True, and it is why newLISP uses two delimiters for this purpose, {}  
and [text][/text]. The latter might not work well in clojure though  
because of its use of arrays.

The former is used for short strings, often for the purpose of regular  
expressions or to avoid quoting quotes, and the latter is used when  
you have a lot of text, or your text contains braces.

Your point is valid though because say for example you want include  
Clojure sample code in the docs for a function, you are very likely to  
run across braces. For this reason it may be useful to include two  
different delimiters, a short-hand for short strings or strings that  
don't include braces, and a long-hand for when you need it.

For the shorthand I still think #s{} makes a good fit for clojure, and  
for a long hand something else could be done. Personally I like the  
triple-quote you suggested because it's effective and aesthetically  
pleasing.

Or you can just go with """ and scrap the #s{}, either way though I  
think this would make an exciting addition to Clojure.

Hopefully the devs watch this list? Or should I also suggest this on  
clojure-dev?

- Greg

On Oct 11, 2009, at 7:31 PM, James Reeves wrote:

>
> What if you need to use braces? It seems to me that any syntax for
> representing long strings needs a terminator that is unlikely to occur
> within the string itself. For example, Python uses """, and XML CDATA
> uses ]]>, both of which are character sequences unlikely to turn up in
> a string. By contrast, an ending brace } is not rare enough to be used
> as a terminator, IMO.
>
> - James
>
> On Oct 11, 10:38 pm, Greg <g...@kinostudios.com> wrote:
>> Dear Clojure group and developers,
>>
>> In a recent discussion on #clojure it was pointed out that another
>> language called newLISP has an excellent feature that would be neat  
>> to
>> adopt into clojure, namely its special text delimiters {} and [text] 
>> [/
>> text]. It uses these delimiters to specify verbatim text (i.e. what's
>> in the parens is *exactly* what the string is, including the  
>> newlines).
>>
>> This feature makes it incredibly easy to write and include various
>> bits of text in the language such as example code, html, and it makes
>> writing regular expressions simple by avoiding the need for some
>> escapes.
>>
>> For example (newLISP code):
>>
>>         (replace {"quoted" text} my-str {"quoted" string})
>>
>> vs
>>
>>         (replace "\"quoted\" text" my-str "\"quoted\" string})
>>
>> As this has numerous advantages we discussed how such a construct
>> could be brought in to the benefit of Clojure, as in Clojure both the
>> {} and [] characters are reserved.
>>
>> The following candidates were considered and rejected for various
>> reasons:
>>
>>         <> ; rejected because conflicts with statements like (< x 1)
>>         #"" ; rejected because represents regex
>>         #[] ; rejected because implies some sort of data structure  
>> like sets,
>> #{}
>>         [t][/t]; rejected because conflicts with arrays
>>
>> Finally we agreed that #s{ ... } would make a nice fit, as it fits
>> nicely with clojure's existing syntax and tendency to use the sharp  
>> to
>> signify a shorthand for something. On irc 'Chousuke' pointed out that
>> this construct could be used to make it easier to write doc strings
>> that include sample code for Clojure's functions, but of course there
>> are many other uses for such a construct (which I should note exists
>> in many other languages as well, even bash, but I referenced newLISP
>> as it's also a lisp and has a particularly elegant implementation).
>>
>> Any and all input is welcome on this proposal!
>>
>> Kind regards and thanks in advance for taking this into  
>> consideration,
>> Greg (irc: itistoday)
> >


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to