[squeak-dev] Re: [vwnc] Does anyone have a "new" string literal?
Eliot Miranda
eliot.miranda at gmail.com
Fri Feb 1 18:43:01 UTC 2013
On Fri, Feb 1, 2013 at 10:28 AM, Eliot Miranda <eliot.miranda at gmail.com>wrote:
>
>
> On Fri, Feb 1, 2013 at 9:47 AM, Terry Raymond <
> traymond at craftedsmalltalk.com> wrote:
>
>> I constantly run into the situation where I am incorporating either HTML
>> or javascript****
>>
>> in my methods. The problem I run into is the smalltalk string quote(‘).
>> It is a real pain****
>>
>> to double quote it, and don’t even try to copy and paste external
>> javascript.****
>>
>> ** **
>>
>> So, I think it would be real helpful to have some other funky string
>> quote like****
>>
>> ##{{ }}## or some sequence that is very unlikely to occur in another
>> language.****
>>
>> ** **
>>
>> Has anyone done this or even thought about it?
>>
>
> David Leibs has been pushing a well-thought-through facility he calls (and
> other systems name) "quasi-quote". Here, a string literal contains escape
> sequences, a little like printf, that allow one to substitute values.
> Dave's syntax uses square brackets to escape into Smalltalk. So that
> (IIRC) you say things like
>
> '<html><head></head><body><H1>[myHeading]</H1>'
>
> which compiles to something analogous to
>
> String streamContents: [:s| s
> nextPutAll: '<html><head></head><body><H1>'; nextPutAll: myHeading
> asString; nextPutAll: '</H1>]
>
> But this excellent suggestion has fallen on deaf ears (my own included)
> for more than a decade.
>
<blush>, saw quote, brian farted, now realize this is nothing to do with
your issue Terry. Apologies</blush>.
But you could come up with some convention to embed in quasi-quote to
change the string quote, right? he thing is to choose your escape
character(s) with care. You need a quote to escape to and from processing
($[ & $]). You need a literal quote ( $\ ?). Do you need a third quote to
change quote interpretation? Or do you need a third quote that turns off
single quote as end of string? eg. say $^ indicates no close quote until
the matching $^. So the following
'^'my single-quoted string'^'
denotes
'''my single-quoted string'''
and I realize I can't remember how David's proposal distinguishes between
quasi-quote strings and normal Smalltalk strings.
> ****
>>
>> ** **
>>
>> Terry****
>>
>> ** **
>>
>> ===========================================================****
>>
>> Terry Raymond****
>>
>> Crafted Smalltalk****
>>
>> 80 Lazywood Ln.****
>>
>> Tiverton, RI 02878****
>>
>> (401) 624-4517 traymond at craftedsmalltalk.com ****
>>
>> ===========================================================****
>>
>> ** **
>>
>> _______________________________________________
>> vwnc mailing list
>> vwnc at cs.uiuc.edu
>> http://lists.cs.uiuc.edu/mailman/listinfo/vwnc
>>
>>
>
>
> --
> best,
> Eliot
>
--
best,
Eliot
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20130201/4f6ad89c/attachment.htm
More information about the Squeak-dev
mailing list
|