Re: Default values for instance variables

2005-11-08 Thread Luke Palmer
On 11/8/05, Gaal Yahas [EMAIL PROTECTED] wrote:
 Wouldn't it be nice to be able to supply default values for instance
 variables right in the attribute declaration?

  class Jabberwock {
  has $.jaws  = bite;
  has $.claws = catch;
  }

  my $scary = Jabberwock.new;
  my $wimpy = Jabberwock.new(jaws = chew, claws = tenderly comb);

That is legal Perl 6.  The fact that it is not legal pugs is pugs's problem. :-)

Luke


Re: Default values for instance variables

2005-11-08 Thread Gaal Yahas
On Tue, Nov 08, 2005 at 07:07:42PM +, Luke Palmer wrote:
   class Jabberwock {
   has $.jaws  = bite;
   has $.claws = catch;
   }
 
 That is legal Perl 6.  The fact that it is not legal pugs is pugs's problem. 
 :-)

Noted. Perhaps it'd be worth foregrounding this feature in the Synopsis? I
was just about to add tests -- but I found they already existed, with
a comment

# These tests are not specified by p6l, But these should be right...

-- 
Gaal Yahas [EMAIL PROTECTED]
http://gaal.livejournal.com/


Re: Default values for instance variables

2005-11-08 Thread Luke Palmer
On 11/8/05, Gaal Yahas [EMAIL PROTECTED] wrote:
 On Tue, Nov 08, 2005 at 07:07:42PM +, Luke Palmer wrote:
class Jabberwock {
has $.jaws  = bite;
has $.claws = catch;
}
 
  That is legal Perl 6.  The fact that it is not legal pugs is pugs's 
  problem. :-)

 Noted. Perhaps it'd be worth foregrounding this feature in the Synopsis?

It is now vaguely hinted at the first mention of attributes in S12.

Luke