develooper Front page | perl.perl5.porters | Postings from March 2000

Re: hook for qs// operator for embedded SQL?

Thread Previous | Thread Next
From:
Joseph N. Hall
Date:
March 20, 2000 00:26
Subject:
Re: hook for qs// operator for embedded SQL?
Message ID:
MailDrop1.2d7j-PPC.1000320012616@perlfaq.com
On Mon, 20 Mar 2000 08:15:43 +0000 mjtg@cus.cam.ac.uk (M.J.T. Guy) wrote:

* Saving two quote characters doesn't seem like a big deal.   Or perhaps
* you want to invent SQL-requests-as-objects?

Well, yes, first you could (in theory) make interpolation context-sensitive.
Again:

  @result = qs/select @cols from $table where $col = $val/

Here, @cols needs to be ,-separated, $table and $col need one kind of
interpolation, and $val needs another.  It's certainly not unreasonable
to assume that a future qs// could be smart enough to recognize this
much SQL.

As to the second, you could certainly have:

  $sqlref = qs/blah blah blah ? blah ? blah/;  # return ref in scalar
  @result = $sqlref->execute(@args);

You p5p-ers may or may not understand the significance and popularity of
SQL and Perl but from my contact with the real world, it's headed toward
"huge."  A few syntactical nods in its direction will likely make Perl
many new friends a year or two down the road.

Frankly I think it would be good to reserve the entire qc (where c is
some lowercase alpha) namespace and quote-op syntax.

  -joseph


Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About