develooper Front page | perl.perl6.language | Postings from November 2003

Re: Control flow variables

Thread Previous | Thread Next
From:
Larry Wall
Date:
November 19, 2003 11:02
Subject:
Re: Control flow variables
Message ID:
20031119190325.GB17924@wall.org
On Wed, Nov 19, 2003 at 09:30:15AM -0700, Luke Palmer wrote:
: Piers Cawley writes:
: > All of which means you can wrap it up in a macro and prove Simon's
: > point about what's syntax and what's CP6AN:
: > 
: >    macro unless_all( Block &test is parsed /<perl.expression>/,
: >                      Block &consequence, *@ary ) 
: >      { my $guard = Object.new;
: >        for *@ary, $guard 
: >          -> { when $guard { &consequence() ; last }
: >               when &test { last } } }
: > 
: > But I've probably got the signature slightly wrong. 

So far we've only allowed "is parsed" on the macro itself, not on
individual arguments.  Still, that's an interesting idea.

: I think the only thing that's wrong with your signature is that you said
: "macro" instead of "sub".  Well, and &test has to be finessed into an
: executable block somehow, but we're not supposed to know how yet.

Hmm, how about statement:unless_all and modifier:unless_all?

: > Higher Order Functions/Methods/Macros are great aren't they? 
: 
: What a modern thinker!  Use a *function* to do a common task?  *What*
: are you talking about!?  :-)

Well, you mayn't put "is parsed" on a function.  Macros have special
rules to enforce lexical scoping of syntax munging, since the syntax
must be known when the call is parsed.  A function call can be parsed
without such special knowledge.

Larry

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