Compiling call to 'for' method can fail

Neal Gafter neal at gafter.com
Wed Jun 25 07:07:05 PDT 2008


Yes, this is on my TODO list.  I need to store a class file attribute for this.

Regards,
Neal

On Wed, Jun 25, 2008 at 2:07 AM, Mark Mahieu
<mark at twistedbanana.demon.co.uk> wrote:
> I guess this is likely to be a known 'to do' item, but just in case it
> isn't...
>
> It seems that compiling a call to a method declared with the 'for' modifier
> only succeeds if that method is being compiled at the same time.  For
> example, given these two source files:
>
>
> // foo/ForCaller.java
>
> package foo;
> import static foo.ForEver.*;
>
> class ForCaller {
>        public static void main(String[] args) {
>                for ever() {}
>        }
> }
>
>
> // foo/ForEver.java
>
> package foo;
>
> class ForEver {
>        static for void ever({==>void} block) {}
> }
>
>
> Then this succeeds:
>
> $ rm foo/*.class
> $ $BGGA_HOME/bin/javac foo/ForCaller.java
> $
>
>
> But this doesn't:
>
> $ rm foo/*.class
> $ $BGGA_HOME/bin/javac foo/ForEver.java
> $ $BGGA_HOME/bin/javac foo/ForCaller.java
> foo/ForCaller.java:7: for may only be used on an invocation if the method
> was declared with the 'for' modifier
>                for ever() {}
>                    ^
> 1 error
> $
>
>
> Regards,
>
> Mark
>
>



More information about the closures-dev mailing list