ease.js - Tasks: task #12104, Pattern matching
You are not allowed to post comments on this tracker with your current authentication level.
task #12104: Pattern matching
Submitter: | Mike Gerwitz <mikegerwitz> | ||
Submitted: | Sun 10 Jun 2012 03:51:41 AM UTC | ||
Should Start On: | Tue 01 Jan 2013 05:00:00 AM UTC | Should be Finished on: | Thu 01 Aug 2013 04:00:00 AM UTC |
Category: | Core | Priority: | 5 - Normal |
Item Group: | Development | Status: | None |
Privacy: | Public | Assigned to: | mikegerwitz |
Percent Complete: | 0% | Open/Closed: | Open |
Planned Release: | None | ||
Keywords: | pattern matching |
No files currently attached
Depends on the following items: None found
Items that depend on this one: None found
Carbon-Copy List
There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.
No changes have been made to this item
Powered by Savane 3.13-caa5.
Corresponding source code
ease.js will adopt a style of pattern matching that is very similar to Scala's concept of case classes and extractors. Since JavaScript is an Object-Oriented language capable of a number of functional concepts, Scala's implementation seemed like an elegant fit.
While the basic implementation has already been designed, it has yet to be finalized. Due to ease.js's design, it may also be possible to match on any class defined with the framework, not just those defined as case classes or extractors. The deciding factor will be overall performance, since such an implementation could potentially slow down all classes, not just those being matched.
This implementation will include everything you'd expect from pattern matching, including variable assignment and guards. Pattern matching may be used in a style similar to case classes to invoke functions, return an object (similar to Scala's method of variable assignment), create partially applied functions for matching, looping and more.
This implementation would likely render method overloading (not overriding; there's a difference) obsolete. Instead, pattern matching could be used to emulate overloading, much like you'd see in Erlang or Haskell.