MOO-cows Mailing List Archive
Re: Dynamic variable typing?
--- Michael Brundage wrote:
a + b
might translate into
which might perform
for(i=1; i<=length(a); i=i+1)
a[i] = a[i] + b[i];
(with suitable error-checking thrown in)
What does everyone else think?
--- end of quoted material ---
I was thinking of something like this, but for objects. Basically, if two
objects were added together, it would call and 'add' function somewhere. The
big problem was "where do I put the result?"
5 + 3 = 8
If 5 and 3 were both objects (say #555, and #333), I guess the call would be
#555 + #333, but then the answer would have to go somewhere. I thought of
making a class of 'temporary objects' to hold these answers, but that wouldn't
work if the answer was returned or a property set. The only way to do it would
be to have a reference count kept on each object, and recycle it when it is
reduced to 0. I finally gave up, but I've got a start, if anyone would care to
take it up . . .
I think this would be very cool, because you could re-define all the
'fundamental' datatypes as objects, and have children of these objects doing
different things (say, a child of '$vector' would be '$complex')
Declaration would be easy, just use ;create(), and casts, etc, would be handled
by verbs on each generic object.
Subject Index |