FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Multiline string question

 
Post new topic   Reply to topic     Forum Index -> MiniD
View previous topic :: View next topic  
Author Message
petar2000



Joined: 29 Jun 2009
Posts: 1

PostPosted: Mon Jun 29, 2009 6:14 am    Post subject: Multiline string question Reply with quote

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
View user's profile Send private message
JarrettBillingsley



Joined: 20 Jun 2006
Posts: 457
Location: Pennsylvania!

PostPosted: Mon Jun 29, 2009 8:12 am    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
spir



Joined: 11 Oct 2010
Posts: 2

PostPosted: Wed Feb 09, 2011 10:13 am    Post subject: Reply with quote

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
View user's profile Send private message
JarrettBillingsley



Joined: 20 Jun 2006
Posts: 457
Location: Pennsylvania!

PostPosted: Thu Mar 31, 2011 7:47 pm    Post subject: Reply with quote

I think you can make your language however you like!
Back to top
View user's profile Send private message Visit poster's website
maustin



Joined: 15 Jun 2009
Posts: 10

PostPosted: Sun Apr 17, 2011 4:19 am    Post subject: Reply with quote

Pushing your own language on another man's language forum? Denis, how could you? Wink. See you on pilud - haven't been there for a while!

Mike
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic     Forum Index -> MiniD All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group