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


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

Re: What allows closures in the JLS?

Started bySteven Simpson <ss@domain.invalid>
First post2014-03-10 13:31 +0000
Last post2014-03-10 13:31 +0000
Articles 1 — 1 participant

Back to article view | Back to comp.lang.java.programmer

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

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

#27710 — Re: What allows closures in the JLS?

FromSteven Simpson <ss@domain.invalid>
Date2014-03-10 13:31 +0000
SubjectRe: What allows closures in the JLS?
Message-ID<uer0va-cl5.ln1@s.simpson148.btinternet.com>
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

[toc] | [standalone]


Back to top | Article view | comp.lang.java.programmer


csiph-web