On Monday 16 July 2007 18:51, Slava Pestov wrote:
> Most tuple constructors do the following things only:
>
> - Set the delegate
> - Set slot values from the stack
> - Set slot values to some default value
>
> Perhaps this can be incorporated into the TUPLE: form, then we won't
> need most C:'s at all?
One constructor doesn't fit all, in some cases. In Smalltalk, if you browse
class methods (as opposed to instance methods), they're often constructors. And
there are often many constructors because there may be many ways to setup an
object.
A BOA-constructor should always be available. Custom constructors should be
defined explictly.
So I like the idea of syntax to specify constructors. But maybe it should not
be embedded in the TUPLE: form; There's only one TUPLE: form per class, but
there may be many constructors.
However, I think it's an interesting idea and I'd like to see it developed and
explored.
There's consensus that C:'s often have boilerplate. There's two ways to solve
this. One way is to use a more complicated declarative version of TUPLE: that
bakes in what we've been doing, but hides it. Another way is to find better
stack effects for 'set-delegate' and the slot setters which will impact all
constructors in a positive way. An expression in terms of well designed words
should ideally be very close to a declarative expression. Syntax should be
minimal. As in Lisp, if something can be done equally well with a function or
macro, go with the function.
Anyways, this is too high a talk-to-code ratio for my taste :-) Let's try some
of this stuff out. For my part, I've already coded up the alternative tuple
ideas:
http://dharmatech.onigirihouse.com/tuples-alt.factor
http://dharmatech.onigirihouse.com/slots-alt.factor
I'm ready to recode all my stuff in terms of it, but then I'd be living in a
parallel world as I did with the module system. :-/ It feels nice to finally be
on the same page as everyone else. But if I must play in the corner all by
myself, so be it. :-)
I wouldn't mind putting these in extra/ but slot's are a pretty low level thing
that get's hacked every once in a while (Slava's work on runtime changes to
tuple shapes) and my stuff would have to be adjusted.
Ed-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Factor-talk mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/factor-talk