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

Re: Keywords in make-instance?



I think many lisp implementations (like Lucid and HP-CL) restrict &key
arguments to be in the keyword package is because it becomes tedious to
type: 

	(xe:make-instance 'xe:window 'xe:width 30 'xe:height 20 ...)

when the current package is not importing the symbols used in the command.

The problem with this of course is that if the set of legal keywords is
unioned (as it is in multiple inheritance systems) there is a chance of
accidently shadowing some of the inherited parent's keywords if the parents
exist in different packages and have different semantics for the same
keyword name.  For this reason, CLOS allows its init-keys to be in other
packages besides the keyword package.

The problem with the tediousness of explicitly typing the package name for
each &key argument could be circumvented if CL were to adopt the Zetalisp
convention of allowing the package prefix to prefix a form, rather than a
symbol.  The symbols contained within the form would be read with a default
package corresponding to the prefix.  The above expression would become:

	xe:(make-instance 'window 'width 30 'height 20 ...)

which is just as easy to type as:

	(make-instance 'xe:window :width 30 :height 20 ...)

but without the shadowing problems.  

I think this syntax allows the best of both worlds.  Does anyone know if
there is much chance of this convention being adopted by ANSI?

Warren