* [Caml-list] Missing tabs
@ 2003-10-26 11:59 Richard Jones
2003-10-26 12:17 ` Nicolas George
2003-10-26 12:33 ` Remi Vanicat
0 siblings, 2 replies; 5+ messages in thread
From: Richard Jones @ 2003-10-26 11:59 UTC (permalink / raw)
To: caml-list
$ ocaml
Objective Caml version 3.07+2
# open Printf;;
# List.iter (printf "\t%s\n") ["foo"; "bar"; "baz"; "buz"];;
foo
bar
baz
buz
- : unit = ()
#
Where did the second and subsequent tabs go? I even tried piping the
output into the 'hd' shell command, and they are definitely missing.
Rich.
--
Richard Jones. http://www.annexia.org/ http://freshmeat.net/users/rwmj
Merjis Ltd. http://www.merjis.com/ - all your business data are belong to you.
"One serious obstacle to the adoption of good programming languages is
the notion that everything has to be sacrificed for speed. In computer
languages as in life, speed kills." -- Mike Vanier
-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Caml-list] Missing tabs
2003-10-26 11:59 [Caml-list] Missing tabs Richard Jones
@ 2003-10-26 12:17 ` Nicolas George
2003-10-26 15:28 ` Richard Jones
2003-10-26 12:33 ` Remi Vanicat
1 sibling, 1 reply; 5+ messages in thread
From: Nicolas George @ 2003-10-26 12:17 UTC (permalink / raw)
To: caml-list; +Cc: Richard Jones
[-- Attachment #1: Type: text/plain, Size: 334 bytes --]
Le quintidi 5 brumaire, an CCXII, Richard Jones a 'ecrit:
> # List.iter (printf "\t%s\n") ["foo"; "bar"; "baz"; "buz"];;
This is a FAQ: you can not partially apply the format string of
printf-like functions. Try (fun x -> printf "\t%s\n" x) instead.
And please note that 'buz' has never been reported as a metasyntactic
variable :)
[-- Attachment #2: Type: application/pgp-signature, Size: 185 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Caml-list] Missing tabs
2003-10-26 12:17 ` Nicolas George
@ 2003-10-26 15:28 ` Richard Jones
2003-10-27 13:12 ` John Carr
0 siblings, 1 reply; 5+ messages in thread
From: Richard Jones @ 2003-10-26 15:28 UTC (permalink / raw)
To: caml-list
On Sun, Oct 26, 2003 at 01:17:58PM +0100, Nicolas George wrote:
> Le quintidi 5 brumaire, an CCXII, Richard Jones a 'ecrit:
> > # List.iter (printf "\t%s\n") ["foo"; "bar"; "baz"; "buz"];;
>
> This is a FAQ: you can not partially apply the format string of
> printf-like functions. Try (fun x -> printf "\t%s\n" x) instead.
I've now read: http://caml.inria.fr/FAQ/FAQ_EXPERT-eng.html#printf
thanks.
Hmmm ... This does appear to violate the principle of least surprise.
So:
let g = Printf.printf " ** %i";;
is supposed to be equivalent to:
let g = print_string " ** "; fun i -> print_int i;;
I would say that it should be equivalent to:
let g = fun i -> (print_string " ** "; print_int i);;
and that the other behaviour is a bug, even if there are
implementation reasons why it is otherwise ...
Just my EUR 0.02.
Rich.
--
Richard Jones. http://www.annexia.org/ http://freshmeat.net/users/rwmj
Merjis Ltd. http://www.merjis.com/ - all your business data are belong to you.
MAKE+ is a sane replacement for GNU autoconf/automake. One script compiles,
RPMs, pkgs etc. Linux, BSD, Solaris. http://www.annexia.org/freeware/makeplus/
-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Caml-list] Missing tabs
2003-10-26 11:59 [Caml-list] Missing tabs Richard Jones
2003-10-26 12:17 ` Nicolas George
@ 2003-10-26 12:33 ` Remi Vanicat
1 sibling, 0 replies; 5+ messages in thread
From: Remi Vanicat @ 2003-10-26 12:33 UTC (permalink / raw)
To: Richard Jones; +Cc: caml-list
Richard Jones <rich@annexia.org> writes:
> $ ocaml
> Objective Caml version 3.07+2
>
> # open Printf;;
> # List.iter (printf "\t%s\n") ["foo"; "bar"; "baz"; "buz"];;
> foo
> bar
> baz
> buz
> - : unit = ()
> #
>
> Where did the second and subsequent tabs go? I even tried piping the
> output into the 'hd' shell command, and they are definitely missing.
printf is partially applied : when you do (printf "\t%s\n"), you print
a tab, and return a function that print its string argument and a new
line.
this will make what you want :
List.iter (fun x -> printf "\t%s\n" x) ["foo"; "bar"; "baz"; "buz"];;
--
Rémi Vanicat
-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2003-10-27 13:34 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-10-26 11:59 [Caml-list] Missing tabs Richard Jones
2003-10-26 12:17 ` Nicolas George
2003-10-26 15:28 ` Richard Jones
2003-10-27 13:12 ` John Carr
2003-10-26 12:33 ` Remi Vanicat
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox