Subject: | Order of class definition with respect to use is critical |
This may just be a reflection of my own cluelessness, but it seems to me
that Perl is indifferent to the order in which things are processed.
Perhaps that's too broad an assertion, but I've never tripped across a
contradiction until attempting to familiarize myself with inside-out
classes and Class::Std.
I took an existing script and added a class at the end of the file, with
the call to Class::Std->new in the (higher up) body. "use class" is not
required in this context. The expected operation of :ATTR( :name<foo )
wasw not happening, although the relevant code in Class::Std was being
exeuted.
Moving the class definition above the use in the file resolved the problem.
To see this, take the file t/perlattrs.t from the distribution (which
passes, of course) and move the statements for package main to the top
of the file. It now fails.
I assume that this is a Perlish thing. However a warning (<strong>!) in
the POD would be appreciated.