Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Translating Lambdas #13

Open
DavePearce opened this issue Sep 25, 2017 · 0 comments
Open

Translating Lambdas #13

DavePearce opened this issue Sep 25, 2017 · 0 comments

Comments

@DavePearce
Copy link
Member

Currently, the following fails:

type fun is function(int)->int

function suc(int i) -> int:
    return i + 1

public export method test():
    fun x = &suc
    assume x(41) == 42

This generates the following java:

import java.math.BigInteger;
import java.util.Arrays;
import java.util.function.Function;
public final class AddressExpression_Valid_1 {
	static BigInteger suc(BigInteger i) {
		return i.add(BigInteger.valueOf(1L));
	}
	public static void test() {
		Function x = (BigInteger p0) -> suc(p0);
		assert x.apply(BigInteger.valueOf(41L)).equals(BigInteger.valueOf(42L));
	}
}

This is pretty close to working, except that Function needs to have the appropriate generic types given.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant