Re: { = } autocomposition

2005-04-20 Thread Ingo Blechschmidt
Hi, Autrijus Tang wrote: %ret = map { $_ = uc $_ }, split , $text; [...] I suppose my test is wrong. When I clicked on reply a moment ago, I wanted to propose to change the hash/code disambiguation rule, so that {...} is always parsed as Code if the body contains $_ or $^ But as this

Re: { = } autocomposition

2005-04-20 Thread Larry Wall
On Wed, Apr 20, 2005 at 05:08:53PM +0200, Ingo Blechschmidt wrote: : Hi, : : Autrijus Tang wrote: : %ret = map { $_ = uc $_ }, split , $text; : [...] : : I suppose my test is wrong. : : When I clicked on reply a moment ago, I wanted to propose to change the : hash/code disambiguation rule,

Re: { = } autocomposition

2005-04-20 Thread Autrijus Tang
On Wed, Apr 20, 2005 at 08:51:24AM -0700, Larry Wall wrote: That may look like an arbitrary amount of lookahead, but I tried to define the hash/closure rule in terms of a semantic analysis rule rather than a syntax rule, such that it's always parsed as a closure, but at some point in semantic

Re: { = } autocomposition

2005-04-20 Thread Larry Wall
On Thu, Apr 21, 2005 at 12:09:18AM +0800, Autrijus Tang wrote: : Adding a special form Parens that takes one Exp and simply returns : it is possible, but unless it serves to disambiguate other cases, : that approach seems more heavy-handed to me. As someone who is currently trying to write a

Re: { = } autocomposition

2005-04-20 Thread Autrijus Tang
On Wed, Apr 20, 2005 at 09:38:28AM -0700, Larry Wall wrote: As someone who is currently trying to write a perfect p5-to-p5 [sic] translator, you have to somehow remember the parens (and whitespace (and comments (and constant-folded subtrees))) to have a complete AST representation of the

Re: { = } autocomposition

2005-04-20 Thread Larry Wall
On Thu, Apr 21, 2005 at 12:50:56AM +0800, Autrijus Tang wrote: : I see. Do you think preserving the /span/ (i.e. the character offset ranges) : of each AST element is enough to do that? That effectively means each : node points to a substring inside the original source string. Yes, though

Re: { = } autocomposition

2005-04-20 Thread Larry Wall
On Wed, Apr 20, 2005 at 10:21:32AM -0700, Larry Wall wrote: : Except that you've probably thrown away the definition of appropriate : by then as well. :-) Well, maybe not, since you presumably need to keep track of the current parser for eval. Larry

Re: { = } autocomposition

2005-04-20 Thread Autrijus Tang
On Wed, Apr 20, 2005 at 10:21:32AM -0700, Larry Wall wrote: On Thu, Apr 21, 2005 at 12:50:56AM +0800, Autrijus Tang wrote: : I see. Do you think preserving the /span/ (i.e. the character offset ranges) : of each AST element is enough to do that? That effectively means each : node points to

Re: { = } autocomposition

2005-04-20 Thread Darren Duncan
At 10:38 PM +0800 4/20/05, Autrijus Tang wrote: In Pugs's t/pugsbugs/map_function_return_values.t, iblech added this test: %ret = map { $_ = uc $_ }, split , $text; This fails because it is parsed, undef the {=} autocomposition rule, into: # Fails because arg1 is not Code %ret =

Re: { = } autocomposition

2005-04-20 Thread Darren Duncan
At 8:43 PM +0200 4/20/05, Juerd wrote: Darren Duncan skribis 2005-04-20 11:40 (-0700): A clear way to disambiguate a block from a hash-ref when using map/grep/sort etc is to use a colon before the leading brace for a block rather than a space, like this: map:{ $_ = uc $_ } I think the best