Mantis Bug Tracker

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0004956OCamlOCaml generalpublic2010-01-07 11:412011-12-09 11:08
ReporterBardou 
Assigned To 
PrioritynormalSeverityfeatureReproducibilityN/A
StatusacknowledgedResolutionopen 
PlatformOSOS Version
Product Version3.11.1 
Target VersionFixed in Version 
Summary0004956: Printf format: %v or %V to print any value
DescriptionThe idea is to be able to write :

Printf.printf
  "Hello %v, %v and %v are OCaml values"
  "user name"
  1
  [ true; false ];

Which would print something like :

Hello "user name", 1 and [ true; false ] are OCaml values
Additional InformationThis would be very useful especially when debugging.

The toplevel already contains a mechanism to print any type, except functions and abstract values. The same printing conventions could be used. In particular : functions could be printed as <fun>, abstract values as <abstr>.

A mechanism should be added to the typing of formats so that %v (or %V) accepts any value type. Then, code generation could use the type information to produce the correct printer.

This correct printer cannot be produced for polymorphic values, but they could be printed as <poly>.

Maybe %V is better than %v, as the convention seems to be that uppercase letter use OCaml conventions.
TagsNo tags attached.
Attached Files

- Relationships

-  Notes
(0005227)
weis (developer)
2010-01-12 10:01

This is a major feature wish that requires careful thinking and a lot of work!

Furthermore, we would not have a completely satisfactory solution in the end (due to this <poly> catch all case that tend to propagate, as far as you use polymorphic functions). The correct solution to get this feature in its full glory is a major modification of the type system along the lines of G'Caml.

In short, a natural feature wish in a strongly typed polymorphic language; we had it in mind for decades; unfortunately, we are not yet ready to offer it, even in the rather limited extent you proposed.

- Issue History
Date Modified Username Field Change
2010-01-07 11:41 Bardou New Issue
2010-01-07 15:22 doligez Status new => acknowledged
2010-01-12 10:01 weis Note Added: 0005227


Copyright © 2000 - 2011 MantisBT Group
Powered by Mantis Bugtracker