Re: If topicalization

2005-08-04 Thread Stuart Cook
On 8/4/05, Luke Palmer [EMAIL PROTECTED] wrote:
 How can that possibly work?  If a bare closure { } is equivalent to -
 ?$_ is rw { }, then the normal:
 
 if foo() {...}
 
 Turns into:
 
 if foo() - ?$_ is rw { }
 
 And every if topicalizes! I'm sure we don't want that.
 
 Luke


Here's one solution:

1) Bare blocks don't topicalise if you call them without an argument.

2) 'if' doesn't pass the value of the condition to its body, _UNLESS_
the body is incapable of accepting 0 arguments.


This means:

* The most common case, if foo() { ... }, won't topicalise.

* If you /really/ want to access the value of the conditional, you can
say one of:
if foo() - $_ { ... }# topicalise
if foo() - $cond { ... } # don't topicalise
and 'if' will give it to you.

* The bare-block-to-pointy-sub rewrite rule is preserved, because a
bare block's parameter is optional.

Is there anything I've failed to take into account?


Stuart


Re: [S5] Topicalization of match

2004-09-30 Thread Juerd
Michele Dondi skribis 2004-09-30 10:30 (+0200):
 PS: this is something that I'd like in the substitution part of a s///e 
 operator in Perl5 too: do you know actual code in which $_ was really used 
 there?

s/\Q$_/$foo{$_}/g for keys %foo;


Juerd


Re: [S5] Topicalization of match

2004-09-30 Thread Michele Dondi
On Thu, 30 Sep 2004, Juerd wrote:
operator in Perl5 too: do you know actual code in which $_ was really used
there?
   s/\Q$_/$foo{$_}/g for keys %foo;
D'Oh!
Michele
--
I have never seen it work, either, since I have never used Word.  The
stories users of it tell me are sufficient for keeping me glad I never
did.
- David Kastrup on comp.text.tex