Hacker News new | ask | show | jobs
by mirekrusin 3472 days ago
I agree, the next missing bit is runtime structural typing (not optional of course) that allows constructs like:

```

const whatIsFoo = match (foo) {

  case : nil : "nothing, really"

  case : string : "it's a string"

  case : number | boolean : "it's bool or number"

  case [ head, ...tail ] : string[] : `it's array of strings with head ${head} and tail ${tail.join(', ')}` 

  case { value } : { type: 'NodeFoo' } : `it's Node Foo with value ${value}`

  default: "well, something else."
}

```

1 comments

If only there were a decades-old system that allowed that[1]

1: https://en.wikipedia.org/wiki/Common_Lisp_Object_System