-
Notifications
You must be signed in to change notification settings - Fork 1
Description
We're already planning on adding objects and arrays, but we also want union types. Tuples would be cool too. You get union types for free in a dynamically typed language because it's like everything is a union over all types. But if we add static typing, it'll be nice to have discriminated unions. Or if we want to be really cool, we could do non-discriminated unions like type script. But that'd be hard. Structural subtyping would be cool too, but that's a topic for another issue
At any rate, We should make pattern matching constructs like const {x,y} = pointObj in js and tuple unpacking (x,y) = pair if we do tuples. It could all be syntactic sugar. But we should allow for nested stuff like const {x,y as {z, p as (a,b)}} = {x:1,y:{z:2,p:(3,4)}}
We've been meaning to make a desugaring pass anyway, since we're doing inline desugaring in the interpreter for stuff like let x = 2; -> let x; x = 2;. Having a dedicated pass and two AST types would make future passes much easier to implement