Thilosophy has asked for the wisdom of the Perl Monks concerning the following question:
as announced (Parrot Monks?) some time back here is the first of what could become a series of Parrot questions, depending on the feedback it generates in the Monastry. The idea is both to help myself get a grip on some basic Parrot concepts, and to, as Ovid put it, "expose more monks to the future".
Is there already a class loader in parrot, that keeps track of what files are loaded? In other words, can I use use in Parrot?
I am now using the load_bytecode opcode, but of course, if I accidently load the same file/class/module twice, its initialization code (supposed to be run only once) is run twice, resulting in an error and program crash.
MyClass.imc file.sub _main @MAIN print "starting\n" # load_bytecode is actually clever enough to load # the (uncompiled) imc file as well (cool) load_bytecode "MyClass.imc" # but loading it twice is bad load_bytecode "MyClass.imc" print "finished\n" .end
Output:.namespace ['MyClass'] .sub _initialize prototyped, @LOAD .local pmc tmpl_class print "registering class\n" newclass tmpl_class, 'MyClass' .end
starting registering class registering class Class MyClass already registered!I am using the 0.1.1 release of Parrot.
Thanks for your time.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: [Parrot] Is there a class loader?
by rg0now (Chaplain) on Feb 17, 2005 at 12:09 UTC | |
by gaal (Parson) on Feb 17, 2005 at 13:25 UTC | |
by rg0now (Chaplain) on Feb 17, 2005 at 14:09 UTC | |
by gaal (Parson) on Feb 17, 2005 at 14:25 UTC | |
by Thilosophy (Curate) on Feb 18, 2005 at 00:33 UTC |