Re: tagged procedures vs procedure properties
Per Bothner 02 Sep 2021 15:48 UTC
I see two semi-orthogical concerns:
(1) Should one be able associate arbitrary (usually named) properties with a procedure,
or just a single tag (which could be a property list)? The former can be built on
top of the latter, but there is a problem with composability: Multiple libraries
may want to associate different kinds of properties with procedures. How should they
avoid stepping on top of each other? Procedure properties is a simple and proven
way to do that. OTOH a simple tag might be more efficient in some cases.
(2) Should you be able to associate properties or a tag with any procedure value
or only a subset of procedure values? The former is conceptually simpler, but
may make some optimizations difficult and/or require more changes to existing implementations.
Maybe instead of:
(lambda/tag tag-expression formals body)
something like:
(lambda/object formals body)
or:
(procedure/object procedure)
These are functionally equivalent:
(procedure/object procedure) === (lambda/object formals (apply procedure formals))
(lambda/object formals body) === (procedure/object (lambda formals body))
The result from procedure/object has all the behavior of the argument procedure,
but it has object identity (eq? is guaranteed to distinguish different results),
plus it is a valid argument to set-procedure-property!
--
--Per Bothner
xxxxxx@bothner.com http://per.bothner.com/