Re: Just a little question before 4.0 will be released

new topic     » goto parent     » topic index » view thread      » older message » newer message
nurminski said...

Greetings.

Sorry, if I am missing something vital in documentation, but is there a way for difining stings in Euphoria in 'heredoc' style?

Ok, I can do this. I suggest this syntax ...

k=#/ 
here comes 
the text    as 
it will be present, no need to escape " and ' and other stuff 
/ 

The idea is that if a '#' is found that is immediately followed by any one of #'`~$^/\|, it indicates the begining of a string literal that terminates with the next occurance of whatever character followed the initial '#'. The one exception here is that if the resulting text begins with a new-line character, the text is trimmed of the leading new-line and any trailing new-line character.

-- Example Code -- 
constant s = #/"one" "two"/ 
constant t = #` 
 
"three"  
"four" 
 
` 

 
constant u = #$ 
"three"  
"four" 
$ 
 
printf(1, "[%s]\n", {s}) 
printf(1, "[%s]\n", {t}) 
printf(1, "[%s]\n", {u}) 
------------------ 

This would output ...

["one" "two"] 
[ 
"three" 
"four" 
] 
["three" 
"four"] 

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu