Re: Magic for object constructor wanted



On Jan 31, 3:18 pm, bugbear <bugbear@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote:
Koszalek Opalek wrote:

my @people = (
     Dude->new("joe"),
     Dude->new("tom"),
     Dude->new("ann").
     Dude->new("jane")
);

Alternatively/additioanaly, you might have a "group"
class (set of Dudes) that allow Dudes t be found by name.

No, then instead of saying
$ann->fill( friends => [ $tom, $tim] );
I'd have to say smth like
$ann->fill( friends => Friends->findByName("tom", "tim") );


If your set of names becomes large, declaring all the
variables implied by your original approach becomes ugly.

It will never get very large.

You might be thinking Dudes are some jerks from a database.
In fact they are tokens. The module user has two define
Dudes (tokens) and relationships between them and the
module will produce a parse tree. (Specifying Dudes
using a BNF grammar is not scheduled for this release:-)

Koszalek
.