[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Macros Make Me Mad

Sundar Narasimhan writes:
> > Examples of good sublanguages:
> > o Oracle PL/SQL:
> >
> >  <http://info-it.umsystem.edu/oradocs/doc/server/doc/PLS23/toc.htm>
> Gee.. I never thought I'd see PL/SQL mentioned here.
> Neel: Could you say more what you like about PL/SQL? (I agree w/ you
> btw, but I'd like to know your reasons.. esp. since PL/SQL is rarely
> thought of as 'light-weight' or having 'macros' :)

It's not because of macros, but because it has a SQL sublanguage
integrated deeply into it. A misformed SQL query embedded into a
PL/SQL program will get a compile-time error, because it will be a
syntax error in the PL/SQL program, too. It's also fairly easy to mix
host language expressions with SQL queries, and it has a number of
syntactic constructs (select into, cursor for-loops) that make it less
needful to explicitly manage cursors.

You can *use* macros to build a sublanguage that gets you most of this
power in a general-purpose language. You can write your macro
definitions so that an improperly formed query will cause a host
language syntax error, and you can trivially add the iteration and
other constructs that make cursor management easier. The one big miss
with a macro sublanguage is that PL/SQL will check to make sure that
all of the columns and tables are all consistent before running, and
we can't do that, only because the compiler can't query the database.

I suppose a procedural macro system theoretically *could* do that(!),
but Needle's macros are based vaguely on an extensible grammar model.

Neel Krishnaswami