From: Rodrigo Rosenfeld Rosas Date: 2011-12-17T21:15:20+09:00 Subject: [ruby-core:41706] Re: Documentation of the language itself (syntax, meanings, etc) This is a multi-part message in MIME format. --------------010903050909010005050909 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 8bit Em 17-12-2011 09:53, Andrew Grimm escreveu: > On Sat, Dec 17, 2011 at 6:42 AM, Sylvain Daubert > wrote: >> Hi, >> >> Le 15/12/2011 17:58, Rodrigo Rosenfeld Rosas a �crit : >> >>> Since Ruby is built on top of simple concepts, most of the documentation >>> can be read in the Core API and Standard Library API pages. >>> >>> Unfortunately, I don't see to find any official reference (besides >>> mentions to books) about the language syntax itself. >>> >> I agree with that. I think Ruby should have official documentation such as >> (at least) a tutorial. >> >> I don't have enough knowledge about Ruby to start such a project, but I'm >> ready to help (proofreading, writing examples, etc.) >> >> Sylvain >> > There's a description of keywords at > http://ruby-doc.org/docs/keywords/1.9/ (you have to click on the > keyword to get a description, though). > > Originally I thought this was part of Ruby itself, but > http://ruby-doc.org/docs/ lists it as an additional document. > Great! I didn't know about this. But the information about return doesn't seem to be accurate: "Inside a code block, the behavior ofreturndepends on whether or not the block constitutes the body of a regular Proc object or a lambda-style Proc object. In the case of a lambda, returncauses execution of the block to terminate. *In the case of a regular Proc,**return**attempts to return from the enclosing method. If there is no enclosing method, it's an error.*" What is the meaning of "enclosing" in this context? def method_name(proc_argument) proc_argument[] # contains a return end My understanding is that the enclosing method of the proc call is "method_name". Even if you say the the definition for "enclosing method" is the one that defined the proc, it still exists, so the snippet "If there is no enclosing method, it's an error." also doesn't reflect the situation. The definition of return for procs should be clearer IMO in the docs above, don't you agree? Cheers, Rodrigo. --------------010903050909010005050909 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Em 17-12-2011 09:53, Andrew Grimm escreveu:
On Sat, Dec 17, 2011 at 6:42 AM, Sylvain Daubert
<sylvain.daubert@laposte.net> wrote:
Hi,

Le 15/12/2011 17:58, Rodrigo Rosenfeld Rosas a écrit :

Since Ruby is built on top of simple concepts, most of the documentation
can be read in the Core API and Standard Library API pages.

Unfortunately, I don't see to find any official reference (besides
mentions to books) about the language syntax itself.

I agree with that. I think Ruby should have official documentation such as
(at least) a tutorial.

I don't have enough knowledge about Ruby to start such a project, but I'm
ready to help (proofreading, writing examples, etc.)

Sylvain

There's a description of keywords at
http://ruby-doc.org/docs/keywords/1.9/ (you have to click on the
keyword to get a description, though).

Originally I thought this was part of Ruby itself, but
http://ruby-doc.org/docs/ lists it as an additional document.


Great! I didn't know about this. But the information about return doesn't seem to be accurate:

"Inside a code block, the behavior of return depends on whether or not the block constitutes the body of a regular Proc object or a lambda-style Proc object. In the case of a lambda, return causes execution of the block to terminate. In the case of a regular Proc, return attempts to return from the enclosing method. If there is no enclosing method, it’s an error."

What is the meaning of "enclosing" in this context?

def method_name(proc_argument)
    proc_argument[] # contains a return
end

My understanding is that the enclosing method of the proc call is "method_name". Even if you say the the definition for "enclosing method" is the one that defined the proc, it still exists, so the snippet "If there is no enclosing method, it's an error." also doesn't reflect the situation.

The definition of return for procs should be clearer IMO in the docs above, don't you agree?

Cheers,

Rodrigo.

--------------010903050909010005050909--