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
Datatypes would be a generalization of tuples. Nonrecursive datatypes would be translated similar to tuples. Recursive datatypes would be translated similar to classes, but with some kind of reference counting to have automated deallocation. This is possible, because immutable datatypes cannot have cycles, and because datatypes will not be castable to int.
Some examples:
// could replace tuples:
data vec2 = vec2(real x, real y)
// can be generic and have cases:
data option<A> = Some(A a) | None
// can be recursive
data list<A> = Cons(A head, list<A> tail) | Nil
I would use it. But what about standard library using options? we are already missing a lot of obvious stl functions and frequently PRs are a pain for user and maintainer.
Option is super nice but it means that pretty much any STL extension function that uses a handle (unit, item, destructable especially) should have another override for Option, I think.
I don't think this is more harm than good - I think it's nice. Just pointing it out.
Activity
peq commentedon Jul 31, 2014
Of course, datatypes could also replace enums. So the language could get smaller 👍
Cokemonkey11 commentedon Aug 21, 2016
I would use it. But what about standard library using options? we are already missing a lot of obvious stl functions and frequently PRs are a pain for user and maintainer.
Option is super nice but it means that pretty much any STL extension function that uses a handle (unit, item, destructable especially) should have another override for Option, I think.
I don't think this is more harm than good - I think it's nice. Just pointing it out.