This is the mail archive of the
kawa@sourceware.org
mailing list for the Kawa project.
Re: Shell-style programming in Kawa
- From: Per Bothner <per at bothner dot com>
- To: Jamison Hope <jrh at theptrgroup dot com>, "kawa at sourceware dot org list" <kawa at sourceware dot org>
- Date: Wed, 29 Jan 2014 00:18:01 -0800
- Subject: Re: Shell-style programming in Kawa
- Authentication-results: sourceware.org; auth=none
- References: <52C4B518 dot 5080000 at bothner dot com> <A72FB562-9459-4C69-B346-A6C94DBD22C4 at theptrgroup dot com> <52E3772D dot 50804 at bothner dot com> <4A37A2F8-76B0-421D-AFCB-62AA1EE78468 at theptrgroup dot com> <52E5995F dot 6000400 at bothner dot com> <52E67F60 dot 5090804 at bothner dot com> <52E751DD dot 6080301 at bothner dot com> <129EA8CD-4BE4-4902-A87B-E61D1DFF6EF5 at theptrgroup dot com>
On 01/28/2014 01:12 PM, Jamison Hope wrote:
Nice. If I'm following the trail correctly, that was changing a
format directive from ~A to ~Q. Is this ~Q directive ever useful
in user code? It isn't documented on the Format page of the
website.
It would be useful for quoting of embedded expressions in DSLs.
For example:
&sql{select * from table where name = "&[name]"}
By using ~Q the "Kawa-SQL" class can add easily add the
appropriate escape characters.
I started a blog article on this, but you can see it's
not much: http://per.bothner.com/blog/2013/Kawa-smart-substitution/
It looks like it acts as if the format specifier were
"\xF202~A\xF203", where #\xf202 and #\xf203 are unassigned
characters from one of the Unicode Private Use Areas. And then
the consumer of the resultant string is responsible for recognizing
these embedded unprintable marks and doing something useful (such
as stripping out a trailing newline). Is that right?
Basically. When shell: is #t, then the handleMarks method may add
escape characters, so when the shell later does word-splitting it
does so more-or-less the same as when the tokenize method does if
for when shell: is false. (FWIW, the handleMarks and tojebize
methods should pobably be merged.)
Another complication is the the characters 0xf200 and 0xf201 are used to
mark sequences.
--
--Per Bothner
per@bothner.com http://per.bothner.com/