[#863] RDtool-0.5.0 — Toshiro Kuwabara <toshirok@...3.so-net.ne.jp>

Hi,

18 messages 1999/10/23
[#864] Re: RDtool-0.5.0 — matz@... (Yukihiro Matsumoto) 1999/10/26

Hi,

[ruby-talk:00890] Re: local / dynamic variables

From: Clemens Hintze <c.hintze@...>
Date: 1999-10-30 07:52:45 UTC
List: ruby-talk #890
GOTO Kentaro writes:
> Hi, 

Hi too,

> 
> In message "[ruby-talk:00879] local / dynamic variables"
>     on 99/10/29, Clemens Hintze <c.hintze@gmx.net> writes:

[...]

> >So, I guess, | | is not a sign for locallity. Only for parameter denoting.
> 
> Great! This explanation is easy to see :-)

thanx :-)))

> 
> However, I feel a small weak point; This explanation cannot be in
> common with the case of a method definition, that is, 
> arg of "def foo(arg)" is shielded from outer scope but |x| doesn't. 
> Of course, it may be a small thing. 

Hmmm... You're right. But there is a small difference, which could
make clear why it is so...

In a method *all* variables (and parameters are also variables in that
sense) are local to the method (if they doesn't begin with '$').

In a block, *only* the variables *created* within the block are
local. Existing ones are shared from the outside.

If I apply these both explanations on parameter as well, it should
bcome clear, why 'def foo(a)' will shield 'a', whereas '|a|' perhaps
wouldn't! So taking my explanation for '||' as parameter denoting +
applying of the rules above should make clear, how Ruby
behaves ... :-)))

What do you mean? Have I overseen something?

> 
> -- gotoken
> 

-- 
Clemens Hintze  mailto: c.hintze@gmx.net

In This Thread

Prev Next