Ruby-dev summary 28274-28600

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-summary.html

APURI Furuhashi schrieb:

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

On Sat, Apr 01, 2006 at 08:02:54PM +0900, Pit C. wrote:

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-dev/28533

(and the Date: header)

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.

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.

Mauricio F. schrieb:

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

(and the Date: header)

OK. Now I’m feeling better :slight_smile:

Regards,
Pit

On Sat, 1 Apr 2006, APURI Furuhashi wrote:

the name.
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

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.

can any one show an example of what this might look like in ruby?

regards.

-a

Hi,

In message “Re: ruby-dev summary 28274-28600”
on Sat, 1 Apr 2006 23:54:36 +0900, [email protected] 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.

Hi,

In message “Re: ruby-dev summary 28274-28600”
on Sun, 2 Apr 2006 01:59:34 +0900, [email protected] 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.

On Sun, 2 Apr 2006, Yukihiro M. wrote:

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

  					matz.

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]

regards.

-a

btw. whatever it is called this will be a very nice feature to have!

A good name mught be 1ST.

T.

On Sun, 2 Apr 2006, Yukihiro M. wrote:

… and in some other file…
foo(“p [FILE, LINE]”)

?
matz.

sorry i wasn’t clear.

i just meant that even though ruby does not have real functions using
FUNCTION (and alias METHOD) seems to be o.k. since

  • it inherits idea from c like FILE and LINE

  • FILE and LINE work even when there is no ‘real’ file or
    line
    (unlike c) so it seems ok that FUNCTION might work even though
    there
    is no ‘real’ function :wink:

btw. whatever it is called this will be a very nice feature to have!

regards.

-a

On Sun, 2 Apr 2006, Trans wrote:

btw. whatever it is called this will be a very nice feature to have!

A good name mught be 1ST.

T.

ya know - what might really be good is

callstack #=> array of method objects

where

first = callstack.first
p first.name #=> like method

so, like caller but something more valuable than strings…

thoughts??

-a

A good name mught be 1ST.

I was waiting for someone to say, “Or APRIL:wink:

T.

[email protected] wrote:

callstack #=> array of method objects

where

first = callstack.first
p first.name #=> like method

so, like caller but something more valuable than strings…

thoughts??

Leave it Ara to to turn lemons into lemonade! :slight_smile:

I argee, Ara. I’ve wondered about a more object-oriented callstack for
sometime --I’ve even created one with my TracePoint class. Which I then
use to create a more robust event tracing system (built on top of
set_trace_func).

T.

[email protected] ha scritto:

so, like caller but something more valuable than strings…

thoughts??

yes, one: I recall Sydney had something like this, i.e. Frame objects
(and BackTrace objects), see for example:
http://hoshi.fallingsnow.net/svn/sydney/trunk/test/sydney/test_frame.rb

I’d love if we could import that, but maybe ruby and sydney diverged too
much in the meanwhile.
Ah, and I guess we’re approaching Smalltalk again, is’nt that what they
use “thisContext” for?

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs