Kipper-Lang / Kipper

The Kipper programming language for Browsers and Node.js 🦊✨ Made at HTL Leonding & JKU Linz
https://kipper-lang.org
GNU General Public License v3.0
26 stars 4 forks source link

[Feature] Implement `Func<P..., T>` generic function type and auto function type inference #584

Closed Luna-Klatzer closed 1 month ago

Luna-Klatzer commented 1 month ago

Is there an existing proposal for this?

This feature does not exist in the latest version

Proposal

As with #494 and #499, Kipper aims to support built-in generics and auto-inferred types, which should allow for more complex operations in the language.

This issue more specifically aims to target the topic of a generic function type, which is necessary for saving functions as values in variables and similar. So for example:

def fun(arg1: num) ->  str {
  // ...
}

// Auto-inferred type when referencing the value
fun; // -> Func<num, str>

//  Assignability of a function to a variable
var x: Func<num, str> = fun; // -> Func<num, str>

// Calling the function from the variable
x(1); // -> str

Exact behaviour / changes you want

Luna-Klatzer commented 1 month ago

Implemented by #673.