Version française
Home     About     Download     Resources     Contact us    
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: -- (:)
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).


David 

-----Original Message-----
From: caml-list-bounces@yquem.inria.fr
[mailto:caml-list-bounces@yquem.inria.fr] On Behalf Of Erik de Castro Lopo
Sent: 19 January 2008 03:33
To: caml-list@yquem.inria.fr
Subject: [Caml-list] Concatenation of static strings?

Hi all,

I find myself doing things like the following:

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

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

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

_______________________________________________
Caml-list mailing list. Subscription management:
http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list
Archives: http://caml.inria.fr
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
Bug reports: http://caml.inria.fr/bin/caml-bugs