Whiley / RFCs

Request for Comment (RFC) proposals for substantial changes to the Whiley language.
3 stars 2 forks source link

Lambda Types Addendum #103

Open DavePearce opened 2 years ago

DavePearce commented 2 years ago

Overview

We desire a way to state that a lambda type is fat. For example, this currently compiles:

type fun_t is function()->(int)

function f(int x) -> fun_t:
   return &( -> x)

This is broken because we don't know how to compile the lambda!! It's actually a fat lambda.

Statically Sized (a.k.a. "Fat") Lambdas

A more appropriate type above would be:

type fun_t is function[int]()->(int)

Here, [int] indicates additional types required in the "lambda package". Rust has a similar problem here, but does not allow you to name such lambdas.

Dynamically Sized Lambdas

Another interesting question then is what &fun_t represents in both situations above. Perhaps we need syntax such as function[...]()->(int) to indicate a fat lambda of unknown size.