Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Method/attribute chaining
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  4 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Alex Gutteridge  
View profile  
 More options May 24 2005, 7:46 am
Newsgroups: perl.perl6.compiler
From: al...@ebi.ac.uk (Alex Gutteridge)
Date: Tue, 24 May 2005 12:46:56 +0100
Local: Tues, May 24 2005 7:46 am
Subject: Method/attribute chaining
Hi,

Just playing around with pugs 6.2.5 OO and couldn't work this out:

class Bowl {
         has $.fish  is rw;
         has $.water is rw;

}

class Fish {
         has $.bowl    is rw;
         has $.eyes    is rw;

}

my $bowl   = Bowl.new;
my $blinky = Fish.new;

$bowl.water  = 'Murky';
$blinky.eyes = 3;

$bowl.fish   = $blinky;
$blinky.bowl = $bowl;

$bowl.water.say;
$blinky.eyes.say;

my $blinkys_bowl = $blinky.bowl;
$blinkys_bowl.water.say;

my $fishy = $bowl.fish;
$fishy.eyes.say;

$bowl.fish.eyes.say;
$blinky.bowl.water.say;

The output I get:

Murky
3
Murky
3
*** No compatible subroutine found: "&eyes"
     at Desktop/testOO.pl line 27, column 1-20

Am I missing something in the syntax when I try to chain the  
attribute methods? Or is this not implemented in pugs yet?

Thanks for any help.

Alex Gutteridge

EBI
Wellcome Trust Genome Campus
Hinxton
Cambs CB10 1SD
UK

Tel: 01223 492546
Email: al...@ebi.ac.uk


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Adrian Taylor  
View profile  
 More options May 24 2005, 7:52 am
Newsgroups: perl.perl6.compiler
From: a...@hohum.me.uk (Adrian Taylor)
Date: Tue, 24 May 2005 12:52:49 +0100
Local: Tues, May 24 2005 7:52 am
Subject: Re: Method/attribute chaining
Hi,

I have seen similar weirdness and added a couple of tests over the
weekend, whilst simultaneously forgetting to mention it on IRC:

class Foo {
  method noargs () { 42 }
  method callsmethod2 { .noargs(); }

}

 $val = $foo.callsmethod2()

dies. (t/oo/method/instance.t)

It appears to be something to do with whether the methods are declared
with brackets (method callsmethod2 versus method callsmethod2()).

Maybe this is related.

Cheers

Ade


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Alex Gutteridge  
View profile  
 More options May 24 2005, 8:53 am
Newsgroups: perl.perl6.compiler
From: al...@ebi.ac.uk (Alex Gutteridge)
Date: Tue, 24 May 2005 13:53:42 +0100
Local: Tues, May 24 2005 8:53 am
Subject: Re: Method/attribute chaining
Hi,

I've written up the case I found as a test, please feel free to add  
it if it's useful. All tests pass apart from the last one which tests  
attribute chaining. Tested on Pugs 6.2.5.

#!/usr/bin/pugs

use v6;
use Test;

plan 7;

#Setup
class Foo {
     has $.bar is rw;

}

my $foo  = Foo.new;
my $foo2 = Foo.new;

#Sanity check
isa_ok($foo,  'Foo');
isa_ok($foo2, 'Foo');

#Setup chain
$foo.bar  = $foo2;
$foo2.bar = 'baz';

#Sanity check part two
is($foo2.bar, 'baz', '... got the right value in $foo2');
is($foo.bar =:= $foo2, 1, '... $foo is storing $foo2');

#Extract last part of chain
my $foo3 = $foo.bar;

#and check its fine
is($foo3 =:= $foo2, 1, '... we can retrieve $foo2 as $foo3');
is($foo3.bar, 'baz', '... got the right value in $foo3');

#Check chaining
lives_ok{
     $foo.bar.bar == 'baz' ;

}, '... attribute chaining is OK';

On 24 May 2005, at 12:52, Adrian Taylor wrote:

Alex Gutteridge

EBI
Wellcome Trust Genome Campus
Hinxton
Cambs CB10 1SD
UK

Tel: 01223 492546
Email: al...@ebi.ac.uk


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Autrijus Tang  
View profile  
 More options Jun 1 2005, 3:05 am
Newsgroups: perl.perl6.compiler
From: autri...@autrijus.org (Autrijus Tang)
Date: Wed, 1 Jun 2005 15:05:55 +0800
Local: Wed, Jun 1 2005 3:05 am
Subject: Re: Method/attribute chaining

On Tue, May 24, 2005 at 01:53:42PM +0100, Alex Gutteridge wrote:
> I've written up the case I found as a test, please feel free to add  
> it if it's useful. All tests pass apart from the last one which tests  
> attribute chaining. Tested on Pugs 6.2.5.

Thanks, stevan applied it and I believe it now works correclty.

/Autrijus/

  application_pgp-signature_part
< 1K Download

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »