Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!eternal-september.org!feeder.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Steven Simpson Newsgroups: comp.lang.java.programmer Subject: Re: What allows closures in the JLS? Date: Mon, 10 Mar 2014 13:31:42 +0000 Organization: A noiseless patient Spider Lines: 42 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 8bit Injection-Info: mx05.eternal-september.org; posting-host="acde58fe4ecb49b864a5b7b2a919199b"; logging-data="12457"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+LiKx75vx4MmQhk1QMrblKDvEoi9PuwaU=" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.3.0 In-Reply-To: Cancel-Lock: sha1:+vV8z11XApomAO0GVUNKj7Q9TX4= Xref: csiph.com comp.lang.java.programmer:27710 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: > 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. > 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: > 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