by phpnode · 7y ago · 0 comments
I would much, much rather that type annotation syntax gets standardised first, because it is comparatively easy to build pattern matching when that's in place but going the opposite direction is difficult. What is a type if not a pattern?
Plus it's a stage1 proposal, meaning it's far from serious.
Could you link the type annotation proposal, I can't find it.
How do you match against a `Buffer` pattern/type?
case (value) {
when { constructor: Buffer } ->
console.log("It's a Buffer!")
}
that doesn't handle subtying though and doesn't work across realms.However I think my point stands that javascript has runtime conceptions of types that go beyond duck typing.