Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

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."
}

```



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

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




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: