[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 28274-28600

APURI Furuhashi

4/1/2006 8:43:00 AM

Hi all,

This is a summary of ruby-dev ML in these days.

[ruby-dev:28246] Named Capture for Regexp

K. Kosako proposed a new /g and /G flag for regexp,
to refer to the result of named capture by the name to Ruby 1.9
Meaning is as follows.
1. When neither is specified (default), capture of the group of
the name.
2. /g is specified. The group of the name doesn't do capture.
3. /G is specified. The group of the name does capture.
The discussion keeps going.




[ruby-dev:28481] __method__ for current method

Usa Nakamura suggested a new method __method__ to access name of
currently executing method. The name is chosen to go with __FILE__ and
__LINE__ but it's a method not syntax.

[ruby-dev:28533] Multi Methods

URABE Shyouhei proposed a rough idea for multi methods (in lisp as
generic function) for ruby
The syntax is
def foo( SPEC val)
SPEC is any object which respond to "===".
This allow multiple dispatch class based or like eql? specializer in
lisp.

But if ther is not a matching SPEC beetween all methods it is still
called, for duck typing.
Matz said he agrees and this can be committed to 1.9 if it is
fast implementation.


-- APURI Furuhashi
ruby-dev summary index: http://i.loveruby.net/en/ruby-dev-su...
15 Answers

Pit Capitain

4/1/2006 11:03:00 AM

0

APURI Furuhashi schrieb:
> [ruby-dev:28533] Multi Methods
>
> URABE Shyouhei proposed a rough idea for multi methods (in lisp as
> generic function) for ruby
> The syntax is
> def foo( SPEC val)
> SPEC is any object which respond to "===".
> This allow multiple dispatch class based or like eql? specializer in
> lisp.
>
> But if ther is not a matching SPEC beetween all methods it is still
> called, for duck typing.
> Matz said he agrees and this can be committed to 1.9 if it is
> fast implementation.

Will there be a defined sequence for calling the "===" methods?

If there are multiple matching definitions, which one(s) would be called?

Regards,
Pit


Mauricio Fernández

4/1/2006 2:08:00 PM

0

On Sat, Apr 01, 2006 at 08:02:54PM +0900, Pit Capitain wrote:
> APURI Furuhashi schrieb:
> >[ruby-dev:28533] Multi Methods
> >
> > URABE Shyouhei proposed a rough idea for multi methods (in lisp as
> > generic function) for ruby
> > The syntax is
> > def foo( SPEC val)
> > SPEC is any object which respond to "===".
> > This allow multiple dispatch class based or like eql? specializer in
> > lisp.
> >
> > But if ther is not a matching SPEC beetween all methods it is still
> > called, for duck typing.
> > Matz said he agrees and this can be committed to 1.9 if it is
> > fast implementation.
>
> Will there be a defined sequence for calling the "===" methods?
>
> If there are multiple matching definitions, which one(s) would be called?

See
http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby...

(and the Date: header)
--
Mauricio Fernandez - http://eige... - singular Ruby


Trans

4/1/2006 2:10:00 PM

0

By multi methods I take this to mean:

class Bar

def foo( String x )
...

def foo( Integer x )
...

Right?

> If there are multiple matching definitions, which one(s) would be called?

And how would you reference them via method()?

T.

Trans

4/1/2006 2:14:00 PM

0

> Usa Nakamura suggested a new method __method__ to access name of
> currently executing method. The name is chosen to go with __FILE__ and
> __LINE__ but it's a method not syntax.

Hmmm.... I had used #this for this purpose. But often I just need the
name of the method. If I have the name I can always do
'method(methodname)' --though the multidispatch thing might effect that
now too.

T.

Pit Capitain

4/1/2006 2:18:00 PM

0

Mauricio Fernandez schrieb:
> See
> http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby...
>
> (and the Date: header)

OK. Now I'm feeling better :-)

Regards,
Pit


Ara.T.Howard

4/1/2006 2:55:00 PM

0

Yukihiro Matsumoto

4/1/2006 4:43:00 PM

0

Hi,

In message "Re: ruby-dev summary 28274-28600"
on Sat, 1 Apr 2006 23:54:36 +0900, ara.t.howard@noaa.gov writes:

|> [ruby-dev:28481] __method__ for current method
|>
|> Usa Nakamura suggested a new method __method__ to access name of
|> currently executing method. The name is chosen to go with __FILE__ and
|> __LINE__ but it's a method not syntax.
|
|why not be consistent
|
| harp:~ > cat a.c
| #include <stdlib.h>
| #include <stdio.h>
| main () { printf ("%s:%s:%d\n", __FILE__, __FUNCTION__, __LINE__); }
|
|
| harp:~ > gcc a.c && a.out
| a.c:main:3

Because we don't have real functions but methods in Ruby.

matz.


Ara.T.Howard

4/1/2006 5:00:00 PM

0

Yukihiro Matsumoto

4/1/2006 5:32:00 PM

0

Hi,

In message "Re: ruby-dev summary 28274-28600"
on Sun, 2 Apr 2006 01:59:34 +0900, ara.t.howard@noaa.gov writes:

|i see your point... still, it seems to cut both ways:
|
| harp:~ > ruby -e' p [__FILE__, __LINE__]; eval "p [__FILE__, __LINE__]" '
| ["-e", 1]
| ["(eval)", 1]

I'm not sure what you meant. Do you mean both should print
["-e", 1] ? If so, what do you want to print by:

p "__FILE__ __LINE__"

? Or what if

def foo(x)
eval(x)
end

... and in some other file...
foo("p [__FILE__, __LINE__]")

?
matz.


Ara.T.Howard

4/1/2006 5:48:00 PM

0