Re: A6: macro invocants

2003-03-13 Thread Paul
> The sugar I'm using here is to go from > >$db.do_sql("select * from Foo"); > to >$db.select * from Foo; Since we're fishing, call it a circumfix operator, something like sql...execute. Like this: $db.sql select * from Foo; execute; _

Re: A6: macro invocants

2003-03-12 Thread Dave Whipp
Brent Dax wrote: Dave Whipp: # But you're right, there are situations where the (base) type # might not # be knowable: and these could result in syntax errors. Except they wouldn't, at least not always. [snip] The only part of that I'm not sure about is infix:LIKE, since such an operator hasn't

RE: A6: macro invocants

2003-03-12 Thread Brent Dax
Dave Whipp: # But you're right, there are situations where the (base) type # might not # be knowable: and these could result in syntax errors. Except they wouldn't, at least not always. $db.select * FROM Foo WHERE Foo.bar LIKE a%b; $db.select() * FROM(

Re: A6: macro invocants

2003-03-12 Thread Dave Whipp
Luke Palmer wrote: I'm not quite sure I follow you (I'm not familiar with that pattern). But the macromethod I imagine is the non-polymorphic one, and the one it expands to is the polymorphic one, if I'm guessing correctly. And you certianly could do that. yes: http://patterndigest.com/patterns/Te

Re: A6: macro invocants

2003-03-12 Thread Larry Wall
On Wed, Mar 12, 2003 at 03:35:58PM -0800, Dave Whipp wrote: : Larry Wall replied: : >: my Database $db = MySqlDatabase.connect(...); : >: $db.select * FROM Foo WHERE Foo.bar LIKE a%b; : : >To answer your actual question, you either need to have some keyword out : >front to start the alternate

Re: A6: macro invocants

2003-03-12 Thread Luke Palmer
> Luke Palmer wrote: > > > Well, if you did that, it surely couldn't be polymorphic, which kind > > of defeats most of the purpose of making it a method. > > I disagree. Consider the "template method" patten. This uses a > non-polymorphic method in a base class to invoke a set of polymorphic >

Re: A6: macro invocants

2003-03-12 Thread Dave Whipp
Luke Palmer wrote: Well, if you did that, it surely couldn't be polymorphic, which kind of defeats most of the purpose of making it a method. I disagree. Consider the "template method" patten. This uses a non-polymorphic method in a base class to invoke a set of polymorphic methods in a standar

Re: A6: macro invocants

2003-03-12 Thread Luke Palmer
Dave Whipp wrote: > (OK, thats not a good example, but you get the gist). If sure it would > be possible to write the macro in such a way that it looks at its LHS > arg -- and ignores itself if its not a Database object ... but that > places an overly large burden on the macro writer. To avoid

Re: A6: macro invocants

2003-03-12 Thread Dave Whipp
Larry Wall replied: : my Database $db = MySqlDatabase.connect(...); : $db.select * FROM Foo WHERE Foo.bar LIKE a%b; To answer your actual question, you either need to have some keyword out front to start the alternate parsing, or you need to treat ".select" as an infix macro that has an ordina

Re: A6: macro invocants

2003-03-12 Thread Larry Wall
On Tue, Mar 11, 2003 at 05:35:34PM -0800, Dave Whipp wrote: : The effect of a macro is lexical; but "the name may be installed in : either a package or a lexical scope". If the name is installed in a : class, can it be invoked via a variable of that class? : : Example (SQL query integrated via m

Re: A6: macro invocants

2003-03-12 Thread Larry Wall
On Tue, Mar 11, 2003 at 05:35:34PM -0800, Dave Whipp wrote: : The effect of a macro is lexical; but "the name may be installed in : either a package or a lexical scope". If the name is installed in a : class, can it be invoked via a variable of that class? : : Example (SQL query integrated via m

A6: macro invocants

2003-03-11 Thread Dave Whipp
The effect of a macro is lexical; but "the name may be installed in either a package or a lexical scope". If the name is installed in a class, can it be invoked via a variable of that class? Example (SQL query integrated via macro): my Database $db = MySqlDatabase.connect(...); $db.select *