[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

ruby-dev summary 25741-25780

Minero Aoki

3/6/2005 6:24:00 AM

39 Answers

djberg96

3/6/2005 9:27:00 AM

0

Minero Aoki wrote:

> [ruby-dev:25780] Proc generation without `proc'
>
> Nobuyoshi Nakada posted a patch to allow generating Proc object
> without `proc' or `lambda' shortly. e.g.
>
> x = {|a| p a } # == proc {|a| p a }
> x.call
>
> x = (do |a| p a end) # == proc do |a| p a end
> x.call
>
> This experimental patch was incorporated in to CVS HEAD.

This feels like we're getting too clever for our own good. The second
form looks like some bastardized form of Lisp. Folks, we're not in a
contest to see how terse we can make Ruby.

I vote NAY.

Dan

dblack

3/6/2005 11:15:00 AM

0

Yukihiro Matsumoto

3/6/2005 11:30:00 AM

0

Hi,

In message "Re: ruby-dev summary 25741-25780"
on Sun, 6 Mar 2005 20:15:03 +0900, "David A. Black" <dblack@wobblini.net> writes:

|Wouldn't this require empty || for blocks that don't take arguments?
|For example:
|
| x = {|| puts "hello" }

Yes.

matz.


Christian Neukirchen

3/6/2005 11:56:00 AM

0

Minero Aoki <aamine@loveruby.net> writes:

> [ruby-dev:25780] Proc generation without `proc'
>
> Nobuyoshi Nakada posted a patch to allow generating Proc object
> without `proc' or `lambda' shortly. e.g.
>
> x = {|a| p a } # == proc {|a| p a }
> x.call
>
> x = (do |a| p a end) # == proc do |a| p a end
> x.call
>
> This experimental patch was incorporated in to CVS HEAD.

Does this mean that foo { |a| ... }, { |b| ... } will work?

> -- Minero Aoki
--
Christian Neukirchen <chneukirchen@gmail.com> http://chneuk...


dblack

3/6/2005 12:00:00 PM

0

Yukihiro Matsumoto

3/6/2005 1:46:00 PM

0

Hi,

In message "Re: ruby-dev summary 25741-25780"
on Sun, 6 Mar 2005 20:56:08 +0900, Christian Neukirchen <chneukirchen@gmail.com> writes:

|Does this mean that foo { |a| ... }, { |b| ... } will work?

No. foo {|a| ...} itself works as a method invocation with a block,
so that above code will be a syntax error. But

foo({ |a| ... }, { |b| ... })

will do.


matz.


Yukihiro Matsumoto

3/6/2005 1:48:00 PM

0

Hi,

In message "Re: ruby-dev summary 25741-25780"
on Sun, 6 Mar 2005 20:59:34 +0900, "David A. Black" <dblack@wobblini.net> writes:

|Isn't that a little bit awkward-looking? Or am I just being too
|sensitive about new forms of significant punctuation in the language?

Maybe, maybe not. It's very subjective matter.

matz.


Brian Schröder

3/6/2005 1:56:00 PM

0

On Sun, 6 Mar 2005 22:45:55 +0900, Yukihiro Matsumoto
<matz@ruby-lang.org> wrote:
> Hi,
>
> In message "Re: ruby-dev summary 25741-25780"
> on Sun, 6 Mar 2005 20:56:08 +0900, Christian Neukirchen <chneukirchen@gmail.com> writes:
>
> |Does this mean that foo { |a| ... }, { |b| ... } will work?
>
> No. foo {|a| ...} itself works as a method invocation with a block,
> so that above code will be a syntax error. But
>
> foo({ |a| ... }, { |b| ... })
>
> will do.
>
> matz.
>
>

I like that!

regards,

Brian

--
Brian Schröder
http://ruby.brian-sch...



Steven Shaw

3/6/2005 3:04:00 PM

0

David A. Black wrote:

> Wouldn't this require empty || for blocks that don't take arguments?
> For example:
>
> x = {|| puts "hello" }

Wouldn't

x = (do puts "hello" end)

be ok/unambiguous?

Nikolai Weibull

3/6/2005 3:12:00 PM

0

* Yukihiro Matsumoto (Mar 06, 2005 14:50):

> > Isn't that a little bit awkward-looking? Or am I just being too
> > sensitive about new forms of significant punctuation in the
> > language?

> Maybe, maybe not. It's very subjective matter.

Definitely. I'd write it as

x = lambda { ... }

if there weren't any arguments. It'd make it much more clear that it
was a thunk and nothing else.

(If there were arguments I'd consider skipping the proc/lamda:

x = { |a| ... }
),
nikolai

--
::: name: Nikolai Weibull :: aliases: pcp / lone-star / aka :::
::: born: Chicago, IL USA :: loc atm: Gothenburg, Sweden :::
::: page: www.pcppopper.org :: fun atm: gf,lps,ruby,lisp,war3 :::
main(){printf(&linux["\021%six\012\0"],(linux)["have"]+"fun"-97);}