On Wed, Apr 20, 2005 at 01:51:11PM -0400, Matt wrote:
: If not already possible, it would be neat to be able to define your own
: quote blocks.  Such as being able to define how to parse the below lines:
: 
: $result = q:sql/SELECT * FROM table/;
: 
:       for q:sql/SELECT * FROM table WHERE id=$id/ {
:               say $_.id ~ ' -> ' ~ $_.value;
:       }

That's certainly doable, for some value of certainly.  But see below.

: Or someone could write a module for P6SQL ? (Pardon me for not remembering
: exactly how HEREDOCs work in P6)
: 
:       p6sql_query "SQLPROC">>
: 
:       $result = SELECT * FROM table
:       FOREACH ROW IN $result AS $field
:               SAY $field.id " -> " $field.value
:       END FOREACH
: 
:       SQLPROC
: 
: Or maybe I'm getting a bit too crazy.

Heredocs are variants on q:to<SQLPROC> these days, but if you're going
to be mixing Perl and SQL syntax, it's probably better to dispense
with the heredoc and just have a language variant so that you can
parse it at compile time.  A heredoc would tend to delay your parse
till run-time, and you'd still have to mix up your parsers somehow.
I don't offhand see a good reason for delaying your parse till run
time, and I can see good reasons for wanting to make your SQL visible
to some optimizer or other at compile time.  (You can certainly parse
at compile time and delay various bindings till run time, so that's not
what is at issue here.)

Larry

Reply via email to