Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.programmer > #27710

Re: What allows closures in the JLS?

From Steven Simpson <ss@domain.invalid>
Newsgroups comp.lang.java.programmer
Subject Re: What allows closures in the JLS?
Date 2014-03-10 13:31 +0000
Organization A noiseless patient Spider
Message-ID <uer0va-cl5.ln1@s.simpson148.btinternet.com> (permalink)
References <closures-20140308015312@ram.dialup.fu-berlin.de>

Show all headers | View raw


On 08/03/14 01:01, Stefan Ram wrote:
>    The JLS, in fact contains the following word sequence:
>
>        "local variables from the surrounding method may be
>        referred to"
>
>      - JLS7, 8.1.3, Example 8.1.3-2.
>
>    and this is just what I was looking for. Why do I still post
>    this question here? Because this sentence "only" appears in
>    an example (Example 8.1.3-2). I am looking for the same
>    contents in a more normative part.


I think these might cover it:

<http://docs.oracle.com/javase/specs/jls/se7/html/jls-6.html#jls-6.3>
> The /scope/ of a declaration is the region of the program within which 
> the entity declared by the declaration can be referred to using a 
> simple name, provided it is visible (§6.4.1).

> The scope of a formal parameter of a method (§8.4.1) or constructor 
> (§8.8.1) is the entire body of the method or constructor.


<http://docs.oracle.com/javase/specs/jls/se7/html/jls-6.html#jls-6.5.6.1>
> If an expression name consists of a single /Identifier/, then there 
> must be exactly one declaration denoting either a local variable, 
> parameter, or field visible (§6.4.1) at the point at which the 
> /Identifier/ occurs.  Otherwise, a compile-time error occurs. 


Also, this would be redundant if you couldn't reference parameters in an
inner class:

<http://docs.oracle.com/javase/specs/jls/se7/html/jls-8.html#jls-8.1.3>
> Any local variable, formal parameter, or exception parameter used but 
> not declared in an inner class must be declared final.

-- 
ss at comp dot lancs dot ac dot uk

Back to comp.lang.java.programmer | Previous | Next | Find similar | Unroll thread


Thread

Re: What allows closures in the JLS? Steven Simpson <ss@domain.invalid> - 2014-03-10 13:31 +0000

csiph-web