in reply to No (ambiguous) Indirect Object Notation in Perl 6
in thread Tim O'Reilly on Perl

Any word on why it isn't a keyword? I mean in perl6 you no longer define your own new. So is there a reason new isn't a key word that triggers the contructor? Like I said before, I wouldn't use inderict object notation anywhere else, but in the case of new it hardly feels like a method, and you are acting on a class not an object. I wonder if not making new a keyword is some attempt at leaving the language dynamic.

Update: Thanks for clarification on all points to both chromatic and TimToady

___________
Eric Hodges
  • Comment on Re: No (ambiguous) Indirect Object Notation in Perl 6

Replies are listed 'Best First'.
Re^2: No (ambiguous) Indirect Object Notation in Perl 6
by TimToady (Parson) on Jul 18, 2005 at 18:00 UTC
    It's not really quite accurate to say that you no longer define your own new. It's merely the case that you get a default new for free. However, that default constructor only handles named parameters. If you want a constructor that uses positional parameters, you have to define your own, and there's no reason you can't call it call it new if you like, presuming it's something that multimethod dispatch can sort out from the default Object.new().

    By the way, I disagree slightly with chromatic on this point. I think new Foo without colon is just fine, since we've gone to some pains to make sure that 1) it works as MMD and that 2) neither the method name nor the class name are taken as barewords. You could just as easily write new(Foo) and it will still work via MMD. But there's nothing wrong with the colon, and different people value different kinds of consistency.

Re^2: No (ambiguous) Indirect Object Notation in Perl 6
by chromatic (Archbishop) on Jul 18, 2005 at 17:55 UTC

    It's a class method you can override if you must. You probably ought to override BUILD() or BUILDALL() instead, but it's there if you need it.