This page is no longer maintained — Please continue to the home page at www.scala-lang.org

Why wasn't 'match' implemented as a method?

2 replies
Ken Scambler
Joined: 2009-11-07,
User offline. Last seen 42 years 45 weeks ago.
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
missingfaktor
Joined: 2010-04-13,
User offline. Last seen 1 year 3 days ago.
Re: Why wasn't 'match' implemented as a method?
It was a method until Scala 2.5. Then they ran into some problems and made it a language construct.
-- Rahul G
Naftoli Gugenheim
Joined: 2008-12-17,
User offline. Last seen 42 years 45 weeks ago.
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:
It was a method until Scala 2.5. Then they ran into some problems and made it a language construct.
-- Rahul G

Copyright © 2012 École Polytechnique Fédérale de Lausanne (EPFL), Lausanne, Switzerland