p = Proc.new { |*args,&block| }
produces syntax error
p = Proc.new { |*args,&block| }
----------------------^
It appears that Proc objects cannot receive blocks?
p = Proc.new { |*args,&block| }
produces syntax error
p = Proc.new { |*args,&block| }
----------------------^
It appears that Proc objects cannot receive blocks?
Hi,
In message "Re: Receiving blocks in Proc?" on Fri, 5 Nov 2004 06:23:43 +0900, james.cromwell@gmail.com (James) writes:
p = Proc.new { |*args,&block| }
produces syntax error
p = Proc.new { |*args,&block| }
----------------------^It appears that Proc objects cannot receive blocks?
Until 1.9, yes.
matz.
Not in 1.8. 1.9 has it; it's slated for 2.0, I believe...
b = lambda{|*args, &blk| args.each{|arg| blk[arg]}}
==>#<Proc:0x00522420@(irb):1>
b.call(1,2,3) {|n| puts "number #{n}"}
number 1
number 2
number 3
==>[1, 2, 3]
[RUBY_VERSION, RUBY_RELEASE_DATE]
==>["1.9.0", "2004-09-17"]
cheers,
Mark
On Fri, 5 Nov 2004 06:23:43 +0900, James <james.cromwell@gmail.com> wrote:
p = Proc.new { |*args,&block| }
produces syntax error
p = Proc.new { |*args,&block| }
----------------------^It appears that Proc objects cannot receive blocks?
Will it eventually be possible to pass the block when using the
bracket-call syntax? ie:
block[...] {|*args| ...}
Right now it gives a parse error. Or would that make it too difficult
for the parser?
thanks,
Mark
On Fri, 5 Nov 2004 06:37:47 +0900, Yukihiro Matsumoto <matz@ruby-lang.org> wrote:
Hi,
In message "Re: Receiving blocks in Proc?" > on Fri, 5 Nov 2004 06:23:43 +0900, james.cromwell@gmail.com (James) writes:
>p = Proc.new { |*args,&block| }
>
>produces syntax error
>
>p = Proc.new { |*args,&block| }
>----------------------^
>
>It appears that Proc objects cannot receive blocks?Until 1.9, yes.
Hi,
In message "Re: Receiving blocks in Proc?" on Fri, 5 Nov 2004 07:00:35 +0900, Mark Hubbart <discordantus@gmail.com> writes:
Will it eventually be possible to pass the block when using the
bracket-call syntax? ie:block[...] {|*args| ...}
Right now it gives a parse error. Or would that make it too difficult
for the parser?
I have no plan to allow this. I have alternative idea, which allows
parentheses instead of brackets. But it still is a vague idea, no
promise.
matz.
Yukihiro Matsumoto ha scritto:
Hi,
>Will it eventually be possible to pass the block when using the
>bracket-call syntax? ie:
>
> block[...] {|*args| ...}
>
>Right now it gives a parse error. Or would that make it too difficult
>for the parser?I have no plan to allow this. I have alternative idea, which allows
parentheses instead of brackets. But it still is a vague idea, no
promise.
(on the notes from James Brown)
please please please please (please please oh oh )
Ok, I'd love this, sorry for the noise
In message "Re: Receiving blocks in Proc?" > on Fri, 5 Nov 2004 07:00:35 +0900, Mark Hubbart <discordantus@gmail.com> writes:
Hi,
At Fri, 5 Nov 2004 10:38:43 +0900,
gabriele renzi wrote in [ruby-talk:119146]:
> I have no plan to allow this. I have alternative idea, which allows
> parentheses instead of brackets. But it still is a vague idea, no
> promise.(on the notes from James Brown)
please please please please (please please oh oh )
I tried it but it breaks many code.
--
Nobu Nakada
Hi,
In message "Re: Receiving blocks in Proc?" on Fri, 12 Nov 2004 12:21:01 +0900, nobu.nokada@softhome.net writes:
> I have no plan to allow this. I have alternative idea, which allows
> parentheses instead of brackets. But it still is a vague idea, no
> promise.
I tried it but it breaks many code.
Yours was too thorough, I guess. What I was thinking was to allow
calling parentheses only after
* predefined local variables
* explicit method calls (with parentheses)
which should break less code.
matz.
Hi,
At Fri, 12 Nov 2004 12:38:37 +0900,
Yukihiro Matsumoto wrote in [ruby-talk:120009]:
>> > I have no plan to allow this. I have alternative idea, which allows
>> > parentheses instead of brackets. But it still is a vague idea, no
>> > promise.>I tried it but it breaks many code.
Yours was too thorough, I guess. What I was thinking was to allow
calling parentheses only after* predefined local variables
* explicit method calls (with parentheses)which should break less code.
Well, it did just those things, IIRC. Yes, "many" was not
correct word, but, even in bundled libraries, tests and
samples, some codes were using the variable of the same name as
a method.
--
Nobu Nakada
nobu.nokada@softhome.net ha scritto:
Hi,
At Fri, 12 Nov 2004 12:38:37 +0900,
Yukihiro Matsumoto wrote in [ruby-talk:120009]:> I have no plan to allow this. I have alternative idea, which allows
> parentheses instead of brackets. But it still is a vague idea, no
> promise.I tried it but it breaks many code.
Yours was too thorough, I guess. What I was thinking was to allow
calling parentheses only after* predefined local variables
* explicit method calls (with parentheses)which should break less code.
Well, it did just those things, IIRC. Yes, "many" was not
correct word, but, even in bundled libraries, tests and
samples, some codes were using the variable of the same name as
a method.
sorry if I'm asking a stupid question, I know I am dumb.. but would'nt be enough to give precedence to a method when called and to the variable when not explicit called?
I.e.
a=proc {|x| 'proc' }
a # #<Proc:0x02befeb0>
a() # 'proc'
a 10 # 'proc'
def a(x) p 'meth' end
a # #<Proc:0x02befeb0> precedence to var, as now
a() # 'meth' precedence to meth as now
a 10 # 'meth' precedence to meth as now
Maybe this is impossible to do at runtime and when building the ast you were just making a simple 'text substitution' like
a() => a.call() ?
Hi,
At Fri, 12 Nov 2004 19:23:27 +0900,
gabriele renzi wrote in [ruby-talk:120026]:
> Well, it did just those things, IIRC. Yes, "many" was not
> correct word, but, even in bundled libraries, tests and
> samples, some codes were using the variable of the same name as
> a method.sorry if I'm asking a stupid question, I know I am dumb.. but would'nt
be enough to give precedence to a method when called and to the variable
when not explicit called?
I.e.a=proc {|x| 'proc' }
a # #<Proc:0x02befeb0>
a() # 'proc'
a 10 # 'proc'
def a(x) p 'meth' end
a # #<Proc:0x02befeb0> precedence to var, as now
a() # 'meth' precedence to meth as now
a 10 # 'meth' precedence to meth as now
Yes, my patch implemented as you mentioned. But, for instance,
a code in sample/test.rb:
method = method(m)
`method' is defined at the moment assignment expression
appears, so `method()' in RHS calls that variable which is
defined but not assigned yet.
--
Nobu Nakada