develooper Front page | perl.perl6.language | Postings from May 2005

Re: How do I... create a new meta operator?

Thread Previous | Thread Next
From:
Luke Palmer
Date:
May 19, 2005 19:41
Subject:
Re: How do I... create a new meta operator?
Message ID:
7ca3f016050519194040a43d78@mail.gmail.com
On 5/19/05, Ingo Blechschmidt <iblech@web.de> wrote:
> Hi,
> 
> quoting A12:
> > infix_postfix_meta_operator:<=>             $x += 2;
> > postfix_prefix_meta_operator:{'»'}         @array »++
> > prefix_postfix_meta_operator:{'«'}         -« @magnitudes
> > infix_circumfix_meta_operator:{'»','«'}   @a »+« @b
> 
> so will the following work?
> 
>   # Silly example
>   sub infix_circumfix_meta_operator:{'->', '<-'} (
>     Code &op,
>     $left, $right,
>   ) {
>     op $left + 1, $right + 1;
>   }
> 
>   say 2 ->+<- 3;  # 7
>   say 2 ->*<- 3;  # 12

That looks approximately right.  I wonder how we specify meta
operators that only work on comparators, or only on assignment forms,
or etc. etc. etc.

Luke

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