"TSa (Thomas Sandlaß)" <[EMAIL PROTECTED]> writes:

> Piers Cawley wrote:
>> Let's say I have a class, call it Foo which has a bunch of attributes, and 
>> I've
>> created a few of them. Then, at runtime I do:
>>    eval 'class Foo { has $.a_new_attribute is :default<10> }';
>> Assuming I've got the syntax right for defaulting an attribute,
>
> I think you need a 'class Foo is extended' to re-open the class.
> Otherwise you produce a redefinition error if the scope you call
> eval in already contains---or is that extains because of the name
> search beeing *outwards*---one you start from scratch.

Oh for heaven's sake! That's the last time I go trying to come up with concrete
examples for this sort of thing. Of course, you're right, I should have said
'is extended', but if I were doing it for real, the eval would fail and I'd
have a meaningful error message. 

[ An explanation of why this particular case doesn't require iterating over the
live set ]

I really shouldn't go picking concrete examples that can be worked around
should I? Suffice to say that sometimes (say for debugging purposes, or program
analysis -- Smalltalk can do some cunning typer inferencing tricks by examining
the live set for instance) I would like to be able to iterate over all the
objects in the live set. ISTM that exposing the Garbage Collector at the
Language level is the neatest way of doing this (or coming up with something
like Ruby's ObjectSpace, but conceptually I reckon the GC is the right place to
hang it).

Reply via email to