New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Distinguish data and literals in CamlinternalFormat.make_printf #6457
Comments
Comment author: @gasche (We discussed this with Alain and Benoît and I agree this is a good idea.) |
Comment author: bvaugon I attach a patch that implement it |
Comment author: @alainfrisch Applying the patch on 4.02 leads to: boot/ocamlrun boot/ocamlc -nostdlib -I boot -strict-sequence -w +33..39+48 -warn-error A -bin-annot -safe-string -I utils -I parsing -I typing -I bytecomp -I asmcomp -I driver -I toplevel -c utils/tbl.ml File "utils/tbl.ml", line 110, characters 33-54: Error: The constructor CamlinternalFormatBasics.Open_box belongs to the variant type CamlinternalFormatBasics.formatting_gen but a constructor was expected belonging to the variant type CamlinternalFormatBasics.formatting_lit Probably some bootstrapping issue. What's the bootstrap procedure when something changes in CamlinternalFormatBasics? |
Comment author: bvaugon Since this patch do not modify CamlinternalFormatBasics, it should work directly without special bootstrap procedure. This patch (add-acc-literal.diff) seems to work on a proper checkout of the trunk. Your compilation problems about Open_box probably comes from the #6418 patches. The bootstrap procedure for the #6418 patches is in fact a bit complicated since it modifies the format6 & co. type declarations. It is described in its own attached file howto-apply-fix-open-tag-patches.txt. |
Comment author: @alainfrisch Ah yes, sorry. I've committed your patch to 4.02 (rev 14988). Thanks for the quick reaction! |
…printf (patch by Benoit Vaugon). git-svn-id: http://caml.inria.fr/svn/ocaml/version/4.02@14988 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
Original bug ID: 6457
Reporter: @alainfrisch
Assigned to: @alainfrisch
Status: closed (set by @xavierleroy on 2015-12-11T18:28:06Z)
Resolution: open
Priority: normal
Severity: minor
Fixed in version: 4.02.0+dev
Category: standard library
Monitored by: @jmeber
Bug description
This function is useful to create custom formatting libraries (e.g. replacement for Format, with a different layout model and syntax for formatting instructions). One problem with it is that the callback cannot distinguish between string literals in the format strings and strings obtained from printed arguments. It seems very simple to split the Acc_string into two constructors (Acc_data_string/Acc_string_literal), and same for Acc_char. They will always be treated in the same way by the current code (for Printf and Format), but a custom formatting library would typically only recognize formatting markers in Acc_string_literal not Acc_data_string.
File attachments
The text was updated successfully, but these errors were encountered: