develooper Front page | perl.perl6.language | Postings from October 2002

Re: labeled if blocks

Thread Previous | Thread Next
From:
Piers Cawley
Date:
October 28, 2002 21:34
Subject:
Re: labeled if blocks
Message ID:
84adkxoln4.fsf@despairon.bofh.org.uk
Larry Wall <larry@wall.org> writes:
> We could make "return" a method as well as a built-in sub.  That gives us
>
>     Loop.return($x)
>     Sub.return($x)
>     Topic.return($x)
>     Thread.return($x)
>     Block.return($x)
>     There.return($x)
>
> or
>
>     return Loop: $x
>     return Sub: $x
>     return Topic: $x
>     return Thread: $x
>     return Block: $x
>     return There: $x
>
> BLOCK_NAME could come in under a rule that says that if the classname lookup
> on an identifier fails, and there's an outer labeled scope of that name,
> it is treated as a reference to that object.  Otherwise it's an error,
> since we don't do barewords anymore.
>
> I suppose a case could be made that the innermost block scope is
> really named MY, not Block.  So it could be MY.return($x).
>
> If the method is named "return" however, we might run into ambiguity with
>
>     return $x;

How about, if 'caller' returns a continuation... 

   class Object;

   method return { MY.caller.return(@_) }

-- 
Piers

   "It is a truth universally acknowledged that a language in
    possession of a rich syntax must be in need of a rewrite."
         -- Jane Austen?

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