Skip to content

Translating Lambdas #13

Open
Open
@DavePearce

Description

@DavePearce

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions