caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: "David Allsopp" <dra-news@metastack.com>
To: <caml-list@yquem.inria.fr>
Subject: RE: [Caml-list] Concatenation of static strings?
Date: Sat, 19 Jan 2008 06:50:31 -0000	[thread overview]
Message-ID: <000501c85a67$9e7cf5e0$6c7ba8c0@countertenor> (raw)
In-Reply-To: <20080119143259.46752d11.mle+ocaml@mega-nerd.com>

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


  reply	other threads:[~2008-01-19  6:50 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-01-19  3:32 Erik de Castro Lopo
2008-01-19  6:50 ` David Allsopp [this message]
2008-01-19  7:36   ` [Caml-list] " Erik de Castro Lopo
2008-01-19 10:55 ` David Baelde
2008-01-24 23:02   ` Ashish Agarwal
2008-01-25  1:57     ` Oliver Bandel
2008-01-25 10:47       ` Loup Vaillant
2008-01-26 13:27         ` Ashish Agarwal
2008-01-26 16:13     ` Jon Harrop
2008-01-26 19:58       ` Oliver Bandel

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='000501c85a67$9e7cf5e0$6c7ba8c0@countertenor' \
    --to=dra-news@metastack.com \
    --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;
as well as URLs for NNTP newsgroup(s).