transparent lambda
Zdenek Tronicek
tronicek at fit.cvut.cz
Mon Jan 4 05:41:40 PST 2010
I think Neal is looking for the SYNTAX. Perhaps he will write more.
Z.
--
Zdenek Tronicek
FIT CTU in Prague
Peter Levart napsal(a):
> I checked the "Jump" and "UnmatchedTransfer" classes in the BGGA
> 2008-08-11 prototype on javac.info. The abstract Jump class has an
> abstract thread() method that returns a thread. I haven't looked into what
> code is generated by the prototype javac in such cases, but I suspect
> javac generates Jump sub-classes for particular non-local transfers. Do
> you perhaps know if there is a document describing the implementation
> details of the prototype regarding non-local transfers?
>
> I may have unknowingly re-spawn the same idea once again, but does the
> BGGA prototype generate code with same semantics as described by Neal when
> he wrote the following:
>
> http://mail.openjdk.java.net/pipermail/closures-dev/2009-December/000506.html
>
> I thought he was looking for a solution of how the desired semantics could
> be implemented.
>
> Peter
>
> On Monday 04 January 2010 12:58:28 Zdenek Tronicek wrote:
>> Did you have a look at the closures prototype? I think you describe the
>> way how non-local transfer is implemented.
>>
>> Z.
>> --
>> Zdenek Tronicek
>> FIT CTU in Prague
>>
>
> P.S. Analogously to the previous non-local return, labeled yield is
> similar but also checks the target of the yield:
>
>
> @Shared #void() y1 = null;
>
> #int() one = #One() {
> if (y1 == null)
> y1 = #(){ yield One: 1; };
>
> y1();
> };
>
> System.out.println(one()); // prints "1"
> System.out.println(one()); // throws exception
>
>
>
> // With following helper class:
>
> public class YieldInt extends RuntimeException {
> public final Object initiatingLambda,
> public final Object targetLambda; // null in case of return from method
> public final int retval;
> public YieldInt(Object initiatingLambda, Object targetLambda, int
> retval) {
> this.initiatingLambda = initiatingLambda;
> this.targetLambda = targetLambda,
> this.retval = retval;
> }
> }
>
>
> // The above could be translated into:
>
> @Shared #void() y1 = null;
>
> class One implements #int() {
> public int invoke() {
> #void() tmp$y1 = null;
> try {
> // #One() body begin
> if (y1 == null) {
> tmp$y1 = new #void()() {
> public void invoke() {
> throw new YieldInt(this, One.this, 1);
> }
> };
> y1 = tmp$y1;
> }
>
> y1();
> // #One() body end
> }
> catch (YieldInt yInt)
> {
> if (yInt.targetLambda == this && (yInt.initiatingLambda == tmp$y1))
> return yInt.retval;
> else
> throw yInt;
> }
> }
> }
>
> #int() one = new One();
>
> System.out.println(one()); // prints "1"
> System.out.println(one()); // throws YieldInt
>
More information about the closures-dev
mailing list