Forums

Multiline strings

General discussion about Cobra. Releases and general news will also be posted here.
Feel free to ask questions or just say "Hello".

Re: Multiline strings

Postby nerdzero » Tue Dec 11, 2012 3:54 pm

Charles wrote:One nice thing about a special token is that it immediately signals what's going on. The other nice thing about triple quotes is that you don't have to escape single instances of quotes inside the string such as when writing the word don't or quoting something.


Hmm...I can buy the first reason if you are looking at in plain text without highlighting and were unfamiliar with this syntax/convention, but I think the indentation and the way it lends itself to natural blocking would go a long way in this regard. I mean, type inference doesn't immediately signal what's going on but I still dig it.

The second reason is a bit more compelling, but I now associate triple quotes with documentation and my brain might short-circuit seeing doc strings that weren't immediately following a box declaration! :)
nerdzero
 
Posts: 286
Location: Chicago, IL

Re: Multiline strings

Postby hopscc » Wed Dec 12, 2012 4:41 am

FWIW on current experience most text literals are not multiline so its only an occasional appearance/use of the different token where the change does delineate 'something different'.

The triple-quote-as-docstring-only-short-cct clears really fast once actually used for multiline text literals :D
and the association works really well for writing and for grokking whats going on - with or without syntax highliting.

( as noted wayback I've got a patched compiler that implements multiline with triple quote delimiters - its very natural)
hopscc
 
Posts: 632
Location: New Plymouth, Taranaki, New Zealand

Re: Multiline strings

Postby nerdzero » Wed Dec 12, 2012 5:38 am

Yeah, I'd probably warm up to them after I used them.

Hops, how are leading and trailing newlines handled in your patch?
nerdzero
 
Posts: 286
Location: Chicago, IL

Re: Multiline strings

Postby hopscc » Wed Dec 12, 2012 7:19 pm

Pretty much as inserted.
Theres some handling for dropping leading whitespace ( if indented the right way) and some
enableable capability to allow start and end bar delimiters ( so you can see what wspace you will get)
roughly as described in the previous postings on this topic.

The patch on ticket:120 has the same handling code (but it provides
different delimiters - bigRaw R'' and R"").
hopscc
 
Posts: 632
Location: New Plymouth, Taranaki, New Zealand

Previous

Return to Discussion

Who is online

Users browsing this forum: No registered users and 15 guests

cron