View previous topic :: View next topic |
Author |
Message |
petar2000
Joined: 29 Jun 2009 Posts: 1
|
Posted: Mon Jun 29, 2009 6:14 am Post subject: Multiline string question |
|
|
A newcomer question :
Does MiniD support (or will support) multiline strings like in Ruby ?
I mean something like this :
Code: |
this is <<END
mulitline
string
END
|
It is convenient to copy/paste some text directly, without enclosing every line with "" and escaping " occurences. |
|
Back to top |
|
|
JarrettBillingsley
Joined: 20 Jun 2006 Posts: 457 Location: Pennsylvania!
|
Posted: Mon Jun 29, 2009 8:12 am Post subject: |
|
|
All string literals are multiline:
Code: | local str = "oh hi
this is a new line
and a third" |
There is, however, no way to do those strings that end with an identifier. The closest you can get is to use a WYSIWYG string. These do not process escape sequences, but their delimiters must be "escaped" by doubling them up:
Code: | local str = `this is some verbatim text
these \a\b\f\n escape sequences won't be processed.
however, if I want to put a backquote in the string,
I have to ``double it up'.` |
The `` before "double" is interpreted as a single ` in the string data. The string ends after the final period. |
|
Back to top |
|
|
spir
Joined: 11 Oct 2010 Posts: 2
|
Posted: Wed Feb 09, 2011 10:13 am Post subject: |
|
|
Hello,
I just just discovered MiniD, waow! Highly attractive; and very interesting for me because I have a (toy) language project with numerous similarities with MiniD (among which implementation in D).
About this thread's topic, 2 points:
* Originally, I planned to have strings basically multiline (like D) but reverted to python-like distinction, because of practical annoyance: editors will reinterpret all the rest of the code as soon as one presses '"'; which is indeed stupid and... unfolds everything else till the end of the module (grrr!).
* I also planned to escape special chars, like '{' in your case, by doubling instead of using '\', looks easier for non-programmers. But then string "uncoding" seems a bit more complicated: one needs to look for patterns like <'{' with no other '{' behind>, instead of using basic replace tools. Or split the string on '{{', interpret the rest, then join back with '{'. Or manually iterate and replace/interpret on the way.
What do you think?
Denis |
|
Back to top |
|
|
JarrettBillingsley
Joined: 20 Jun 2006 Posts: 457 Location: Pennsylvania!
|
Posted: Thu Mar 31, 2011 7:47 pm Post subject: |
|
|
I think you can make your language however you like! |
|
Back to top |
|
|
maustin
Joined: 15 Jun 2009 Posts: 10
|
Posted: Sun Apr 17, 2011 4:19 am Post subject: |
|
|
Pushing your own language on another man's language forum? Denis, how could you? . See you on pilud - haven't been there for a while!
Mike |
|
Back to top |
|
|
|