[e-lang] E-Native Methods and arguments
Kevin Reid
kpreid at mac.com
Wed Aug 30 20:33:26 CDT 2006
On Aug 30, 2006, at 20:57, rick at vecx.net wrote:
> I have a question relating to the MethodN classes in e-native. Is
> it important that we tie the class/functions definition to the
> argument count? The simple question being how many arguments are
> enough?
I am not familar with the ENative design but it sounds like you might
not know this: in E, the number of arguments is dispatched on
visibly, not as an implementation detail, and there are rarely
optional/variable arguments.
? def o {
> to m() { println(`a`) }
> to m(x) { println(`b: $x`) }
> }
# value: <o>
? o.m()
a
? o.m(1)
b: 1
Conceptually, however, this is merely a behavior of ordinary objects,
and is not inherently required by "ELib"'s message passing system.
For example, TextWriters have the variable-argument method 'print',
and matchers in E-language objects can implement any dispatch rules
they choose.
In my E-on-Common-Lisp, to (theoretically) optimize the common case,
the message system passes 'mangled verbs' which incorporate the
arity: :|m/0|, :|m/1|, etc. Compiled fixed-arity calls (i.e. those in
the E language) have their mangled-verb computed at compile time;
dynamic-arity calls (E.call(...)) compute it within E.call. The
mangled verb is passed around as a unit unless and until it
encounters a matcher, at which time it is disassembled and the arity
discarded.
--
Kevin Reid <http://homepage.mac.com/kpreid/>
More information about the e-lang
mailing list