Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Message from discussion placeholder attachment?
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Trey Harris  
View profile  
 More options Apr 19 2004, 6:49 am
Newsgroups: perl.perl6.language
From: t...@sage.org (Trey Harris)
Date: Sun, 18 Apr 2004 12:47:36 -0700 (PDT)
Local: Sun, Apr 18 2004 3:47 pm
Subject: placeholder attachment?
Can anyone explain the rules of placeholder attachment?  i.e., in the
example in Perl6::Placeholder's manpage,

  grep { $data{$^value} } 1..10;

C<$^value> is clearly intended to attach to the outer closure C<{
$data{$^value} }>, not the inner closure C<{$^value}>.  But how does the
compiler know?  What is the general rule?

It's easy to just say "don't nest placeholder-using closures," but that
doesn't seem workable in practice since every block is a closure, unless
placeholders are forbidden from all but the most trivial cases.  Absurdly
trivial, it seems.  How about

  $sub = { if $^a { $^b = $^a } };

?  Are there two C<$^a>'s, one masking the other?  Or just one?  If two,
then the code should fail at runtime for attempted assignment to an
undefined lvalue (because $^b isn't set) or more likely at compile-time
for a missing required parameter.  If there's just one C<$^a>, wouldn't
C<$^b> get set to the topic of the C<if>, i.e. C<$^a> (or is the topic of
an C<if>'s first closure always C<true>?), leading to the expression being
equivalent to

  $sub = ( if $^a { $^a = $^a } };

?  Or will Perl DWIM and attach both $^a and $^b to the outer sub?  If so,
how did it know to do that, and not attach it to whatever sub contains the
assignment to $sub?

I'm probably just confused here, but I'd appreciate some straightening
out, as it's relevant to something I'm working on.  Apo 6 seems to be
silent on this (which perhaps indicates that I'm making this a lot harder
than it is).

Trey


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.