Kipper-Lang / Kipper

The Kipper programming language for Browsers and Node.js 🦊✨ Made at HTL Leonding & JKU Linz
https://kipper-lang.org
GNU General Public License v3.0
26 stars 4 forks source link

[Feature] Implement `match` operator for matching any type to a type #672

Closed Luna-Klatzer closed 1 month ago

Luna-Klatzer commented 3 months ago

Is there an existing proposal for this?

This feature does not exist in the latest version

Proposal

Implement a match operator which matches any type against an interface. This is a simple wrapper of all the type functionality present in Kipper, which allows the user to match anything against a Kipper type.

This means the following:

As such, match is also not identical to typeof or instanceof. typeof returns obj for every object in the language and as such can not be used to compare interface types, while instanceof is limited to a prototype being present i.e. a class instance being compared to another class.

Exact behaviour / changes you want

Luna-Klatzer commented 1 month ago

Implemented by #692.