[#5218] Ruby Book Eng tl, ch1 question — Jon Babcock <jon@...>
From: Jon Babcock <jon@kanji.com>
Thanks.
From: Jon Babcock <jon@kanji.com>
Ah, thanks, I think I get it, a slightly different nuance then.
From: Jon Babcock <jon@kanji.com>
'Because all of Ruby has been...' -> 'Because Ruby has been...'?
[#5221] better way to say 'recursive join' — Yasushi Shoji <yashi@...>
in [ruby-dev:6289], Shugo Maeda suggested better name for recursive
[#5240] Ruby for Win32/DOS — Dennis Newbold <dennisn@...>
Not all of us are blessed with the opportunity to be able to develop on
[#5254] problem: undefined method `size' for File — "葡ic Santonacci" <Eric.Santonacci@...>
Hi all,
HI,
[#5264] Re: problem: undefined method `size' for Fil e — Aleksi Niemel<aleksi.niemela@...>
matz critizes good solution argumenting with features lacking from some
[#5268] Proper ConditionVariable usage? — Aleksi Niemel<aleksi.niemela@...>
Abstract
On Wed, 04 Oct 2000 07:05:22 +0900, Aleksi Niemelwrote:
In message <20001004110040.A26666@xs4all.nl>
Hi,
[#5276] Re: Ruby Book Eng tl, ch1 question — schneik@...
[#5310] Errata for Ruby Book? — Jon Babcock <jon@...>
[#5318] Redefining super method as singleton? — Robert Feldt <feldt@...>
On Fri, 6 Oct 2000, Yukihiro Matsumoto wrote:
[#5329] Ruby vs PHP ? — "Valerio Bamberga" <bamberga@...>
Hi!
[#5331] Unit testing network code? — Hugh Sasse Staff Elec Eng <hgs@...>
Can someone give me pointers on how to Unit Test code that is run on
> I think maybe one would test each end on its own first, faking the
[#5335] string streams in Ruby? — Hugh Sasse Staff Elec Eng <hgs@...>
Is there any way, without going through "modifying the internals",
[#5346] Is Ruby "enough better"? — Gabriel Lima <Gabriel.Lima@...>
Hi.
[#5364] Allowing *ary's in the middle of a camma separated list — "Akinori MUSHA" <knu@...>
Hi,
Hi,
At Tue, 10 Oct 2000 14:17:24 +0900,
[#5404] Object.foo, setters and so on — "Hal E. Fulton" <hal9000@...>
OK, here is what I think I know.
At Wed, 11 Oct 2000 11:37:25 +0900,
Hi,
Hi,
Hi,
Hi,
[#5425] Ruby Book Eng. tl, 9.8.11 -- seishitsu ? — Jon Babcock <jon@...>
At Thu, 12 Oct 2000 03:49:46 +0900,
Thanks for the input.
At Thu, 12 Oct 2000 04:53:41 +0900,
At Thu, 12 Oct 2000 07:25:03 +0900,
oops, I didn't read this one before I went out for food..
At Thu, 12 Oct 2000 09:59:19 +0900,
[#5437] Editor recommandations? — "Chris Morris" <chrismo@...>
Any recommendations on editors for Ruby script on Windows?
[#5471] 2 ideas from Haskell — Mark Slagell <ms@...>
Do either of these interest anyone:
[#5479] Some newbye question — Davide Marchignoli <marchign@...>
I am reading the documentation I found about ruby but several points
[#5480] InstallShield version for Ruby soon... — andy@... (Andrew Hunt)
Okay folks,
[#5489] Regexp#matches — Aleksi Niemel<aleksi.niemela@...>
Would someone object aliasing matches for match in Regexp?
[#5505] Sorry, What is Ruby Book — Mansuriatus Shahrir Amir <chioque@...>
Sorry if this information is somewhere obvious. I just stumbled upon
[#5516] Re: Some newbye question — ts <decoux@...>
>>>>> "D" == Davide Marchignoli <marchign@di.unipi.it> writes:
Hi,
On Sat, 14 Oct 2000, Yukihiro Matsumoto wrote:
matz@zetabits.com (Yukihiro Matsumoto) writes:
Dave Thomas <Dave@thomases.com> wrote:
Hi,
> Proposal a and b have incompatibility. I'm not sure it's worth it.
>>>>> "Y" == Yukihiro Matsumoto <matz@zetabits.com> writes:
On Mon, 16 Oct 2000, ts wrote:
>>>>> "Y" == Yukihiro Matsumoto <matz@zetabits.com> writes:
[#5558] GC: malloc_memories — Mathieu Bouchard <matju@...>
Hi,
> |precipitate a new GC cycle if lots of resizing is done. My biggest
[#5570] Notes about GC — Mathieu Bouchard <matju@...>
[#5600] passing single or multiple strings. — Hugh Sasse Staff Elec Eng <hgs@...>
With multple assignments I can get nested arrays "shelled" (like peas)
In message "[ruby-talk:5600] passing single or multiple strings."
[#5603] debug command list in English — "Morris, Chris" <ChrisM@...>
I found this page which lists the interactive debugger commands ... anyone
[#5619] lint? — "Swit" <swit@...>
Is there something like lint for Ruby? I'd like to find NameErrors before
[#5705] Dynamic languages, SWOT ? — Hugh Sasse Staff Elec Eng <hgs@...>
There has been discussion on this list/group from time to time about
Hugh Sasse Staff Elec Eng wrote:
On Sat, 21 Oct 2000, Charles Hixson wrote:
[#5715] Help: sockets broken — jason petrone <jp@...>
I just compiled ruby 1.6.1 on an openbsd 2.6 machine(x86).
[#5716] Re: Array#insert — Aleksi Niemel<aleksi.niemela@...>
> From: jweirich@one.net [mailto:jweirich@one.net]
[#5727] String#slice surprise — "Guy N. Hurst" <gnhurst@...>
Hi,
Dave Thomas wrote:
[#5787] Shells and Ruby — "Dat Nguyen" <thucdat@...>
Hello all,
[#5850] Re: Array#insert rehashed — Aleksi Niemel<aleksi.niemela@...>
Dave asks for:
[#5862] succ but no pred? (& the MURKY award) — "Hal E. Fulton" <hal9000@...>
First of all, a serious question:
[#5873] Integer(String) weirdness for a ruby newbie — Stoned Elipot <Stoned.Elipot@...>
Hi,
[#5881] Q:what about "Programming Ruby"? — Gabriel Lima <Gabriel.Lima@...>
Hi to you all.
[#5882] [RFC] Towards a new synchronisation primitive — hipster <hipster@...4all.nl>
Hello fellow rubyists,
On Fri, 27 Oct 2000, hipster wrote:
[#5947] Hash.new {block} / Hash#default_proc{,_set} — "Brian F. Feldman" <green@...>
I've done very little testing, but I think I've successfully implemented the
[ruby-talk:5789] Re: local variables (nested, in-block, parameters, etc.)
Yukihiro Matsumoto wrote:
> ...
> In summary, possible problems (and ugliness) are
>
> (1) a block parameter variable names appeared BEFORE the lambda.
> Since parameters in most languages are scope local, some (or
> even most) expect them local to the block, even if they already
> appear in the enclosing scope.
>
> (2) a local variable names appeared IN the block.
> When you are trying to use a variable local to the block, you
> have to assure the name of a variable is not used outside of the
> block. You have to know all local variable names. Although
> it's good to know all local variable names in the method, a
> programmer should be allowed to be lazy enough to avoid
> searching variable names.
>
> (3) a local variable names appeared AFTER the lambda.
> Since it's easy to forget about block scope rules, some (or even
> most) expect the values of block local variables preserved after
> the block. When he meets the `undefined local variable' error,
> he should go back before the block and initialize the variable.
>
> I admit all violates the principles of least surprise. Hmm.
>
I thought very long about this issue (partly for the challenge), and although
I am probably missing certain aspects of this whole issue, I figured I'd give
it a showing anyway.
Currently, I think Ruby will bind a parameter to a local var automatically -
but only if it exists. Otherwise it makes an in-block var, which is not
available beyond the { } scope.
But what are the cases for potentially desired uses of local and
in-block parameters?
I think they are:
If a local var exists before a lambda,
- it should be available to the lambda
- it should be bindable to a parameter
If you are making a lambda
a - you should have the option to bind parameter to a local var
+ makes in-block var same as local var; no name conflicts
b - you should have access to local vars you know about
c - if you don't bind a parameter to a local var, you shouldn't
have to worry about conflicts of that in-block var with the local var
+ [name conflict] either disallow using the local var you chose to not bind to
+ or, use special accessor syntax to differentiate the two
d - you should be able to make in-block vars that are limited to inside the block
+ to make it limited to the block, it can't be bound to a local var
+ you shouldn't have to worry about conflicts with local vars you use inside the block
e - you should be able to make vars inside the block that are accessible outside it
+ to make it accessible outside the block, it should have to be a local var
+ you shouldn't have to worry about conflicts with other local vars
f - you shouldn't have to know about all local vars to avoid conflicts
It seems to me that there are some conflicts that have nothing to do with implementation.
That is, mixing in-block-only vars with accessible local vars having the same name.(c/d)
Or, creating a local var inside the block that will conflict with pre-existing local vars (e)
The c/d conflict is not really a conflict, once you think about it. If you wish to use
an in-block variable called 'x', and also a local variable called 'x', you would know
about it. In that case, you name your in-block variable something else. But if you do not
know about the local var 'x', then chances are you aren't planning on using it, either.
In that case, you can make in-block 'x' such that it overshadows the local var - meaning
that you can no longer access the local var called 'x'.
This is in line with the {|x~| .... } construct.
Situation e, on the other hand, is a true overlap. There simply has to be some other way
than making it a local var - otherwise you will have to keep track of all local vars!
Someone mentioned making the interpreter give a warning when you have conflicting names.
That is a good start.
But I think a solution would be to create some separate way to access in-block vars outside
of the block (an apparent contradiction).
One way to do this would be to create a new scope access operator, or maybe adjust the
existing one... something like {}::x to access in-block variable 'x' outside of the block.
For this to work without confusion, it would have to be limited to the most recent block.
x=9;
[1,2,3].each{|x~| break if x==2}
p x #-> 9
p {}::x #-> 2
Alternatively, I suppose the same tilde thing could be used for that, too.
x=9;
[1,2,3].each{|x~| break if x==2}
p x #-> 9
p x~ #-> 2
Ruby will automatically bind a parameter to a local var, but only if it exists.
If I know it exists or not, fine - I know what to expect.
But if I do not know whether a local var exists, I use |x~|, and either use it
only in the block, or else access it outside the block as x~, without worrying
about it conflicting with local var 'x'.
Now, about the nesting problem... the solution depends on what the desired behaviour
should be, and I have not thought long enough about that... ;-)
Guy N. Hurst
P.S. If the tilde is too ugly, then using the <a,b> combined with |x,y| and {}::x
is fine with me.
{|x,y|<a,b> a=x; ....} # <a,b> in-block only
p {}::a # but still accessible outside ;-)
p x # local vars as before
etc..
vs.
{|x~,y,b~| .... } # x,b in-block only
p x~ # in-block x still available as x~
p x # local vars as before...
I don't think the tilde is so bad, considering its capability...
--
HurstLinks Web Development http://www.hurstlinks.com/
Norfolk, VA - (757)623-9688
PHP/MySQL - Ruby/Perl - HTML/Javascript