Conversation
|
There is |
|
Damn, @Octachron was faster. In addition, please write a |
|
@Octachron re. MPR#7827, my new attempt with expect tests does not work very well: |
c91bfff to
06ba0fe
Compare
|
I implemented the suggestion to move |
|
I think that this is more a redirection issue: |
06ba0fe to
f8e0594
Compare
|
@Octachron do you foresee any issue with changing |
(for now the use-sites are unchanged)
|
I do not foresee any problem (and removing one layer in |
The use of a non-Format output caused troubles when called from the toplevel. In comparison, Misc.fatal_errorf was already using Format, and many files freely mix those two functions. The suggestion comes from Florian Angeletti in ocaml#1918. Reviewed by: ? (no change entry needed)
|
Gabriel Radanne (2018/07/19 13:54 -0700):
Damn, @Octachron was faster. In addition, please write a `pp` function
first, and then `to_string` in term of it if you really want it.
Just out of curiosity: why the _pp function first? And how is one
supposed to obtain a to_string function from a _pp function?
|
|
@shindere , you can convert from a let to_string_from_printer pp = Format.asprintf "%a" pp ;;
(* which is Fmt.to_to_string *)Internally, Format will use a buffer and extract the printed string at the end. |
|
Okay thanks! Doesn't that depend on whether there is already something
in the formatter?
Wouldn't you get as a string what was already there plus the string
representation of the value?
|
|
Format.asprintf generates a new formatter from a fresh buffer before printing to it, thus the result does not depend on the former content of any formatter. |
|
Florian Angeletti (2018/07/21 01:47 -0700):
Format.asprintf generates a new formatter from a fresh buffer before
printing to it, thus the result does not depend on the former content
of any formatter.
Okay thanks!
|
| in String.concat "" (print lid []) | ||
|
|
||
| let rec pp ppf = function | ||
| | Lident s -> Format.pp_print_string ppf s |
There was a problem hiding this comment.
Does Lident "~+" need special treatment?
|
|
||
| let rec pp ppf = function | ||
| | Lident s -> Format.pp_print_string ppf s | ||
| | Ldot(p, s) -> Format.fprintf ppf "%a.%s" pp p s |
There was a problem hiding this comment.
What about cases like L.( = ) ?
|
@jberdine excellent questions, thanks! I'll have to look at pprintast to check how that is done there. (The fact that |
|
For types, there is no special identifiers, so I don't think that |
|
Superseded by #1996. |
Longident.to_string : t -> stringis something which I would have needed while implementing ocaml-ppx/ppx_import#25I thought that I was writing the tests out of principle, but in fact my first version was buggy, it would print
(F)Xinstead ofF(X). (One of the worst notations for applications.)