- About Scala
- Documentation
- Code Examples
- Software
- Scala Developers
case statement
Wed, 2011-04-27, 17:58
Hi,
Does someone know how case statement is implemented in Scala? Is
"case" a primitive keyword or a function in a library? It's
interesting to see that a group of case statements is an instance of
PartialFunction. I would like to know more details about its
implementation.
Thanks in advance.
Jiansen
Wed, 2011-04-27, 18:27
#2
Re: case statement
On Wednesday April 27 2011, Jiansen wrote:
> Hi,
>
> Does someone know how case statement is implemented in Scala? Is
> "case" a primitive keyword or a function in a library? It's
> interesting to see that a group of case statements is an instance of
> PartialFunction. I would like to know more details about its
> implementation.
>
> Thanks in advance.
>
> Jiansen
It's not library functionality. "case" is a reserved keyword and has
significant portions of the compiler devoted to it and its many forms.
The treatment of a block of cases (when not used with "match") as a
PartialFunction is likewise a special case of a Function literal
handled by the compiler.
The "Compiler Corner" and "Compiler Corner Reloaded" are good starting
points for information on the implementation of the Scala compiler.
It's not a simple thing...
Randall Schulz
Specifically, section 8.5 (page 122)
On 27 April 2011 17:58, Jiansen <jiansenhe@gmail.com> wrote:
--
Kevin Wright
gtalk / msn : kev.lee.wright@gmail.comkev.lee.wright@gmail.commail: kevin.wright@scalatechnology.com
vibe / skype: kev.lee.wrightquora: http://www.quora.com/Kevin-Wright
twitter: @thecoda
"My point today is that, if we wish to count lines of code, we should not regard them as "lines produced" but as "lines spent": the current conventional wisdom is so foolish as to book that count on the wrong side of the ledger" ~ Dijkstra