Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

Browse thread
Concatenation of static strings?
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2008-01-19 (06:50)
From: David Allsopp <dra-news@m...>
Subject: RE: [Caml-list] Concatenation of static strings?
I don't know whether the compiler optimises the concatenation (it ought to,
just as constant integer arithmetic ought to be evaluated by the compiler),
but how about writing:

    let print_usage () =
        print_endline "\n\
                       Usage : progname [options]\n\
                      \        progname [options] <config file>"

Which is less typing. I use this for long SQL statements in code, as well.
Note that you must escape the first space on the line if you want any spaces
after it to count (the lexer semantics for \CR or \LF ignore whitespace at
the start of the next line).


-----Original Message-----
[] On Behalf Of Erik de Castro Lopo
Sent: 19 January 2008 03:33
Subject: [Caml-list] Concatenation of static strings?

Hi all,

I find myself doing things like the following:

    let print_usage () =
	(	"\n" ^
		"Usage : progname [options]\n" ^
		"        progname [options] <config file>\n"

and wondering, when those strings are concatenated. Is that done
at compile time?

Erik de Castro Lopo
The difference between a violin and a viola is that a viola
burns longer.

Caml-list mailing list. Subscription management:
Beginner's list:
Bug reports: