- About Scala
- Documentation
- Code Examples
- Software
- Scala Developers
Why wasn't 'match' implemented as a method?
Sat, 2010-10-16, 14:07
Sorry if this is a silly question:
Why is it that match was implemented as a special syntax and keyword, and not exposed as a regular method, like say:
// On Any
def match[A](f: PartialFunction[this.type, A]): A
Scala usually tries to avoid special syntax, and allows the language's flexibility to do the rest (ie primitives, arrays, -> tuple creation, ::, etc) -- to my limited understanding it looks like match would have been a good candidate for that too.
Cheers,
Ken
Why is it that match was implemented as a special syntax and keyword, and not exposed as a regular method, like say:
// On Any
def match[A](f: PartialFunction[this.type, A]): A
Scala usually tries to avoid special syntax, and allows the language's flexibility to do the rest (ie primitives, arrays, -> tuple creation, ::, etc) -- to my limited understanding it looks like match would have been a good candidate for that too.
Cheers,
Ken
Mon, 2010-10-18, 22:27
#2
Re: Why wasn't 'match' implemented as a method?
That's interesting. I wondered about the OP's question too. Anyone know what the problems were?
On Sat, Oct 16, 2010 at 1:55 PM, missingfaktor <rahul.phulore.999@gmail.com> wrote:
On Sat, Oct 16, 2010 at 1:55 PM, missingfaktor <rahul.phulore.999@gmail.com> wrote:
It was a method until Scala 2.5. Then they ran into some problems and made it a language construct.
-- Rahul G
-- Rahul G