sophiajt / june

MIT License
803 stars 31 forks source link

Feature request: Anonymous functions #69

Open tealeg opened 4 months ago

tealeg commented 4 months ago

Commit: f2107d4

Currently, one must always name a function when defining it, but in the case where we wish to return a function from within a function (or otherwise utilse first class functions) this is inelegant.

Consider the following definition (which will get through codegen, but won't compile - see #68 )

fun areaOfCircle(pie: f64) -> fun(f64) -> f64 {
  fun f(r: f64) -> f64 {
    return pie * (r * r)
  }
  return f
}

Ideally it would look like this:

fun areaOfCircle(pie: f64) -> fun(f64) -> f64 {
  return fun (r: f64) -> f64 {
    return pie * (r * r)
  }
}