[#1491] bug — Mathieu Bouchard <matju@...>
6 messages
2003/09/01
[#1492] non-blocking mode behavior (Re: bug)
— nobu.nokada@...
2003/09/01
Hi,
[#1512] New tests — Dave Thomas <Dave@...>
I was looking through the new test/ruby/* stuff just now, and notices
6 messages
2003/09/05
[#1533] GC disable / enable question — Torsten Rueger <torsten.rueger@...>
Moi,
7 messages
2003/09/17
[#1534] Re: GC disable / enable question
— nobu.nokada@...
2003/09/17
Hi,
[#1541] How to debug ? — Torsten Rueger <torsten.rueger@...>
Moi,
6 messages
2003/09/19
[#1542] Re: How to debug ?
— ts <decoux@...>
2003/09/19
>>>>> "T" == Torsten Rueger <torsten.rueger@hiit.fi> writes:
[#1551] Hashes as keys — "Nathaniel Talbott" <nathaniel@...>
I was just playing around with Hash#hash and discovered that you can't use a
13 messages
2003/09/23
[#1552] Re: Hashes as keys
— Jim Freeze <jim@...>
2003/09/23
On Wednesday, 24 September 2003 at 6:21:33 +0900, Nathaniel Talbott wrote:
[#1556] ostruct.rb patch — "Nathaniel Talbott" <nathaniel@...>
I've been finding OpenStruct to be very useful lately, and then I discovered
9 messages
2003/09/24
[#1557] Re: ostruct.rb patch
— "NAKAMURA, Hiroshi" <nahi@...>
2003/09/24
Hi, Nathaniel,
Re: |rcr|.xv Index Variables ( *_with_index )
From:
why the lucky stiff <ruby-core@...>
Date:
2003-09-02 17:01:00 UTC
List:
ruby-core #1498
daz (dooby@d10.karoo.co.uk) wrote:
>
> loop {.x
> x < 5 or break
> p x
> }
>
daz:
A good, exhaustive trip through this particular debacle. Your citations
were cool.
You know, I think our basic problem concerns metadata. An index is
merely metadata applicable to an iteration cycle. And I don't think
that's the only bit of metadata that could be useful in iteration. The
total number of iterations expected. Even an available reference to the
current block would be great for simpler recursion.
I think you've done a good job presenting your RCR (although it's really
hard to push syntactical changes with the current parser.)
My concerns:
1. If we do want to add more metadata, the syntax becomes cumbersome.
I'm guessing additions would be positional.
loop {.index.last print "Item #{ index } of #{ last }." }
If there is no plan for expansion of the syntax, then it become an
_exception_ to Ruby's syntax rather than an _evolution_ of Ruby's
syntax.
2. The dot notation looks like a method call. Yet, assignment is
being performed. It also gives the illusion that the block's
argument list is an object.
I would love to see a good solution to this problem, though. So I
wonder: is there a way we can provide access to block metadata?
Perhaps through a keyword, which provides an instance of metadata within
a block:
loop {
x = iter.index
x < 5 or break
p x
}
Or maybe a generic metadata scheme which could be used with various Ruby
constructs:
class Test
[dot_net_signature => [String, Int, Int]]
def run_me( a, b )
"#{ a } + #{ b }"
end
end
Test.method( :run_me ).meta['dot_net_signature'] => [String, Int, Int]
# Start our index at 2..
[index => 2]
loop {
x = meta['index']
x < 5 or break
p x
}
Fun ideas, but you have to think about scoping and the various types of
blocks that commonly float around in Ruby.
_why