[bitc-dev] pattern binding
Jonathan S. Shapiro
shap at eros-os.org
Mon Jun 26 10:18:46 EDT 2006
Right now, BitC accepts binding patterns in LET, LETREC, DEFINE, and
LAMBDA. A binding pattern is an arbitrary tree of identifiers and pairs
of binding patterns.
Ignoring contrived examples, the only serious use of binding patterns I
can see at the moment is for multiple value return. This use takes the
form
(let ((a,b) (f ...)) ...)
or
(define (a,b) (f ...))
I'm considering removing binding patterns from lambda arguments, which
would mean that procedure arguments must be declared as simple
identifiers. Until now, the compiler has rewritten:
(lambda ((x,y) ...)
into
(lambda (tmp) (let ((x,y) tmp) ...))
The argument to remove syntactic support for pair patterns at lambda
arguments has to do with the use of the function type syntax (fn
(type...) type) at a PROCLAIM form. For reasons of documentation, it is
VERY useful if a proclaim form can give argument identifier names. These
names have no semantic significance to the compiler, but they are
invaluable for human consumption. Compare:
(proclaim transfer: (fn (bank bank) bool))
vs.
(proclaim transfer: (fn (dest:bank source:bank) bool))
[Aside: this is also a good argument for making PROCLAIM be
syntactically more parallel to DEFINE].
The problem here is that you want the identifiers to be optional,
because their are other contexts where they are *not* meaningful. The
difficulty at that point is that the pair pattern syntax breaks down in
a hopeless snarl of shift/reduce conflicts. I could resolve them all by
forcing operator precedence rules on the convenience forms, but I think
it's much cleaner to just remove (and simplify) the pattern binding
forms.
In fact, I'ld like to remove them everywhere.
Reactions? Opinions?
shap
More information about the bitc-dev
mailing list