Juerd writes: > Austin Hastings skribis 2004-04-23 13:33 (-0400): > > I should then be able to call class methods of Dog via $spot without further > > initialization: > > print defined($spot); # FALSE > > $rover = $spot.new; > > @breeds = $spot.list_breeds; > > But shouldn't you then just use "my Class $spot = Dog" then? Or maybe > just "my $spot := Dog"?
Well, maybe, but what if you're being passed it in via a sub? And what if you don't know the type. Eg. sub foo ($x is copy) { $x //= $x.new; } That would clearly die if you said: foo(undef); But what if that undef was cascaded from somewhere else? It allows you to have an *undefined* object floating around that knows what it *should* be. To be clear, I don't know exactly what benefit that has just yet, but it seems like one of those things that has potential. On the other hand, A12 said that $x.new when $x is undef should in turn be undef. That also seems like something potentially useful. > > This is, as pointed out, just sugar for Dog::new and Dog::list_breeds, but > > it brings up the spectre of undef invocants: > > :: or .? I'm confused. Dog::new is the name of the method; Dog.new is how you call it. So the answer is yes. > > $c->foo->bar->baz; # If foo or bar fails, what happens? > > -> or .? Even more confused now. You'll have to give Austin some rope in the syntax area. His brain occasionally stops working (hmm, I know that feeling %-), but you can usually figure out what he means. :-p Luke