Robert Klemme wrote:
"Trans" <transfire@gmail.com> schrieb im Newsbeitrag
news:1106832987.976217.139210@f14g2000cwb.googlegroups.com...
> Maybe someone can offer me a possible reason for this. I have a set
of
> classes in a module called Markers. I have a module method,
> Markers#list, that does nothing more than collects them into an
array.
> Then in my program when I do:
>
> > markers = Markers.list
>
> It works. But when I do:
>
> > markers = Markers.list.collect { |m| nm = m.dup ; nm }
You can also do:
markers = Markers.list.collect { |m| m.dup }
Thanks. That true, but the line I ultimately want is:
markers = Markers.list.collect { |m| nm = m.dup ; nm.parser = self;
nm }
I need to pass the current parser object down to the markers themselves
b/c I do "reentrant" pasrsing. But obviously I don't want to effect the
Classes themselves with this state info in case they are used by
another parser, so I'm duplicating them.
> It does not work.
>
> I don't understand why. Obviously my initial thought is that
something
> about my Marker classes must not be shallow, but they're just
classes,
> made of methods and have no state, so I don't see how that can be.
So Markers.list returns a list of class objects?
Yes. Here, Markers.list returns
[MarkUps::Markers::Command, MarkUps::Markers::Verbatim,
MarkUps::Markers::Outline, MarkUps::Markers::Document,
MarkUps::Markers::Paragraph, MarkUps::Markers::Table]
and the dup'd collection returns:
[#<Class:0x4033a584>, #<Class:0x4033a534>, #<Class:0x4033a4f8>,
#<Class:0x4033a4a8>, #<Class:0x4033a480>, #<Class:0x4033a444>]
> (Actually they do have a small bit of boolean state in a class
instance
> var, but I check and it is being duplicated.)
> I just don't get it. Any ideas?
What exactly goes wrong?
Unfortunately it is strange. The Outline Marker which tells the parser
how to identify and parse an outline fails.
T.