[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: globals considered harmfull.
I. R. Woollard writes:
> Self Style Suggestion:
> If I want to produce an instance of something, I believe it is better
> to ask the traits object for it.
Only if you're following the class-instance model. Suppose you have
objects that don't have a traits object? E.g. all the oddballs?
> I propose that most traits objects should respond to a 'new' invocation
> - it allows the posibility of parameters to determine the contents.
What's wrong with providing a prototype that understands a
> - it doesn't preclude having globals as well
How does copy preclude "globals"? A prototype can refer to any
> - a 'new' mixin is easily defined
As is a 'copy' mixin....
> - a lot of traits already have a prototype slot
And _all_ the prototypes have traits slots. A prototype can't
function without a traits slot, whereas a traits _can_ function
without a prototype slot. Don't require unnecessary slots in traits
objects -- that's violating the "minimal but sufficient" design rule
(the minimal part).
> - its less code in the clients, you don't have to use explicit "copy"'s
What's the difference between sending new to the traits object versus
copy to the prototype?
traits fooBar new.
prototypes fooBar copy.
> - it is closer to the smalltalk model, hence easier to learn
Um...... Why don't we add classes and metaobjects to Self, too? That
way, Self will be just as complex as Smalltalk.... (just kidding :-)
> - accidently forgetting the copy is a real screw up, you end up
> modifying the prototype
Accidentally forgetting a new would be worse. When you modify the
traits object, everything that inherited from that traits object would
be modified. When you forget a copy, only the prototype is modified
-- a much smaller-scale change.
So using copy is actually _safer_ than using new.
> p.s. I'm obviously missing something here... I'm quite prepared to be
Did that help?
> p.p.s. Is there any kind of style guide anywhere? (I have read the User
I've found the papers that _aren't_ on compiler internals to be
extremely helpful in learning about the different kinds of things you
can do with Self objects that you can't do with objects in other
> p.p.p.s. Long term, languages are port or die. How portable *is* Self?
It's a native compiler. Native compilers are always a pain to port,
whatever the language....