Re: S04-related closure question

2008-09-22 Thread Patrick R. Michaud
On Sat, Jul 12, 2008 at 09:52:34PM -0500, Patrick R. Michaud wrote: > What would be the expected output from the following? > > my $a = foo(); > my $b; > > { > my $x = 1; > sub get_x() { return $x; } > sub foo() { return &get_x; } > $b = foo(); >

Re: Subroutine parameter with trait and default.

2008-09-22 Thread Michael G Schwern
Patrick R. Michaud wrote: > On Sun, Sep 21, 2008 at 07:02:37PM -0700, Michael G Schwern wrote: >> I'm pondering what the proper syntax is for a subroutine parameter with both >> a >> trait and a default. That is... >> sub foo ($arg = 42) >> and >> sub foo ($arg is readonly) >> together

Re: Subroutine parameter with trait and default.

2008-09-22 Thread TSa
HaloO, Patrick R. Michaud wrote: The STD.pm grammar [1] shows that the second is the correct form -- i.e., default values occur after traits. IIRC, there used to be an 'is default(42)' trait that could be placed arbitrarily. PS Incidentally, it seems silly to have "is rw" but not "is ro".

Re: Subroutine parameter with trait and default.

2008-09-22 Thread Patrick R. Michaud
On Sun, Sep 21, 2008 at 07:02:37PM -0700, Michael G Schwern wrote: > I'm pondering what the proper syntax is for a subroutine parameter with both a > trait and a default. That is... > sub foo ($arg = 42) > and > sub foo ($arg is readonly) > together in one parameter. Would that be >