We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Add support for generic functions, to allow things like
fn sqr(x) = x^2
We can go the Rust route and do something like
fn sqr<T>(x: T) -> T^2 = x^2
Or we could add a special syntax for type variables, e.g. $T:
$T
fn sqr(x: $T) -> $T^2 = x^2
Or go the Haskell way and use lowercase expressions as variables:
fn sqr(x: d) -> d^2 = x^2
that could work well with inferred types (#29):
f(x: d0, y: d1, z: d2) -> dR = …
The text was updated successfully, but these errors were encountered:
Generic parameter deduction is definitely not straightforward. Imagine:
fn foo<D>(x: Meter * D^3) -> Scalar = … foo(3 * meter * time^2) // D^3 = time^2 ==> D = time^(2/3)
or even worse:
fn bar<D1, D2>(x: D1 * D2, y: D1, z: D2) -> Scalar = …
This is a potential use case and could probably be supported somehow but maybe we should first disallow this. Or only allow it in the opposite order.
Sorry, something went wrong.
Error cases to consider:
fn foo<Length>(x: Length) = …
fn foo<D1, D2>(x: D1*D2) = …
fn foo<D1>(x: Scalar) -> Scalar = …
Implement generics, see #25
5aa9bfd
No branches or pull requests
Add support for generic functions, to allow things like
Syntax
We can go the Rust route and do something like
Or we could add a special syntax for type variables, e.g.
$T
:Or go the Haskell way and use lowercase expressions as variables:
that could work well with inferred types (#29):
The text was updated successfully, but these errors were encountered: