M
Minero Aoki
Hi all,
This is a summary of ruby-dev #27393-27541.
[ruby-dev:27406] Ripper.new("").parse blocks
Akira Tanaka reported that Ripper.new("").parse blocks. This is because:
1. Ripper.new checks #gets method for the argument.
2. rb_respond_to() returns true for private methods.
3. Ripper.new calls String#gets, which is equivalent to private
method Kernel#gets.
4. Kernel#gets reads data from $stdin, it blocks.
To solve this problem, nobu posted a patch to change rb_respond_to()
behavior, and the patch is incorporated. Now rb_respond_to() returns
true only for public methods.
[ruby-dev:27417] selector namespace
Shugo Maeda proposed a new language feature, "selector namespace".
Matz also noted this topic in his key note at Ruby Conference 2005.
Selector namespace is a namespace of selector (method name). This
function is useful to replace methods temporarily. For example,
current jcode.rb replaces String#chop itself, which effects globally.
But with selector namespace, it effects only in "jcode" namespace.
class String
def jcode$chop # define #chop method in jcode namespace
...
end
end
# "\244\242\244\244" is Japanese characters 'A'+'I' in EUC-JP
p "\244\242\244\244".chop # "\244\242\244" # wrong result
p "\244\242\244\244".jcode$chop # "\244\242" # right result
You can omit namespace specifier ("jcode$") by using "using" syntax:
class String
def jcode$chop() ... end
end
using jcode
p "\244\242\244\244".chop # "\244\242" # right result
There are still many arguments, for example:
* whether "using" effects statically or dynamically
* '$' is ugly
* scope of "using" (file level / module level / method level)
* whether spaces are allowed around '$'
[ruby-dev:27424] value of BEGIN block
Nobuyoshi Nakada posted a patch to get a value of BEGIN block, like
following code:
val = BEGIN { 2 ** 345 }
You can utilise this function like `once' method provided by Eiffel
programming language:
# p is executed 5000 times but 2**345 is calculated only once
5000.times do
p(BEGIN { 2 ** 345 })
end
This issue is still open.
[ruby-dev:27449] --without-foo
Usaku Nakamura posted a patch to add new configure options to select
compiling extension libraries. For example, you can disable Win32API
library and io/wait library by following options:
$ ./configure --without-Win32API --with-io/wait=no
This patch is incorporated to CVS trunk HEAD.
[ruby-dev:27470] def Foo::Bar.baz
Shyouhei URABE claimed that "def Foo::Bar.baz" should be valid:
~ % ruby -ce 'def Foo::Bar.baz() end'
-e:1: syntax error, unexpected '.', expecting ';' or '\n'
def Foo::Bar.baz() end
^
-e:1: syntax error, unexpected kEND, expecting $end
Matz rejected this claim because we cannot add this syntax without
any (yacc's) conflict.
[ruby-dev:27548] ruby 1.8.4 preview 1 released
Matz released ruby 1.8.4 preview 1.
ftp://ftp.ruby-lang.org/pub/ruby/1.8/ruby-1.8.4-preview1.tar.gz
MD5 sum: cfb6e4c53369c016ebb4061c240c493d
-- Minero Aoki
ruby-dev summary index: http://i.loveruby.net/en/ruby-dev-summary.html
This is a summary of ruby-dev #27393-27541.
[ruby-dev:27406] Ripper.new("").parse blocks
Akira Tanaka reported that Ripper.new("").parse blocks. This is because:
1. Ripper.new checks #gets method for the argument.
2. rb_respond_to() returns true for private methods.
3. Ripper.new calls String#gets, which is equivalent to private
method Kernel#gets.
4. Kernel#gets reads data from $stdin, it blocks.
To solve this problem, nobu posted a patch to change rb_respond_to()
behavior, and the patch is incorporated. Now rb_respond_to() returns
true only for public methods.
[ruby-dev:27417] selector namespace
Shugo Maeda proposed a new language feature, "selector namespace".
Matz also noted this topic in his key note at Ruby Conference 2005.
Selector namespace is a namespace of selector (method name). This
function is useful to replace methods temporarily. For example,
current jcode.rb replaces String#chop itself, which effects globally.
But with selector namespace, it effects only in "jcode" namespace.
class String
def jcode$chop # define #chop method in jcode namespace
...
end
end
# "\244\242\244\244" is Japanese characters 'A'+'I' in EUC-JP
p "\244\242\244\244".chop # "\244\242\244" # wrong result
p "\244\242\244\244".jcode$chop # "\244\242" # right result
You can omit namespace specifier ("jcode$") by using "using" syntax:
class String
def jcode$chop() ... end
end
using jcode
p "\244\242\244\244".chop # "\244\242" # right result
There are still many arguments, for example:
* whether "using" effects statically or dynamically
* '$' is ugly
* scope of "using" (file level / module level / method level)
* whether spaces are allowed around '$'
[ruby-dev:27424] value of BEGIN block
Nobuyoshi Nakada posted a patch to get a value of BEGIN block, like
following code:
val = BEGIN { 2 ** 345 }
You can utilise this function like `once' method provided by Eiffel
programming language:
# p is executed 5000 times but 2**345 is calculated only once
5000.times do
p(BEGIN { 2 ** 345 })
end
This issue is still open.
[ruby-dev:27449] --without-foo
Usaku Nakamura posted a patch to add new configure options to select
compiling extension libraries. For example, you can disable Win32API
library and io/wait library by following options:
$ ./configure --without-Win32API --with-io/wait=no
This patch is incorporated to CVS trunk HEAD.
[ruby-dev:27470] def Foo::Bar.baz
Shyouhei URABE claimed that "def Foo::Bar.baz" should be valid:
~ % ruby -ce 'def Foo::Bar.baz() end'
-e:1: syntax error, unexpected '.', expecting ';' or '\n'
def Foo::Bar.baz() end
^
-e:1: syntax error, unexpected kEND, expecting $end
Matz rejected this claim because we cannot add this syntax without
any (yacc's) conflict.
[ruby-dev:27548] ruby 1.8.4 preview 1 released
Matz released ruby 1.8.4 preview 1.
ftp://ftp.ruby-lang.org/pub/ruby/1.8/ruby-1.8.4-preview1.tar.gz
MD5 sum: cfb6e4c53369c016ebb4061c240c493d
-- Minero Aoki
ruby-dev summary index: http://i.loveruby.net/en/ruby-dev-summary.html