[#39810] 2.0 feature questionnaire — SASADA Koichi <ko1@...>

I made a questionnaire "What do you want to introduce in 2.0?" in my

59 messages 2011/10/01
[#39822] Re: 2.0 feature questionnaire — Jeremy Kemper <jeremy@...> 2011/10/02

2011/10/1 SASADA Koichi <ko1@atdot.net>:

[#39827] Re: 2.0 feature questionnaire — Yukihiro Matsumoto <matz@...> 2011/10/02

Hi,

[#40324] Re: 2.0 feature questionnaire — Charles Oliver Nutter <headius@...> 2011/10/25

2011/10/1 SASADA Koichi <ko1@atdot.net>:

[#39823] Discussion results — SASADA Koichi <ko1@...>

Hi,

34 messages 2011/10/02
[#39840] Re: Discussion results — Intransition <transfire@...> 2011/10/02

I did not have the fortune of attending the discussion, but I would

[#39844] Re: Discussion results — Yukihiro Matsumoto <matz@...> 2011/10/02

Hi,

[#39851] Re: Discussion results (here documents with indents) — "Martin J. Dürst" <duerst@...> 2011/10/03

Hello Matz,

[#39862] Re: Discussion results (here documents with indents) — Yusuke Endoh <mame@...> 2011/10/03

Hello,

[#39874] Re: Discussion results (here documents with indents) — Trans <transfire@...> 2011/10/03

On Mon, Oct 3, 2011 at 8:16 AM, Yusuke Endoh <mame@tsg.ne.jp> wrote:

[#39915] [Ruby 1.9 - Feature #5400][Open] Remove flip-flops in 2.0 — Magnus Holm <judofyr@...>

29 messages 2011/10/04

[#39957] [Ruby 1.9 - Bug #5407][Open] Cannot build ruby-1.9.3-rc1 with TDM-GCC 4.6.1 on Windows XP SP3 — Heesob Park <phasis@...>

11 messages 2011/10/05

[#39993] [Ruby 1.9 - Feature #2348] RBTree Should be Added to the Standard Library — David Graham <david.malcom.graham@...>

10 messages 2011/10/06

[#40037] [Ruby 1.9 - Bug #5422][Open] File.fnmatch != Dir.glob # {no,sets} — Suraj Kurapati <sunaku@...>

14 messages 2011/10/07

[#40073] [Ruby 1.9 - Feature #5427][Open] Not complex patch to improve `require` time (load.c) — Yura Sokolov <funny.falcon@...>

31 messages 2011/10/09

[#40090] [Ruby 1.9 - Bug #5433][Open] PTY.spawn Kernel panic on macos lion — Gamaliel Toro <argami@...>

14 messages 2011/10/10

[#40188] [Ruby 2.0 - Feature #5454] keyword arguments — Yukihiro Matsumoto <matz@...>

16 messages 2011/10/17
[#40189] Re: [Ruby 2.0 - Feature #5454] keyword arguments — Evan Phoenix <evan@...> 2011/10/17

This looks very interesting! Would someone be willing to translate to english? I've only got a vague idea of what is being discussed.

[#40191] Re: [Ruby 2.0 - Feature #5454] keyword arguments — Yutaka Hara <yutaka.hara@...> 2011/10/18

Hi,

[#40192] Re: [Ruby 2.0 - Feature #5454] keyword arguments — Yukihiro Matsumoto <matz@...> 2011/10/18

Hi,

[#40259] Counseling — Perry Smith <pedzsan@...>

Ruby and I are back in counseling... Its always the same thing with her. "I'm throwing an Encoding exception!!!"

21 messages 2011/10/21
[#40263] Re: Counseling — "Haase, Konstantin" <Konstantin.Haase@...> 2011/10/21

What's your $LC_CTYPE? What OS are you on?

[#40264] Re: Counseling — Gon軋lo Silva <goncalossilva@...> 2011/10/21

Hi all,

[#40266] Re: Counseling — Bill Kelly <billk@...> 2011/10/21

Gon軋lo Silva wrote:

[#40267] Re: Counseling — Perry Smith <pedzsan@...> 2011/10/22

[#40268] Re: Counseling — Eric Hodel <drbrain@...7.net> 2011/10/22

On Oct 21, 2011, at 9:43 AM, Perry Smith wrote:

[#40269] Re: Counseling — Joshua Ballanco <jballanc@...> 2011/10/22

To try and cut to the core of the issue: in Ruby 1.8 it was common practice to use the String class to represent both "proper strings" as well as a "bag-o-bytes". In Ruby 1.9, you can only properly use the String class to represent "proper strings". For a "bag-o-bytes" we're left with Array, but there are times when Array is not the right abstraction (e.g. reading data from a socket, identifying a start and stop token, and writing the bytes between to a file on disk). Also, the "BINARY" encoding is not the right abstraction, because you still have an object which will worry about encodings and, due to Ruby always trying to do "the right thing", bugs can be very difficult to track down. Consider:

[#40271] Can rubygems save us from "binary-compatibility hell"? — Yusuke Endoh <mame@...>

Hello, rubygems developers --

17 messages 2011/10/22

[#40290] [ruby-trunk - Feature #5474][Assigned] keyword argument — Yusuke Endoh <mame@...>

36 messages 2011/10/23
[#40414] Re: [ruby-trunk - Feature #5474][Assigned] keyword argument — Charles Oliver Nutter <headius@...> 2011/10/26

More refinement below. I think we're on a good path here.

[#40416] Re: [ruby-trunk - Feature #5474][Assigned] keyword argument — Yukihiro Matsumoto <matz@...> 2011/10/26

Hi,

[#40418] Re: [ruby-trunk - Feature #5474][Assigned] keyword argument — Joshua Ballanco <jballanc@...> 2011/10/26

On Wed, Oct 26, 2011 at 2:08 PM, Yukihiro Matsumoto <matz@ruby-lang.org>wrote:

[#40425] Re: [ruby-trunk - Feature #5474][Assigned] keyword argument — Yukihiro Matsumoto <matz@...> 2011/10/27

Hi,

[#40298] Re: [ruby-trunk - Feature #5474][Assigned] keyword argument — Yukihiro Matsumoto <matz@...> 2011/10/24

Hi,

[#40311] [ruby-trunk - Feature #5478][Open] import Set into core, add syntax — Konstantin Haase <Konstantin.Haase@...>

33 messages 2011/10/24

[#40312] [ruby-trunk - Feature #5479][Open] import StringIO into core, add String#to_io — Konstantin Haase <Konstantin.Haase@...>

9 messages 2011/10/24
[#40350] [ruby-trunk - Feature #5479] import StringIO into core, add String#to_io — Charles Nutter <headius@...> 2011/10/25

[#40316] [ruby-trunk - Feature #5481][Open] Gemifying Ruby standard library — Hiroshi Nakamura <nakahiro@...>

86 messages 2011/10/24
[#40334] [ruby-trunk - Feature #5481] Gemifying Ruby standard library — Lucas Nussbaum <lucas@...> 2011/10/25

[#40322] [ruby-trunk - Feature #5482][Open] Rubinius as basis for Ruby 2.0 — Thomas Sawyer <transfire@...>

19 messages 2011/10/25

[#40356] JIT development for MRI — Carter Cheng <cartercheng@...>

Hello,

25 messages 2011/10/25
[#40390] Re: JIT development for MRI — SASADA Koichi <ko1@...> 2011/10/26

Hi,

[#40394] Re: JIT development for MRI — Carter Cheng <cartercheng@...> 2011/10/26

Dear Koichi SASADA,

[#40395] Re: JIT development for MRI — Carter Cheng <cartercheng@...> 2011/10/26

I noticed that you used context threading in YARV. Do you have some analysis

[#40417] Re: JIT development for MRI — SASADA Koichi <ko1@...> 2011/10/26

Thanks for reference.

[#40423] Re: JIT development for MRI — Carter Cheng <cartercheng@...> 2011/10/26

Thanks Koichi.

[#40412] [ruby-trunk - Bug #5486][Open] rb_stat() doesn’t respect input encoding — Nikolai Weibull <now@...>

15 messages 2011/10/26

[#40462] [ruby-trunk - Bug #5492][Open] MinGW Installation with Ruby 1.9.3rc1 Broken — Charlie Savage <cfis@...>

14 messages 2011/10/27

[#40573] [ruby-trunk - Bug #5530][Open] SEEK_SET malfunctions when used with 'append' File.open mode — "Joshua J. Drake" <ruby-lang.jdrake@...>

17 messages 2011/10/31

[#40586] [ruby-trunk - Feature #5531][Open] deep_value for dealing with nested hashes — Kyle Peyton <kylepeyton@...>

19 messages 2011/10/31

[ruby-core:40541] Re: [ruby-trunk - Feature #5474][Assigned] keyword argument

From: Benoit Daloze <eregontp@...>
Date: 2011-10-30 22:32:30 UTC
List: ruby-core #40541
On 30 October 2011 11:10, Yusuke Endoh <mame@tsg.ne.jp> wrote:
> Hello,
>
> Koichi told me that I can commit my patch to the trunk. o
> I'll do after I fix the issues Benoit reported.
> But I'll remain this ticket open to continue to discuss the
> spec.
>
>
> 2011/10/30 Benoit Daloze <eregontp@gmail.com>:
>> I have a few questions/remarks:
>
> Thank you very much for your trying my patch and your opinion!

It's all my pleasure to test shiny new features.

>> 1) What is the way to pass keyword arguments ?
>> I would guess `**h` like:
>>
>> def meth(a, **h)
>> ther(a, **h)
>> end # => syntax error
>
> I didn't implement caller's **.
> I wonder if we need it or not. s "other(a, h)" not enough?

I don't know why I thought keyword arguments were a separate type of
arguments, while there are mostly syntactic sugar for treating the
Hash given, if I understand well (which is fine, except maybe for
optimizations from the implementer POV, but I don't know well).

In that case, it is indeed enough.

>> BTW, using **h in the argument list does not seems to work in some cases for me:
>>
>> def a(**h)
>> end # => syntax error, unexpected tPOW
>
> Currently, my patch allows ** only when there are one or more
> keyword arguments.
>
> This is because I didn't think of any use case.
> In addition, I wanted to simplify the implementation of parser.
> (Unfortunately, adding a new argument type requries *doubling*
> he parser rules to avoid yacc's conflict)
> Do you think we need it?

No, sorry for the confusion.
(Ugh, doubling the parser rules sounds bad)

>> def m(k: nil, **h, &block)
>> end
>> m() # => undefined method `key?' for nil:NilClass
>
> This must be a bug. 'll fix it. hanks!

It seems to happen only when there is the &block parameter in my experience.

>> 2) I'm a bit dubious about the `**h` syntax to get (and I guess to
>> pass) a Hash though.
>
> As I said above, it serves as just `get', not `pass,' currently.
>
>
>> I believe `*args` is appropriate for the rest argument, because the
>> star is the splat operator.
>> I cannot think of any clear logic like that for `**h` except "another
>> rest argument".
>> Also `**` is the power operator, which is unrelated.
>> Something related to `{}`, the literal Hash syntax, would fit better
>> in my opinion.
>
> I accept another syntax, if it is allowed by matz, and yacc :-)
>
>> Do you have any idea of an alternate syntax to `**h` ?
>
> No I don't.

Given the above considerations, `**h` will only be used to get the
Hash, so I think it is fine.
Notably, delegating with method missing will stay simple as it is:

def method_missing(*args, &block)
  other(*args, &block)
end

>> 3) What would {Proc,Method,UnboundMethod}#parameters returns for
>> keywords arguments ?
>
> Indeed.  completely forgot. 'll do.

I would happily write the tests for that if you want.
Do you agree on the :key and :keyrest (now I'm thinking to :hash) names ?

>> 4)  noticed a few problems while experimenting:
>> def a(k: :a, **h)
>>  [k,h]
>> end
>> a(:b, c: :d, e: :f) # => wrong number of arguments (2 for 0) (ArgumentError)
>> It should be "1 for 0"
>
> Yes, the error message should be considered.
> But in the case, you're passing two arguments actually:
> ":b", and "{:c=>:d, :e=>:f}"
> Do you mean the keyword argument (= hash) should be ignored?

Well, it is rather confusing as is.
I would be fine with "1 for 0" since the method does not actually need
any argument.

If we count all arguments, we have indeed two, but then it's "2 for
1", the Hash should be counted at callee side too.
It would be nice if the ArgumentError specified what is missing, or
you might end up with "wrong number of arguments (1 for 1)":

def b(k: nil, **h)
end
b(:a) # => wrong number of arguments (1 for 0) (ArgumentError) # This
would be "1 for 1" if Hash is counted at callee side

I'm thinking to something like:
"positional argument given instead of keyword argument (ArgumentError)"
or
replace "x for y" by something mentioning (y-1) positional arguments
and the keyword argument.
But that's really badly said, I got no inspiration for error messages.

"2 for 0..1" might be a good compromise.
I wonder why this is not implemented with standard arguments (sorry
this is a bit off-topic, but it illustrates my thought):
def f(a, b = nil)
end
f(1, 2, 3) # => wrong number of arguments (3 for 2)
f() # => wrong number of arguments (0 for 1)
It's be nice to have "for 1..2".

>> def a(k: :a)
>>  [k,h]
>> end
>> a(r: :a) # => unknown keyword (TypeError)
>> It should say which keyword is missing
>
> Strongly agreed.  was just lazy :-)

The first virtue of a programmer :-)

>> (and an ArgumentError rather than TypeError, no?).
>
> Yes, fixed. atz said so too. ruby-core:40298]
>
> Thanks!
>
> --
> Yusuke Endoh <mame@tsg.ne.jp>
>

In This Thread