From: Remi VANICAT <vanicat@labri.u-bordeaux.fr>
To: caml-list@inria.fr
Subject: Re: [Caml-list] Printf.sprintf ?
Date: 16 Aug 2001 11:27:30 +0200 [thread overview]
Message-ID: <87d75wxsl9.dlv@wanadoo.fr> (raw)
In-Reply-To: <Pine.BSF.4.21.0108150810370.27897-100000@shell5.ba.best.com>
Brian Rogoff <bpr@best.com> writes:
> Because Printf is a bit of a hack, in that the syntax for a format string
> is the same as the syntax for a regular string. As a beginner, when you
> use Printf, it's easier to use the format string as a literal and not
> as a variable. If you feel you must do this, the polite way is as follows
>
> # let q = ("%s" : ('a, 'b, 'c) format);;
> val q : (string -> 'a, 'b, 'a) format = <abstr>
> # let s = Printf.sprintf q "enigiets";;
> val s : string = "enigiets"
>
> and there's also a rude way (forgive me Berke! :)
>
> let s : string = Printf.sprintf (Obj.magic q) "enigiets";;
it's often not a good idea :
# let q = "%s";;
val q : string = "%s"
# let s : string = Printf.sprintf (Obj.magic q)0;;
Segmentation fault
moi@debian:~$
this break the type system.
better use the first solution.
--
Rémi Vanicat
vanicat@labri.u-bordeaux.fr
http://dept-info.labri.u-bordeaux.fr/~vanicat
-------------------
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
next prev parent reply other threads:[~2001-08-16 10:06 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2001-08-15 9:49 Johann Spies
2001-08-15 15:27 ` Brian Rogoff
2001-08-16 9:27 ` Remi VANICAT [this message]
[not found] <200108151045.f7FAjl423204@sarg.ryerson.ca>
2001-08-15 11:04 ` Johann Spies
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=87d75wxsl9.dlv@wanadoo.fr \
--to=vanicat@labri.u-bordeaux.fr \
--cc=caml-list@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