[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Re: Request for Block local methods, and Proc syntax

Yukihiro Matsumoto

9/5/2008 11:34:00 PM

Hi,

In message "Re: Request for Block local methods, and Proc syntax"
on Mon, 1 Sep 2008 11:35:56 +0900, Patrick Li <patrickli_2001@hotmail.com> writes:

|1) Block local methods:
|
|def myMethod
| def myLocalMethod #<-- myLocalMethod only visible within myMethod()
| end
|end

In that case, if myLocalMethod can only be visible from myMethod, can
we say the receiver responds to myLocalMethod message, or not? I am
afraid such "local methods" risk break the language's object system.

It's much easier to make such inner def to define a singleton method for
the receiver, and I have ever considered it, but I didn't get
confidence on the idea.

|2) Procs without proc keyword.
|
|Is there any reason why we need a proc keyword in front of a block?

This idea has risk to break the syntax. Making keyword less braces a
block conflict existing syntax (a lot). The idea should be realized
in the different language, I think.

matz.
p.s.
Try not to change the language first. Try bend it.

1 Answer

Patrick Li

9/6/2008 4:08:00 PM

0

Thanks for the reply Matz,

I see what you mean by the inner def screwing up the object system. I
don't foresee an easy way around that yet.

But I still think it's worth thinking about. In my opinion, DSL's is
Ruby's greatest strength. It's the one feature where Ruby is light years
ahead of other languages. And context-sensitive methods are vital to
DSL's. I think putting in some thought towards this direction could
really make Ruby stand out.

What other language let's you write code like:

html{
image(@mySource)
}

or

initEngine{
initSound
initGraphics
@window = initWindow
}

Anyway, thanks for designing such an elegant language Matz. It's really
a joy to use. I'm just shamelessly asking for more.
-Patrick
--
Posted via http://www.ruby-....