develooper Front page | perl.perl6.language | Postings from December 2004

Re: Topification [Was: Arglist I/O [Was: Angle quotes and pointybrackets]]

Thread Previous | Thread Next
From:
Matthew Walton
Date:
December 6, 2004 12:09
Subject:
Re: Topification [Was: Arglist I/O [Was: Angle quotes and pointybrackets]]
Message ID:
41B4BC57.70903@alledora.co.uk
Luke Palmer wrote:

> The remaining problem is what to do about unary dot.  Repeated here for
> the, er, benefit? of p6l:
> 
>     class Duple {
>         has $.left;
>         has $.right;
> 
>         method perform (&oper) {
>             &oper($.left);
>             &oper($.right);
>         }
>     }
> 
> Let's change that into a Tuple class:
> 
>     class Tuple {
>         has @.elems;
> 
>         method perform (&oper) {
>             for @.elems {
>                 .perform($_);
>             }
>         }
>     }
> 
> Can you find the mistake?

Well it's not using &oper on the elems anymore.

	method perform (&oper) {
	  for @.elems {
	    &oper($_);
	  }
	}

But I don't think that was the mistake you were talking about. And I 
don't see what it has to do with unary dot either, because you don't 
need to use unary dot to implement that method. Unless each member of 
@.elems is a Duple, in which case the class isn't one I'd call Tuple.

Sorry, nitpicking level seems to be set to 9 at the moment. What did you 
mean?

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About