diff options
author | Martin Odersky <odersky@gmail.com> | 2004-01-20 14:01:27 +0000 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2004-01-20 14:01:27 +0000 |
commit | f8865bfa8582aeec2a928e29274b37b5e5b57cb7 (patch) | |
tree | d8f4e5b9df4b2be69b670d9997efc82b7c8ebd45 /doc/reference | |
parent | bbadab7e722fd89987f6df1bce6eb3ba9fa93ad0 (diff) | |
download | scala-f8865bfa8582aeec2a928e29274b37b5e5b57cb7.tar.gz scala-f8865bfa8582aeec2a928e29274b37b5e5b57cb7.tar.bz2 scala-f8865bfa8582aeec2a928e29274b37b5e5b57cb7.zip |
*** empty log message ***
Diffstat (limited to 'doc/reference')
-rw-r--r-- | doc/reference/ImplementationStatus.tex | 50 | ||||
-rwxr-xr-x | doc/reference/ProgrammingInScala.tex | 89 | ||||
-rw-r--r-- | doc/reference/ReferencePartAppendix.tex | 203 |
3 files changed, 342 insertions, 0 deletions
diff --git a/doc/reference/ImplementationStatus.tex b/doc/reference/ImplementationStatus.tex new file mode 100644 index 0000000000..f2c74b8695 --- /dev/null +++ b/doc/reference/ImplementationStatus.tex @@ -0,0 +1,50 @@ + +The present Scala compiler does not yet implement all of the Scala +specification. Its currently existing omissions and deviations are +listed below. We are working on a refined implementation that +addresses these issues. +\begin{enumerate} +\item +Unicode support is still limited. At present we only permit Unicode +encodings \verb@\uXXXX@ in strings and backquote-enclosed identifiers. +To define or access a Unicode identifier, you need to put it in +backquotes and use the \verb@\uXXXX@ encoding. +\item +The unicode operator ``$\Rightarrow$'' +(\sref{sec:idents}) is not yet recognized; you need to use the two +character ASCII equivalent ``\code{=>}'' instead. +\item +The current implementation does not yet support run-time types. +All types are erased (\sref{sec:erasure}) during compilation. This means that +the following operations give potentially wrong results. +\begin{itemize} +\item +Type tests and type casts to parameterized types. Here it is only tested +that a value is an instance of the given top-level type constructor. +\item +Type tests and type casts to type parameters and abstract types. Here +it is only tested that a value is an instance of the type parameter's upper bound. +\item +Polymorphic array creation. If \code{t} is a type variable or abstract type, then +\code{new Array[t]} will yield an array of the upper bound of \code{t}. +\end{itemize} +\item +Return expressions are not yet permitted inside an anonymous function +or inside a call-by-name argument (i.e.\ a function argument corresponding to a +\code{def} parameter). +\item +Members of the empty package (\sref{sec:packagings}) cannot yet be +accessed from other source files. Hence, all library classes and +objects have to be in some package. +\item +At present, auxiliary constructors (\sref{sec:constr-defs}) are only permitted +for monomorphic classes. +\item +The \code{Array} class supports as yet only a restricted set of +operations as given in \sref{cls:array}. It is planned to extend that +interface. In particular, arrays will implement the \code{scala.Seq} +trait as well as the methods needed to support for-comprehensions. +\item +At present, all classes used as mixins must be accessible to the Scala +compiler in source form. +\end{enumerate} diff --git a/doc/reference/ProgrammingInScala.tex b/doc/reference/ProgrammingInScala.tex new file mode 100755 index 0000000000..ce88840053 --- /dev/null +++ b/doc/reference/ProgrammingInScala.tex @@ -0,0 +1,89 @@ +\documentclass[a4paper,12pt,twoside,titlepage]{book} + +\usepackage{scaladoc} +\usepackage{fleqn} +\usepackage{modefs} +\usepackage{math} +\usepackage{scaladefs} +\renewcommand{\todo}[1]{} + + + +\ifpdf + \pdfinfo { + /Author (Martin Odersky) + /Title (Programming in Scala) + /Keywords (Scala) + /Subject () + /Creator (TeX) + /Producer (PDFLaTeX) + } +\fi + +\renewcommand{\doctitle}{Programming in Scala\\[33mm]\ } +\renewcommand{\docauthor}{Martin Odersky\\[53mm]\ } + +\begin{document} + +\frontmatter +\makedoctitle +\clearemptydoublepage +\tableofcontents +\mainmatter +\sloppy + +\part{Rationale} + +\input{RationalePart} + +\paragraph{Acknowledgments} +Many people have contributed to the definition and implementation of +the Scala language and to parts of this book. First of all, I would +like to thank the Scala team at EPFL consisting of Philippe Altherr, +Vincent Cremet, Burak Emir, St\'ephane Micheloud, Nikolay Mihaylov, +Michel Schinz, Erik Stenman, and Matthias Zenger. They put a lot of +effort in the Scala compiler, tools, and documentation and have +contributed in an essential way to the specification of the Scala +language through many observations, clever suggestions, and +discussions. Members of the team have also contributed examples in +this book, as well as parts of the specification. Phil Bagwell, Gilad +Bracha, Erik Ernst, Erik Mejer, Benjamin Pierce, Enno Runne, and Phil +Wadler have given very useful feedback on the Scala design. + +The documentation ows a great debt to Abelson's and Sussman's +wonderful book ``Structure and Interpretation of Computer +Programs''\cite{abelson-sussman:structure}. I have adapted several of +their examples and exercises in the ``Scala By Example'' part of this +book. Of course, the working language has in each case been changed +from Scheme to Scala. Furthermore, the examples make use of Scala's +object-oriented constructs where appropriate. + +\part{Scala by Example} + +Scala is a programming language that fuses elements from +object-oriented and functional programming. This part introduces Scala +in an informal way, through a sequence of examples. + +Chapters~\ref{chap:example-one} and \ref{chap:example-auction} +highlight some of the features that make Scala interesting. The +following chapters introduce the language constructs of Scala in a +more thorough way, starting with simple expressions and functions, and +working up through objects and classes, lists and streams, mutable +state, pattern matching to more complete examples that show +interesting programming techniques. The present informal exposition is +complemented by the Scala Language Reference Manual which specifies +Scala in a more detailed and precise way. + +\input{ExamplesPart} + +\part{The Scala Language Specification \\ \ \\ \Large Version 1.0} + +\input{ReferencePart} + +\bibliographystyle{alpha} +\bibliography{Scala} + +\input{ReferencePartAppendix} + + +\end{document} diff --git a/doc/reference/ReferencePartAppendix.tex b/doc/reference/ReferencePartAppendix.tex new file mode 100644 index 0000000000..0f96746779 --- /dev/null +++ b/doc/reference/ReferencePartAppendix.tex @@ -0,0 +1,203 @@ +\appendix +\chapter{Scala Syntax Summary} + +The lexical syntax of Scala is given by the following grammar in EBNF +form. + +\begin{lstlisting} + upper ::= `A' | $\ldots$ | `Z' | `$\Dollar$' | `_' + lower ::= `a' | $\ldots$ | `z' + letter ::= upper | lower + digit ::= `0' | $\ldots$ | `9' + special ::= $\mbox{\rm\em ``all other characters except parentheses ([{}]) and periods''}$ + + op ::= special {special} + varid ::= lower {letter | digit} [`_' [id]] + id ::= upper {letter | digit} [`_' [id]] + | varid + | op + | `\'stringLit + + intLit ::= $\mbox{\rm\em ``as in Java''}$ + floatLit ::= $\mbox{\rm\em ``as in Java''}$ + charLit ::= $\mbox{\rm\em ``as in Java''}$ + stringLit ::= $\mbox{\rm\em ``as in Java''}$ + symbolLit ::= `\'' id + + comment ::= `/*' ``any sequence of characters'' `*/' + | `//' `any sequence of characters up to end of line'' +\end{lstlisting} + +The context-free syntax of Scala is given by the following EBNF +grammar. + +\begin{lstlisting} + Literal ::= intLit + | floatLit + | charLit + | stringLit + | symbolLit + | true + | false + | null + + StableId ::= id + | Path `.' id + Path ::= StableId + | [id `.'] this + | [id '.'] super [`[' id `]']`.' id + + Type ::= Type1 `=>' Type + | `(' [Types] `)' `=>' Type + | Type1 + Type1 ::= SimpleType {with SimpleType} [Refinement] + SimpleType ::= SimpleType TypeArgs + | SimpleType `#' id + | StableId + | Path `.' type + | `(' Type ')' + TypeArgs ::= `[' Types `]' + Types ::= Type {`,' Type} + Refinement ::= `{' [RefineStat {`;' RefineStat}] `}' + RefineStat ::= Dcl + | type TypeDef {`,' TypeDef} + | + + Exprs ::= Expr {`,' Expr} + Expr ::= Bindings `=>' Expr + | Expr1 + Expr1 ::= if `(' Expr1 `)' Expr [[`;'] else Expr] + | try `{' Block `}' [catch Expr] [finally Expr] + | do Expr [`;'] while `(' Expr ')' + | for `(' Enumerators `)' (do | yield) Expr + | return [Expr] + | throw Expr + | [SimpleExpr `.'] id `=' Expr + | SimpleExpr ArgumentExprs `=' Expr + | PostfixExpr [`:' Type1] + PostfixExpr ::= InfixExpr [id] + InfixExpr ::= PrefixExpr + | InfixExpr id PrefixExpr + PrefixExpr ::= [`-' | `+' | `~' | `!'] SimpleExpr + SimpleExpr ::= Literal + | Path + | `(' [Expr] `)' + | BlockExpr + | new Template + | SimpleExpr `.' id + | SimpleExpr TypeArgs + | SimpleExpr ArgumentExprs + ArgumentExprs ::= `(' [Exprs] ')' + | BlockExpr + BlockExpr ::= `{' CaseClause {CaseClause} `}' + | `{' Block `}' + Block ::= {BlockStat `;'} [ResultExpr] + BlockStat ::= Import + | Def + | {LocalModifier} ClsDef + | Expr1 + | + ResultExpr ::= Expr1 + | Bindings `=>' Block + + Enumerators ::= Generator {`;' Enumerator} + Enumerator ::= Generator + | Expr + Generator ::= val Pattern1 `<-' Expr + + CaseClause ::= case Pattern [`if' PostfixExpr] `=>' Block + + Constr ::= StableId [TypeArgs] [`(' [Exprs] `)'] + + Pattern ::= Pattern1 { `|' Pattern1 } + Pattern1 ::= varid `:' Type + | `_' `:' Type + | Pattern2 + Pattern2 ::= [varid `@'] Pattern3 + Pattern3 ::= SimplePattern [ '*' | '?' | '+' ] + | SimplePattern { id SimplePattern } + SimplePattern ::= `_' + | varid + | Literal + | StableId [ `(' [Patterns] `)' ] + | `(' [Patterns] `)' + Patterns ::= Pattern {`,' Pattern} + + TypeParamClause ::= `[' TypeParam {`,' TypeParam} `]' + FunTypeParamClause ::= `[' TypeDcl {`,' TypeDcl} `]' + TypeParam ::= [`+' | `-'] TypeDcl + ParamClause ::= `(' [Param {`,' Param}] `)' + Param ::= [def] id `:' Type [`*'] + Bindings ::= id [`:' Type1] + | `(' Binding {`,' Binding `)' + Binding ::= id [`:' Type] + + Modifier ::= LocalModifier + | private + | protected + | override + LocalModifier ::= abstract + | final + | sealed + + Template ::= Constr {`with' Constr} [TemplateBody] + TemplateBody ::= `{' [TemplateStat {`;' TemplateStat}] `}' + TemplateStat ::= Import + | {Modifier} Def + | {Modifier} Dcl + | Expr + | + + Import ::= import ImportExpr {`,' ImportExpr} + ImportExpr ::= StableId `.' (id | `_' | ImportSelectors) + ImportSelectors ::= `{' {ImportSelector `,'} + (ImportSelector | `_') `}' + ImportSelector ::= id [`=>' id | `=>' `_'] + + Dcl ::= val ValDcl {`,' ValDcl} + | var VarDcl {`,' VarDcl} + | def FunDcl {`,' FunDcl} + | type TypeDcl {`,' TypeDcl} + ValDcl ::= id `:' Type + VarDcl ::= id `:' Type + FunDcl ::= id [FunTypeParamClause] {ParamClause} `:' Type + TypeDcl ::= id [`>:' Type] [`<:' Type] + + Def ::= val PatDef {`,' PatDef} + | var VarDef {`,' VarDef} + | def FunDef {`,' FunDef} + | type TypeDef {`,' TypeDef} + | ClsDef + PatDef ::= Pattern `=' Expr + VarDef ::= id [`:' Type] `=' Expr + | id `:' Type `=' `_' + FunDef ::= id [FunTypeParamClause] {ParamClause} + [`:' Type] `=' Expr + | this ParamClause `=' ConstrExpr + TypeDef ::= id [TypeParamClause] `=' Type + ClsDef ::= ([case] class | trait) ClassDef {`,' ClassDef} + | [case] object ObjectDef {`,' ObjectDef} + ClassDef ::= id [TypeParamClause] [ParamClause] + [`:' SimpleType] ClassTemplate + ObjectDef ::= id [`:' SimpleType] ClassTemplate + ClassTemplate ::= extends Template + | TemplateBody + | + ConstrExpr ::= this ArgumentExprs + | `{' this ArgumentExprs {`;' BlockStat} `}' + + CompilationUnit ::= [package QualId `;'] {TopStat `;'} TopStat + TopStat ::= {Modifier} ClsDef + | Import + | Packaging + | + Packaging ::= package QualId `{' {TopStat `;'} TopStat `}' + QualId ::= id {`.' id} +\end{lstlisting} + +\chapter{Implementation Status} + +\input{ImplementationStatus} + +\end{document} + |