[RFC] 'via' proposal

Hello!

Well, just a thought… Consider that:

1000.times do |a, b, c|
a = …
b = …
c = …
bar a
bar b
bar c
foo
end

Okay, this is a bad design, but let’s say that I can’t change
it. Can a Ruby syntax structure like the one below constructed
in an (almost) easy way?

via bar foo do |a, b, c|
a = …
b = …
c = …
end

i.e. can I construct in pure Ruby or via a C extension a 'via’
method for Object, which will enhance:

foo do { |…| … }

in a way, that all block arguments will be passed in another
method before the end of the block?

If all these do not make sense, just forgive me. It’s night
here. :slight_smile:

Regards,

···


University of Athens I bet the human brain
Physics Department is a kludge --Marvin Minsky

Hello!

Well, just a thought… Consider that:

1000.times do |a, b, c|
a = …
b = …
c = …
bar a
bar b
bar c
foo
end

Okay, this is a bad design, but let’s say that I can’t change
it.

I’m not sure what’s “bad design” about it… there’s not really enough
to tell what you’re actually doing. If you want fewer lines, you can
always:

1000.times { |a, b, c|
a = bar(…)
b = bar(…)
c = bar(…)
foo
}

Fewer lines or more lines isn’t directly related to how good or bad a
design is though.

Can a Ruby syntax structure like the one below constructed
in an (almost) easy way?

via bar foo do |a, b, c|
a = …
b = …
c = …
end

If all these do not make sense, just forgive me. It’s night
here. :slight_smile:

I really can’t tell what you’re trying to do here… please provide
more details about the actual problem at hand: what you’re doing, what
you’re trying to accomplish in the end (not just how you’re trying to
accomplish it). My guess is there’s an easier way.

To answer your question, though, you can always write a function that
takes a block as a parameter. However, you can’t directly manipulate
the code inside; otoh, I’m guessing you don’t really need to.

···

On Sun, 8 Feb 2004 04:37:28 +0900 Elias Athanasopoulos elathan@phys.uoa.gr wrote:


Ryan Pavlik rpav@mephle.com

“As in the case of CLAMZILLA…” - 8BT