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

applicability of "syntax" constructs

[I haven't seen mail from RRRS-AUTHORS for a while; I assume this is
because the list has been dormant, rather than because of a mailer

I'd like to solicit views on the question of application of
macros and their first- vs. second-class status in Scheme.
The popular evaluation model for "syntax," as I understand
it, implies that evaluation of (X a b c) will induce Scheme
to look for a "syntax" definition of X before looking for
a normal binding, whereas in (a X b c) the "syntax" definition
of X is not sought by the evaluator and the normal binding, if
any, is used.

Now consider the case where, for example, "a" above is "apply".

I find this troubling.  (apply or '(#f #f #t)) "should work," from
the perspective of the programmer.  This is true for two reasons:

1. Consistent treatment of operators as viewed from the perspective of
   the programmer (vs. the implementor or language designer).
2. Inability to determine when objects may or may not be applied on
   a practical basis.

Some time ago we discussed introducing APPLICABLE?; I believe this
was shelved in favor of PROCEDURE?, which of course is not quite the
same thing.  I'm especially concerned about what happens once we
define a user-accessible macro capability and let the users loose
with it: in a large system, a given programmer only writes a small
part of the software, but for Scheme the standard interface specification of
a procedure someone else wrote no longer is adequate to tell you
how to use it---you also need to know whether or not it is APPLICABLE?.
Worse, in practice we learn how to use operators by looking at other 
people's code rather than from an interface spec (if one even exists), 
and even a programmer who is familiar with the principles of Dijkstra
short-circuit AND/OR constructs and so forth would find nothing in
looking at (or #t #f) to would indicate that (apply or '(#t #f))
would be improper.  

Even given the availability of some predicate that distinguishes 
between syntax and procedures, our code would become
tortuously cluttered if we have to insert checks for APPLICABLE?
throughout our programs whenever we wish to apply (what we hope is)
the procedure bound to a token someone else defined.

This line of reasoning seems to me to lead to a requirement for either 
a "smart compiler" or the implementation of macros as first-class objects,
at which point we seem in essence to be talking about FEXPRS/NLAMBDAS.

I've only gotten into this issue far enough for it to bother me, not
far enough to see a clear design solution; perhaps others have more
insight to offer.