From: Hendrik Tews <tews@tcs.inf.tu-dresden.de>
To: caml-list@yquem.inria.fr
Subject: Re: [Caml-list] printf format strings
Date: Thu, 01 Dec 2005 11:18:10 +0100 [thread overview]
Message-ID: <rliru9w271.fsf@ithif59.inf.tu-dresden.de> (raw)
In-Reply-To: <ad8cfe7e0511301531m589a7abie37d2e3e2cb6e582@mail.gmail.com>
Jonathan Roewen <jonathan.roewen@gmail.com> writes:
{ fmt %}: convert a format string argument. The argument must have the
same type as the internal format string fmt.
And how to use it? I get Bad format `%{' in the toplevel.
My toplevel accepts it, but does nothing on it:
# Printf.printf "%{%d%s%}" "kkkk\n" ;;
This expression has type
(int -> string -> 'a, 'b, 'c, int -> string -> 'a) format4
but is here used with type (int -> string -> 'a, 'b, 'c, 'a) format4
This is expected, because kkkk has the wrong type.
# Printf.printf "%{%d%s%}" "kk%dkk%s\n" ;;
- : unit = <unknown constructor>
This should print something I guess. The "unknown constructor"
looks very suspicious. Maybe the %{ format is meant to generate
random strings???
# String.escaped(Printf.sprintf "%{kkk%}" "kkk\n") ;;
- : string =
"\\136LÛ\\149*\\000\\000\\000 óY\\149*\\000\\000\\0000\\tî\\149*\\000\\000"
;-)
Note that there is a typo in the docs: There is no format %\(...%\):
# Printf.printf "%\\(aaa%\\)";;
Bad conversion %\, at char number 0 in format string ``%\(aaa%\)''
It is %(...%):
# Printf.printf "%(aaa%)";;
- : ('_a, '_b, '_c, '_a) format4 -> unit = <fun>
However, it does not seem to work either:
# Printf.printf "%(aaa%)" "bbbb";;
- : unit = <unknown constructor>
Bye,
Hendrik
PS. These two conversions are new, but not marked as such in the
enhanced reference manual, because they do not appear in the txt
version (which I used for the diffs).
next prev parent reply other threads:[~2005-12-01 10:18 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-11-30 23:31 Jonathan Roewen
2005-12-01 10:18 ` Hendrik Tews [this message]
[not found] ` <6b8a91420512010825k23d78780u@mail.gmail.com>
2005-12-01 16:26 ` Remi Vanicat
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=rliru9w271.fsf@ithif59.inf.tu-dresden.de \
--to=tews@tcs.inf.tu-dresden.de \
--cc=caml-list@yquem.inria.fr \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox