Mantis Bug Tracker

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0006452OCamlOCaml standard librarypublic2014-06-05 16:032015-03-10 13:23
Assigned Todim 
PrioritynormalSeverityfeatureReproducibilityhave not tried
PlatformOSOS Version
Product Versionlater 
Target VersionundecidedFixed in Version4.03.0+dev 
Summary0006452: custom format
DescriptionIt would be good if we could put custom functions into a format. There doesn't need to be a syntax for it, this could be the job of a ppx.

I'm thinking of something like this:

  | Custom :
      ('b -> 'x -> 'c) * ('a, 'b, 'c, 'd, 'e, 'f) fmt ->
        ('x -> 'a, 'b, 'c, 'd, 'e, 'f) fmt

This would allow to write things like in a much cleaner way. At the moment we modify the call site to stuff the conversion functions in the list of arguments: it's not pretty and becoming more and more complex. With the suggested modification we could simply 'map' the format and stuff the conversion functions in it.

I don't have a use case but it might also be interesting to allow custom functions to take 0 or more than 1 argument, here is a more generic proposal:

  | Custom :
     ('x, 'y, 'a, 'c) custom_arity * ('b -> 'y) * ('a, 'b, 'c, 'd, 'e, 'f) fmt ->
       ('x, 'b, 'c, 'd, 'e, 'f) fmt

  type (_, _, _, _) custom_arity =
    | Zero : ('a, 'b, 'a, 'b) custom
    | Succ : ('a, 'b, 'c, 'd) custom -> ('x -> 'a, 'x -> 'b, 'c, 'd) custom
Attached Filesdiff file icon custom-format-string-only.diff [^] (4,043 bytes) 2015-03-10 13:20 [Show Content]

- Relationships

-  Notes
gasche (developer)
2015-03-08 10:43

The patch proposed in [^]
was just merged in trunk. Thanks.
dim (developer)
2015-03-10 13:23

Added a patch to make custom functions always return a string. To avoid pinning the format to one specific class of printf functions.

- Issue History
Date Modified Username Field Change
2014-06-05 16:03 dim New Issue
2014-06-19 17:53 gasche Status new => acknowledged
2014-06-19 17:54 gasche Tag Attached: junior_job
2014-09-04 00:25 doligez Target Version 4.02.1+dev => undecided
2015-03-08 10:43 gasche Note Added: 0013408
2015-03-08 10:43 gasche Status acknowledged => resolved
2015-03-08 10:43 gasche Fixed in Version => 4.03.0+dev
2015-03-08 10:43 gasche Resolution open => fixed
2015-03-08 10:43 gasche Assigned To => dim
2015-03-10 13:20 dim File Added: custom-format-string-only.diff
2015-03-10 13:23 dim Note Added: 0013424

Copyright © 2000 - 2011 MantisBT Group
Powered by Mantis Bugtracker