You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fnadd(a:any,b:any) -> any{ ...}allT{(T f64,T f64) -> T f64 }
This is needed since addition on ad-hoc types is only valid for the same ad-hoc type.
A "none ad-hoc type" is a type f64 which ad-hoc type is T f64.
The all quantifier uses the semantics that "none ad-hoc type" is quantified over. This way, one only needs to write a single rule for all ad-hoc types plus the default case. The normal ad-hoc rule is not involved, since one can simply leave out the case e.g. (f64, f64) -> f64 and use all T { (T f64, T f64) -> T f64 } instead.
The "none ad-hoc type" of the previous arguments is lifted to T. This means that for binary operators, you can leave out ad-hoc type of the left argument and still pass the type check.
fnkm(a:f64) -> km f64{returnclone(a)}fnmain(){println(2 + km(4))// Works fine.
println(km(4) + 2)// ERROR}
The text was updated successfully, but these errors were encountered:
See PistonDevelopers#645
Use the semantics that none ad-hoc type is quantified over by `all`.
- Added `Type::all_ext`
- Added `Type::bind_ty_vars`
- Added `Type::insert_var`
- Added `Type::insert_none_var`
- Added `T` lazy static string
- Added some refine quantifier tests
- Updated `add` in “lib.dyon”
- Updated `add` extra type information
- Added support for type quantifier in syntax
- Push type variable names to “ty” node
For example:
This is needed since addition on ad-hoc types is only valid for the same ad-hoc type.
A "none ad-hoc type" is a type
f64
which ad-hoc type isT f64
.The
all
quantifier uses the semantics that "none ad-hoc type" is quantified over. This way, one only needs to write a single rule for all ad-hoc types plus the default case. The normal ad-hoc rule is not involved, since one can simply leave out the case e.g.(f64, f64) -> f64
and useall T { (T f64, T f64) -> T f64 }
instead.The "none ad-hoc type" of the previous arguments is lifted to
T
. This means that for binary operators, you can leave out ad-hoc type of the left argument and still pass the type check.The text was updated successfully, but these errors were encountered: