ASPN ActiveState Programmer Network
ActiveState
/ Home / Perl / PHP / Python / Tcl / XSLT /
/ Safari / My ASPN /
Cookbooks | Documentation | Mailing Lists | Modules | News Feeds | Products | User Groups


Recent Messages
List Archives
About the List
List Leaders
Subscription Options

View Subscriptions
Help

View by Topic
ActiveState
.NET Framework
Open Source
Perl
PHP
Python
Tcl
Web Services
XML & XSLT

View by Category
Database
General
SOAP
System Administration
Tools
User Interfaces
Web Programming
XML Programming


MyASPN >> Mail Archive >> ruby-talk
ruby-talk
Re: Subclassing Struct.new
by Caleb Clausen other posts by this author
Mar 2 2006 11:18AM messages near this date
Re: Subclassing Struct.new | Re: Subclassing Struct.new
On 3/1/06, Yukihiro Matsumoto <matz@[...].org>  wrote:
>  My original intention is _not_ to use local variables before their
>  first assignment, but to extent their scope to by their outer most
>  appearance in the method.

I'm trying to understand the distinction... I think I see. It's
cases where the assignment happens (or might happen?) after
a use at runtime, but also, the use comes before the assignment
in the lexical order.

>  But at the same time, I expect the new rule
>  to solve
> 
>     print foo if foo = bar()

The perfect example. This, I agree ought to work as expected. I'm
not sure I can see an easy way to make it work, but it seems like
there might be a special case... on the other hand, maybe just
a special case isn't good enough. What about this:

until foo && foo.k
  foo=readfoo
end

Sort of silly, there's a better way to do this. But the question is, do
you want foo to be a variable on the first line? And this case:

>  | def baz
>  |   n # will be variable
>  |   n = 3
>  |   n # variable
>  | end

is clearly always use before definition. Should this cause a warning or
something then?

>  I will ponder the new rule (and implementation) bit more.

One thought I had: if there isn't a clever trick for inline if, maybe the
best way is to keep the existing semantics and issue a warning if
there's a method call with a name that subsequently is used for a
local variable in the same scope. That shouldn't be too hard.
Thread:
Minkoo Seo
Chiaro Scuro
Minkoo Seo
Yukihiro Matsumoto
Mark Wilden
Markus Werner
Chiaro Scuro
Minkoo Seo
Minkoo Seo
Hal Fulton
mental
Ross Bamford
mental
Ross Bamford
Chiaro Scuro
Ross Bamford
Chiaro Scuro
Minkoo Seo
Chiaro Scuro
mental
Chiaro Scuro
mental
Yukihiro Matsumoto
Caleb Clausen
Yukihiro Matsumoto
Caleb Clausen
MenTaLguY
Yukihiro Matsumoto
gwtmp01
Chiaro Scuro
mental
Chiaro Scuro
mental
Logan Capaldo
Pit Capitain

Privacy Policy | Email Opt-out | Feedback | Syndication
© ActiveState Software Inc. All rights reserved