[#16611] lambda, ->, haskell, and so on — Dave Thomas <dave@...>
This is one of those e-mails that I know from the start to be futile, =20=
T24gV2VkLCBBcHIgMzAsIDIwMDggYXQgMTE6MjYgUE0sIERhdmUgVGhvbWFzIDxkYXZlQHByYWdw
Hi --
David A. Black wrote:
wouldn't
On Thu, May 01, 2008 at 12:26:47PM +0900, Dave Thomas wrote:
Hi --
David A. Black wrote:
Hi --
David A. Black wrote:
On Tue, May 06, 2008 at 02:02:34AM +0900, David A. Black wrote:
Hi --
Hi --
ara howard wrote:
Hi --
Hi --
Hi --
Not to throw the whole thread into a tizzy again, but why again is:
Evan Phoenix wrote:
Hi,
Hi --
On Sun, May 11, 2008 at 9:49 AM, Nobuyoshi Nakada <nobu@ruby-lang.org>
Hi,
Hi --
Hi,
Hi,
What about "fn" or "fun", for "function"?
Hi,
Hi,
Hi --
Hi,
Hi --
On Wed, 14 May 2008, David A. Black wrote:
Hi,
how about an uppercase lambda (instead of the usual lowercase one)
Christopher Gill wrote:
Suraj N. Kurapati wrote:
Hi,
Nobuyoshi Nakada wrote:
Hi,
=20
T24gVGh1LCBNYXkgMjIsIDIwMDggYXQgNTozNyBQTSwgQmVyZ2VyLCBEYW5pZWwgPERhbmllbC5C
RXZlbiB0aG91Z2ggSSBzZWUgdGhlIHVzZWZ1bG5lc3MsIHRoYXQncyBqdXN0IHVnbHkuCgotLUpl
"Jeremy McAnally" <jeremymcanally@gmail.com> wrote on 05/22/2008 05:35:01=20
2008/5/23 <Nate_Wiger@playstation.sony.com>:
I am not sure if that fits to the thread. I have not used yet the more
Tammo Tjarks wrote:
Hi --
> assert_yin_yang -> { q += 0 }, 'it broke!', -> { q == 42 }
Hi --
>> assert_yin_yang proc{ q += 0 }, 'it broke!',
[#16627] Monotonic timeofday() — zimbatm <zimbatm@...>
Hi ruby-core.
[#16642] ruby/trunk rev 16276 broken? ib/erb.rb:429:in `initialize': wrong argument type StringScanner (expected true) (TypeError) — Kurt Stephens <ks@...>
Build crashes shortly after miniruby linkage
[#16648] Uniform RDoc markup — "Jeremy McAnally" <jeremymcanally@...>
Would there be any resistance to making the markup of the RDoc
[#16760] errors running make test — Stephen Bannasch <stephen.bannasch@...>
I updated to revision 16403 and now compiling and running ruby1.9
[#16772] The RubySpec project at rubyspec.org — Brian Ford <brixen@...>
Hi all,
[#16773] Singleton methods on Float and Bignum — Evan Phoenix <evan@...>
In 1.8 (and 1.9 likely), trying to add a singleton method to a Float
Evan Phoenix wrote:
[#16788] Ruby 1.8.7-preview3 has been released — "Akinori MUSHA" <knu@...>
Folks,
[#16791] GC heap allocation in 1.9 — Sylvain Joyeux <sylvain.joyeux@...4x.org>
While getting the latest of trunk, I stumbled on r16194.
[#16806] nil.instance_eval — ts <decoux@...>
[#16807] Embedding Ruby1.9: seg fault — Masoom <masoom.shaikh@...>
Hi,
Hi,
that means current vm is not embeddable ? by min. src I guess you mean the
Masoom wrote:
[#16812] Proposal: Subject of ruby-core ML article should include artile number — SASADA Koichi <ko1@...>
Hi,
On Tue, May 20, 2008 at 8:20 AM, SASADA Koichi <ko1@atdot.net> wrote:
Luis Lavena wrote:
[#16832] Who is responsible for Ruby license? — "Han, Kimyung" <Kimyung.Han@...>
I am trying to discuss the ruby license with anyone who is responsible
[#16834] Returning duplicate values from Dir.glob — "Vladimir Sizikov" <vsizikov@...>
Hi,
[#16839] ruby autoconf problems — "Michal Suchanek" <hramrach@...>
Hello
[#16864] removal of magical definition of name for some class definition idioms — "Robert Dober" <robert.dober@...>
Dear list
[#16884] block args w/ defaults (was Re: resolving lambda | ambiguity) — "Eric Mahurin" <eric.mahurin@...>
On Sat, May 24, 2008 at 4:06 PM, Eric Mahurin <eric.mahurin@gmail.com>
SGV5IQoKSSd2ZSB0cmllZCB5b3VyIHBhdGNoIGFuZCBoYXZlIHNvbWUgdHJvdWJsZXMuCkkgZXhw
[#16886] lambda with normal block syntax — "Eric Mahurin" <eric.mahurin@...>
This patch is an independent but related one to my previous one. It can be
Hi,
On Sun, May 25, 2008 at 8:19 PM, Nobuyoshi Nakada <nobu@ruby-lang.org>
Hi,
Hi,
Hi,
Hi,
On Mon, May 26, 2008 at 4:14 PM, Dave Thomas <dave@pragprog.com> wrote:
Hi,
On Mon, May 26, 2008 at 5:18 PM, Yukihiro Matsumoto <matz@ruby-lang.org>
Hi,
If I may, here are two entries from the ChangeLog file:
Dave Thomas wrote:
Dave Thomas wrote:
Dave Thomas wrote:
On May 27, 2008, at 12:33 PM, David Flanagan wrote:
James Gray wrote:
Dave Thomas wrote:
David Flanagan wrote:
Hi,
On 5/28/08, Yukihiro Matsumoto <matz@ruby-lang.org> wrote:
Hi,
On Sun, May 25, 2008 at 2:31 AM, Eric Mahurin <eric.mahurin@gmail.com> wrote:
[#16921] Major performance degradation on trunk — "Vladimir Sizikov" <vsizikov@...>
Hi,
[#16943] Re: [PATCH] block args w/ defaults (updated) — "Eric Mahurin" <eric.mahurin@...>
MjAwOC81LzI2IFJhZG9zs2F3IEJ1s2F0IDxyYWRlay5idWxhdEBnbWFpbC5jb20+OgoKPiBIZXkh
[#16945] Oniguruma and \p{Greek} — Dave Thomas <dave@...>
Looking at the source, I'd expect the following to work:
[#16951] Ruby 1.9 "exception reentered" — "Paul Boekholt" <p.boekholt@...>
Hi,
2008/5/27, Paul Boekholt <p.boekholt@gmail.com>:
2008/6/6, Paul Boekholt <p.boekholt@gmail.com>:
> 2008/6/6, Paul Boekholt <p.boekholt@gmail.com>:
[#16953] 1.8.6, jemalloc, sock.close problem — Christopher Thompson <cthompson@...>
Warning: This message is probably only peripherally related to Ruby!
I used to catch Errno::EINVAL when using lots of open file descriptors
[#16955] ruby-mode.el copyright assignment — Phil Hagelberg <phil@...>
Hi,
[#16979] Array.nitems replacement? — David Flanagan <david@...>
Array.nitems has just been removed from 1.9, and as near as I can make
[#16984] ZLIB for MSVC 8 - tar_input.rb — "Giancarlo F Bellido" <support@...>
I managed to install wxruby and compile zlib extension using this patch in
On May 28, 2008, at 19:48 PM, Giancarlo F Bellido wrote:
[#17010] unexpected return using define_method — Paul Brannan <pbrannan@...>
Is this a bug?
Paul Brannan wrote:
On Fri, May 30, 2008 at 06:10:25PM +0900, ts wrote:
Paul Brannan wrote:
[#17028] Ruby 1.8.7 has been released — "Akinori MUSHA" <knu@...>
Folks,
On Sun, Jun 01, 2008 at 12:25:08AM +0900, Akinori MUSHA wrote:
At Mon, 2 Jun 2008 06:37:21 +0900,
On Mon, Jun 02, 2008 at 03:46:53PM +0900, Akinori MUSHA wrote:
[#17030] Bytecode handling (compilation) extensions to Ruby 1.9 — Adam Strzelecki <ono@...>
Hello,
Hello again,
Hi,
> to_ary() convert ISeq object to Array and well known objects such as
Re: [PATCH] block args w/ defaults (updated)
MjAwOC81LzI3IFJhZG9zs2F3IEJ1s2F0IDxyYWRlay5idWxhdEBnbWFpbC5jb20+OgoKPiBDb3Vs ZCB5b3Ugc2VuZCB0aGlzIHBhdGNoIGFzIGF0dGFjaG1lbnQgcGxlYXNlPyBXaGVuIEkgY29weSBp dCBmcm9tCj4gbWFpbCB0aGVyZSBhcmUgc29tZSB3aGl0ZSBzcGFjZSBpc3N1ZSBhbmQgcGF0Y2gg Y291bGRuJ3QgYmUgYXBwbGllZAo+IGF1dG9tYXRpY2FsbHkgKHRoZSBzYW1lIHdhcyB3aXRoIHBy ZXZpb3VzIGJ1dCBhdHRhY2hlZCBwYXRjaCB3b3JrZWQKPiBmb3IgbWUpLgo+CgpJJ20gYXR0YWNo aW5nIGl0IGFzIGEgLnR4dCBmaWxlIHNvIHRoYXQgaXQgaXMgdmlld2FibGUgKGdtYWlsIGFsd2F5 cyB1c2VzCmJhc2U2NCBmb3IgLnBhdGNoKS4K
Attachments (1)
Index: sample/test.rb
===================================================================
--- sample/test.rb (revision 16568)
+++ sample/test.rb (working copy)
@@ -296,6 +296,61 @@
test_ok(f.call([42,55]) == [[42,55]])
test_ok(f.call(42,55) == [42,55])
+[method(:lambda), method(:proc), Proc.method(:new), lambda{|&b|b}].each do |lam|
+
+ f = lam.call { |a, b=42, *c| [a,b,c] }
+ test_ok(f.call(1 ) == [1,42,[ ]] )
+ test_ok(f.call(1,43 ) == [1,43,[ ]] )
+ test_ok(f.call(1,43,44) == [1,43,[44]] )
+
+ f = lam.call { |a, b=(a|16), *c, &block| [a,b,c,block&&block[]] }
+ test_ok(f.call(8 ) == [8,24,[ ],nil] )
+ test_ok(f.call(8,43 ) == [8,43,[ ],nil] )
+ test_ok(f.call(8,43,44) == [8,43,[44],nil] )
+ test_ok(f.call(8 ){45} == [8,24,[ ],45 ] )
+ test_ok(f.call(8,43 ){45} == [8,43,[ ],45 ] )
+ test_ok(f.call(8,43,44){45} == [8,43,[44],45 ] )
+
+ f = lam.call { |a, b=42, *c, d| [a,b,c,d] }
+ test_ok(f.call(1 ,99) == [1,42,[ ],99] )
+ test_ok(f.call(1,43 ,99) == [1,43,[ ],99] )
+ test_ok(f.call(1,43,44,99) == [1,43,[44],99] )
+
+ f = lam.call { |a, b=(a|16), &block| [a,b,block&&block[]] }
+ test_ok(f.call(8 ) == [8,24,nil] )
+ test_ok(f.call(8,43) == [8,43,nil] )
+ test_ok(f.call(8 ){45} == [8,24,45 ] )
+ test_ok(f.call(8,43){45} == [8,43,45 ] )
+
+ f = lam.call { |a, b=42, d| [a,b,d] }
+ test_ok(f.call(1 ,99) == [1,42,99] )
+ test_ok(f.call(1,43,99) == [1,43,99] )
+
+ f = lam.call { |b=42, *c, &block| [b,c,block&&block[]] }
+ test_ok(f.call( ) == [42,[ ],nil] )
+ test_ok(f.call(43 ) == [43,[ ],nil] )
+ test_ok(f.call(43,44) == [43,[44],nil] )
+ test_ok(f.call( ){45} == [42,[ ],45 ] )
+ test_ok(f.call(43 ){45} == [43,[ ],45 ] )
+ test_ok(f.call(43,44){45} == [43,[44],45 ] )
+
+ f = lam.call { |b=42, *c, d| [b,c,d] }
+ test_ok(f.call( 99) == [42,[ ],99] )
+ test_ok(f.call(43 ,99) == [43,[ ],99] )
+ test_ok(f.call(43,44,99) == [43,[44],99] )
+
+ f = lam.call { |b=42, &block| [b,block&&block[]] }
+ test_ok(f.call( ) == [42,nil] )
+ test_ok(f.call(43) == [43,nil] )
+ test_ok(f.call( ){45} == [42,45 ] )
+ test_ok(f.call(43){45} == [43,45 ] )
+
+ f = lam.call { |b=42, d| [b,d] }
+ test_ok(f.call( 99) == [42,99] )
+ test_ok(f.call(43,99) == [43,99] )
+
+end
+
a,=*[1]
test_ok(a == 1)
a,=*[[1]]
Index: parse.y
===================================================================
--- parse.y (revision 16568)
+++ parse.y (working copy)
@@ -666,6 +666,7 @@
%type <node> open_args paren_args opt_paren_args
%type <node> command_args aref_args opt_block_arg block_arg var_ref var_lhs
%type <node> mrhs superclass block_call block_command
+%type <node> f_block_optarg f_block_opt
%type <node> f_arglist f_args f_arg f_arg_item f_optarg f_marg f_marg_list f_margs
%type <node> assoc_list assocs assoc undef_list backref string_dvar for_var
%type <node> block_param opt_block_param block_param_def f_opt
@@ -3169,9 +3170,41 @@
}
;
-block_param : f_arg ',' f_rest_arg opt_f_block_arg
+block_param : f_arg ',' f_block_optarg ',' f_rest_arg opt_f_block_arg
{
/*%%%*/
+ $$ = new_args($1, $3, $5, 0, $6);
+ /*%
+ $$ = params_new($1, $3, $5, Qnil, escape_Qundef($6));
+ %*/
+ }
+ | f_arg ',' f_block_optarg ',' f_rest_arg ',' f_arg opt_f_block_arg
+ {
+ /*%%%*/
+ $$ = new_args($1, $3, $5, $7, $8);
+ /*%
+ $$ = params_new($1, $3, $5, $7, escape_Qundef($8));
+ %*/
+ }
+ | f_arg ',' f_block_optarg opt_f_block_arg
+ {
+ /*%%%*/
+ $$ = new_args($1, $3, 0, 0, $4);
+ /*%
+ $$ = params_new($1, $3, Qnil, Qnil, escape_Qundef($4));
+ %*/
+ }
+ | f_arg ',' f_block_optarg ',' f_arg opt_f_block_arg
+ {
+ /*%%%*/
+ $$ = new_args($1, $3, 0, $5, $6);
+ /*%
+ $$ = params_new($1, $3, Qnil, $5, escape_Qundef($6));
+ %*/
+ }
+ | f_arg ',' f_rest_arg opt_f_block_arg
+ {
+ /*%%%*/
$$ = new_args($1, 0, $3, 0, $4);
/*%
$$ = params_new($1, Qnil, $3, Qnil, escape_Qundef($4));
@@ -3202,6 +3235,38 @@
$$ = params_new($1, Qnil,Qnil, Qnil, escape_Qundef($2));
%*/
}
+ | f_block_optarg ',' f_rest_arg opt_f_block_arg
+ {
+ /*%%%*/
+ $$ = new_args(0, $1, $3, 0, $4);
+ /*%
+ $$ = params_new(Qnil, $1, $3, Qnil, escape_Qundef($4));
+ %*/
+ }
+ | f_block_optarg ',' f_rest_arg ',' f_arg opt_f_block_arg
+ {
+ /*%%%*/
+ $$ = new_args(0, $1, $3, $5, $6);
+ /*%
+ $$ = params_new(Qnil, $1, $3, $5, escape_Qundef($6));
+ %*/
+ }
+ | f_block_optarg opt_f_block_arg
+ {
+ /*%%%*/
+ $$ = new_args(0, $1, 0, 0, $2);
+ /*%
+ $$ = params_new(Qnil, $1, Qnil, Qnil,escape_Qundef($2));
+ %*/
+ }
+ | f_block_optarg ',' f_arg opt_f_block_arg
+ {
+ /*%%%*/
+ $$ = new_args(0, $1, 0, $3, $4);
+ /*%
+ $$ = params_new(Qnil, $1, Qnil, $3, escape_Qundef($4));
+ %*/
+ }
| f_rest_arg opt_f_block_arg
{
/*%%%*/
@@ -4302,6 +4367,44 @@
}
;
+f_block_opt : tIDENTIFIER '=' primary_value
+ {
+ /*%%%*/
+ if (!is_local_id($1))
+ yyerror("formal argument must be local variable");
+ shadowing_lvar($1);
+ arg_var($1);
+ $$ = NEW_OPT_ARG(0, assignable($1, $3));
+ /*%
+ $$ = rb_assoc_new($1, $3);
+ %*/
+ }
+ ;
+
+f_block_optarg : f_block_opt
+ {
+ /*%%%*/
+ $$ = $1;
+ /*%
+ $$ = rb_ary_new3(1, $1);
+ %*/
+ }
+ | f_block_optarg ',' f_block_opt
+ {
+ /*%%%*/
+ NODE *opts = $1;
+
+ while (opts->nd_next) {
+ opts = opts->nd_next;
+ }
+ opts->nd_next = $3;
+ $$ = $1;
+ /*%
+ $$ = rb_ary_push($1, $3);
+ %*/
+ }
+ ;
+
f_optarg : f_opt
{
/*%%%*/
Index: vm_insnhelper.c
===================================================================
--- vm_insnhelper.c (revision 16568)
+++ vm_insnhelper.c (working copy)
@@ -699,7 +699,8 @@
else {
int i;
int argc = orig_argc;
- const int m = iseq->argc;
+ int m = iseq->argc;
+ int opt_pc = 0;
th->mark_stack_len = argc;
@@ -719,18 +720,39 @@
MEMCPY(argv, RARRAY_PTR(ary), VALUE, argc);
}
+ if (iseq->arg_opts) {
+ const int opts = iseq->arg_opts - 1 /* no opt */;
+ int overrides = argc-(m + iseq->arg_post_len);
+ if (overrides > opts) overrides = opts;
+ else if (overrides < 0) overrides = 0;
+ opt_pc = iseq->arg_opt_table[overrides];
+ m += overrides;
+ }
+
for (i=argc; i<m; i++) {
argv[i] = Qnil;
}
if (iseq->arg_rest == -1) {
- if (m < argc) {
+ if ( (m + iseq->arg_post_len) < argc) {
/*
* yield 1, 2
* => {|a|} # truncate
*/
- th->mark_stack_len = argc = m;
+ th->mark_stack_len = argc = m + iseq->arg_post_len;
}
+ if (iseq->arg_post_len) {
+ int len = iseq->arg_post_len;
+ int start = iseq->arg_post_start;
+ int rsize = argc > m ? argc - m : 0;
+ int psize = rsize;
+
+ MEMMOVE(&argv[start], &argv[argc - psize], VALUE, psize);
+
+ for (i=psize; i<len; i++) {
+ argv[start + i] = Qnil;
+ }
+ }
}
else {
int r = iseq->arg_rest;
@@ -754,7 +776,7 @@
}
/* copy post argument */
- MEMMOVE(&argv[start], &argv[r + rsize - psize], VALUE, psize);
+ MEMMOVE(&argv[start], &argv[argc - psize], VALUE, psize);
for (i=psize; i<len; i++) {
argv[start + i] = Qnil;
@@ -791,7 +813,7 @@
}
th->mark_stack_len = 0;
- return 0;
+ return opt_pc;
}
}