Re: RFC 171 (v1) my Dog $spot should call a constructor implicitly

[email protected] (Nathan Wiger)
Newsgroups perl.perl6.language.objects
Message-ID <[email protected]>
Michael Fowler wrote:
> 
> Regarding the STORE call, if RFC 159 gets adopted, sure, why not.  I'll
> mention that alternative in the RFC's next version.

Cool.
 
> I need to mention the:
> 
>     my int $x;
>     my int $i = 4;
>     my int ($x, $y, $z) = (4, 5, 6);
> 
> syntax in the RFC.  It describes more of the intent behind the change.

Great, yeah this is where it's really powerful.
 
> Sure, the my Dog $spot (@args) looks neat, but it's not any less complex
> than a normal constructor call; if anything, it's moreso. There's no current
> precedent in Perl for such syntax, and I'm loathe to add it without more
> reason.

Yeah, I wrote that on a lot of beer. ;-) The more I think about it, if
we went that route it should look like this:

    my Dog (@args) $spot = "Spot";   # $spot = Dog->CREATE(@args);
                                     # $spot->STORE("Spot");

That is, the args follow the class name. Then it's really just a
left-side indirect object syntax:

   my $q = new CGI (@args);
   my CGI (@args) $q;

   my($x, $y, $z) = new int (@args);
   my int (@args) ($x, $y, $z);

Then I think there is a decent precedent for it. It's an option, at
least. Parsing would be tricky though, at least in the second case.

-Nate
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.