[erlang-questions] String continuation

James Churchman jameschurchman@REDACTED
Thu Jan 13 22:15:26 CET 2011


i think for what your are asking, its designed to allow strings to elegantly span lines. In JS for example its very common to want multiline strings (for html for example), and people do the following 

"really really long string part 1" +
"really really long string part 2" +
"really really long string part 3"

to get around this limitation of multi line spanning strings
(
you cant even do this for example, and have it include the line breakes
"long line 1
 long line 2"
)

people noted however this is quite inefficient  as it involves (potentially dozens) of string concatenations all at run time, often in loops

most JS compressors now will go and optimise it into a huge one-liner, as this provides a good speed up & people will never read this optimised version

i would personally rather just type

"really really long string part 1"
"really really long string part 2"
"really really long string part 3"

than the former but i guess its less common in erlang to have large chunks of text so its a bit less relevant.. still something i appreciate tho





On 13 Jan 2011, at 17:40, Attila Rajmund Nohl wrote:

> Hello!
> 
> Let's have a look at this little example code:
> 
> -module('strc').
> 
> -export([f/0]).
> 
> f() ->
>    {["string1",
>      "string2"],
>     ["string3"
>      "string4"]}.
> 
> This compiles fine and returns a tuple with two lists, the first with
> 2 strings, the second with a single list. Of course, if there was only
> a typo in the second list (a missed comma), I wouldn't notice it until
> the code executes (which might happen in an inconvenient time in error
> handling code). I wonder that the possibility to omit the extra ++
> from the end of "string3" line worth the problems what might be caused
> by the missing comma. This only bit me once, so it might not be that
> common...
> 
> ________________________________________________________________
> erlang-questions (at) erlang.org mailing list.
> See http://www.erlang.org/faq.html
> To unsubscribe; mailto:erlang-questions-unsubscribe@REDACTED
> 



More information about the erlang-questions mailing list