summaryrefslogtreecommitdiff
path: root/doc
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2003-11-28 18:28:10 +0000
committerMartin Odersky <odersky@gmail.com>2003-11-28 18:28:10 +0000
commitee3559b8bd67e39638dd93e1dc832a210c2ac374 (patch)
treef1b0e56d241894a873b3b8020feb02b093eb9bfc /doc
parentdaea8b76a5f9dd35e54f4d524691187850202182 (diff)
downloadscala-ee3559b8bd67e39638dd93e1dc832a210c2ac374.tar.gz
scala-ee3559b8bd67e39638dd93e1dc832a210c2ac374.tar.bz2
scala-ee3559b8bd67e39638dd93e1dc832a210c2ac374.zip
*** empty log message ***
Diffstat (limited to 'doc')
-rw-r--r--doc/reference/ScalaByExample.tex36
-rw-r--r--doc/reference/ScalaReference.tex90
2 files changed, 70 insertions, 56 deletions
diff --git a/doc/reference/ScalaByExample.tex b/doc/reference/ScalaByExample.tex
index c7659ff25c..a5eaf71c41 100644
--- a/doc/reference/ScalaByExample.tex
+++ b/doc/reference/ScalaByExample.tex
@@ -271,6 +271,24 @@ its incoming messages which is represented as a queue. It can work
sequentially through the messages in its mailbox, or search for
messages matching some pattern.
+\begin{lstlisting}[style=floating,label=fig:simple-auction-msgs,caption=Implementation of an Auction Service]
+trait AuctionMessage;
+
+/** make a bid */
+case class Offer(bid: int, client: Actor) extends AuctionMessage;
+
+/** inquire status */
+case class Inquire(client: Actor) extends AuctionMessage;
+
+trait AuctionReply;
+case class Status(asked: int, expiration: Date) extends AuctionReply;
+case object BestOffer extends AuctionReply;
+case class BeatenOffer(maxBid: int) extends AuctionReply;
+case class AuctionConcluded(seller: Actor, client: Actor) extends AuctionReply;
+case object AuctionFailed extends AuctionReply;
+case object AuctionOver extends AuctionReply;
+\end{lstlisting}
+
For every traded item there is an auctioneer process that publishes
information about the traded item, that accepts offers from clients
and that communicates with the seller and winning bidder to close the
@@ -281,22 +299,8 @@ As a first step, we define the messages that are exchanged during an
auction. There are two abstract base classes (called {\em traits}):
\code{AuctionMessage} for messages from clients to the auction
service, and \code{AuctionReply} for replies from the service to the
-clients. These are defined as follows.
-\begin{lstlisting}
-trait AuctionMessage;
-case class
- Offer(bid: int, client: Actor), // make a bid
- Inquire(client: Actor) extends AuctionMessage; // inquire status
-
-trait AuctionReply;
-case class
- Status(asked: int, expiration: Date), // asked sum, expiration date
- BestOffer, // yours is the best offer
- BeatenOffer(maxBid: int), // offer beaten by maxBid
- AuctionConcluded(seller: Actor, client: Actor), // auction concluded
- AuctionFailed, // failed with no bids
- AuctionOver extends AuctionReply; // bidding is closed
-\end{lstlisting}
+clients. For both base classes there exists a number of cases, which
+are defined in Figure~\ref{fig:simple-auction-msgs}.
\begin{lstlisting}[style=floating,label=fig:simple-auction,caption=Implementation of an Auction Service]
class Auction(seller: Actor, minBid: int, closing: Date) extends Actor {
diff --git a/doc/reference/ScalaReference.tex b/doc/reference/ScalaReference.tex
index 9b3c4096c7..c128f40bd6 100644
--- a/doc/reference/ScalaReference.tex
+++ b/doc/reference/ScalaReference.tex
@@ -1577,7 +1577,7 @@ are the base classes of $T$.
The notions of mixin base classes and base classes are extended from
classes to arbitrary types following the definitions of
\sref{sec:base-classes}.
-
+
If two types in the base class sequence of a template refer to the
same class definition, then that definition must define a trait
(\sref{sec:traits}), and the type that comes later in the sequence must
@@ -1626,32 +1626,33 @@ represented by the constructor invocation.
The object resulting from evaluation of a template has directly bound
members and inherited members. Members can be abstract or concrete.
-These are defined as follows.
+For a template $T$ these categories are defined as follows.
\begin{enumerate}
\item
-A {\em directly bound} member is an entity introduced by a member
-definition or declaration in the template's statement sequence. The
+A {\em directly bound} member of $T$ is an entity introduced by a member
+definition or declaration in the $T$'s statement sequence. The
member is called {\em abstract} if it is introduced by a declaration,
{\em concrete} otherwise.
\item
-A {\em concrete inherited} member is a non-private, concrete member of
-one of the template's base classes $B$, except if a member with the
-same \ifqualified{qualified} name is already directly bound in the template, or is
-directly bound in a base class of the template which is a subclass of
-$B$, or is a directly bound, non-private, concrete member of a base
-class which succeeds $B$ in the base class sequence of the template.
+A {\em concrete inherited} member of $T$ is a non-private, concrete member of
+one of $T$'s parent classes, except if a member with the same name is
+already directly bound in $T$ or the member is mixin-overridden in
+$T$. A member $m$ of $T$'s superclass is {\em mixin-overridden} in $T$
+if there is a concrete member of a mixin base class of $T$ which
+either overrides $m$ itself or overrides a member named $m$ of a base
+class of $T$'s superclass.
\item
-An {\em abstract inherited} member is a non-private, abstract member
-of one of the template's base classes $B$, except if a member with the
-same \ifqualified{qualified} name is already directly bound in the template, or is a
-concrete inherited member, or is a directly bound, non-private member
-of a base class which succeeds $B$ in the base class sequence of the
-template.
+An {\em abstract inherited} member of $T$ is a non-private, abstract member
+of one of $T$'s parent classes $P$, except if the template has a
+directly bound or concrete inherited member with the same name, or the
+template has an abstract member inherited from a parent class which
+precedes $P$, and which has the same modifiers and type as the member
+inherited from $P$ would have in $T$.
\end{enumerate}
+It is an error if a template has more than one member with
+the same name.
+
-If two mixin classes of a template each have a concrete member
-with the same name, then the template itself must also declare or
-define a member with the same name.
\comment{
The type of a member $m$ is determined as follows: If $m$ is defined
@@ -1951,9 +1952,9 @@ $t$.
\subsection{Constructor Definitions}
\syntax\begin{lstlisting}
- FunDef ::= this ParamClause `=' ConstrExpr
- ConstrExpr ::= this ArgumentExpr
- | `{' this ArgumentExpr {`;' BlockStat} `}'
+ FunDef ::= this ParamClause`=' ConstrExpr
+ ConstrExpr ::= this ArgumentExprs
+ | `{' this ArgumentExprs {`;' BlockStat} `}'
\end{lstlisting}
A class may have additional constructors besides the primary
@@ -2267,11 +2268,11 @@ module FileSystem with {
| return [Expr]
| throw Expr
| [SimpleExpr `.'] id `=' Expr
- | SimpleExpr ArgumentExpr `=' Expr
+ | SimpleExpr ArgumentExprs `=' Expr
| PostfixExpr [`:' Type1]
PostfixExpr ::= InfixExpr [id]
InfixExpr ::= PrefixExpr
- | InfixExpr id InfixExpr
+ | InfixExpr id PrefixExpr
PrefixExpr ::= [`-' | `+' | `~' | `!'] SimpleExpr
SimpleExpr ::= Literal
| Path
@@ -2280,8 +2281,8 @@ module FileSystem with {
| new Template
| SimpleExpr `.' id
| SimpleExpr TypeArgs
- | SimpleExpr ArgumentExpr
- ArgumentExpr ::= `(' Expr ')'
+ | SimpleExpr ArgumentExprs
+ ArgumentExprs ::= `(' [Exprs] ')'
| BlockExpr
BlockExpr ::= `{' CaseClause {CaseClause} `}'
| `{' Block `}'
@@ -2326,10 +2327,10 @@ character literal denotes a Unicode character. A string literal
denotes a member of \lstinline@scala.Predef.String@.
A symbol literal ~\lstinline@'$x$@~ is a shorthand for the expression
-~\lstinline@scala.Symbol("$x$")@. If the symbol literal is followed by an
-actual parameters, as in ~\lstinline@'$x$($\args\,$)@, then the whole expression
-is taken to be a shorthand for
-~\lstinline@scala.Labelled(scala.Symbol("$x$"), $\args\,$)@.
+~\lstinline@scala.Symbol("$x$")@. If the symbol literal is followed by
+actual parameters, as in ~\lstinline@'$x$($\args\,$)@, then the whole
+expression is taken to be a shorthand for
+~\lstinline@scala.Symbol("$x$", $\args\,$)@.
\subsection{Boolean constants}
@@ -2499,7 +2500,7 @@ trait BorderedColoredShape extends Shape with Bordered with Colored {
\label{sec:apply}
\syntax\begin{lstlisting}
- SimpleExpr ::= SimpleExpr ArgumentExpr
+ SimpleExpr ::= SimpleExpr ArgumentExprs
\end{lstlisting}
An application \lstinline@$f$($e_1 \commadots e_n$)@ applies the function $f$ to the
@@ -2757,7 +2758,7 @@ replaced by the expected type $B$.
\syntax\begin{lstlisting}
PostfixExpr ::= InfixExpr [id]
InfixExpr ::= PrefixExpr
- | InfixExpr id InfixExpr
+ | InfixExpr id PrefixExpr
PrefixExpr ::= [`-' | `+' | `!' | `~'] SimpleExpr
\end{lstlisting}
@@ -2848,7 +2849,7 @@ the expression is the value of $e$ converted to type $T$.
\syntax\begin{lstlisting}
Expr1 ::= Designator `=' Expr
- | SimpleExpr ArgumentExpr `=' Expr
+ | SimpleExpr ArgumentExprs `=' Expr
\end{lstlisting}
The interpretation of assignment to a simple variable ~\lstinline@$x$ = $e$@~
@@ -4233,11 +4234,11 @@ grammar.
| return [Expr]
| throw Expr
| [SimpleExpr `.'] id `=' Expr
- | SimpleExpr ArgumentExpr `=' Expr
+ | SimpleExpr ArgumentExprs `=' Expr
| PostfixExpr [`:' Type1]
PostfixExpr ::= InfixExpr [id]
InfixExpr ::= PrefixExpr
- | InfixExpr id InfixExpr
+ | InfixExpr id PrefixExpr
PrefixExpr ::= [`-' | `+' | `~' | `!'] SimpleExpr
SimpleExpr ::= Literal
| Path
@@ -4245,10 +4246,9 @@ grammar.
| BlockExpr
| new Template
| SimpleExpr `.' id
- | id `#' id
| SimpleExpr TypeArgs
- | SimpleExpr ArgumentExpr
- ArgumentExpr ::= `(' Expr ')'
+ | SimpleExpr ArgumentExprs
+ ArgumentExprs ::= `(' [Exprs] ')'
| BlockExpr
BlockExpr ::= `{' CaseClause {CaseClause} `}'
| `{' Block `}'
@@ -4344,8 +4344,8 @@ grammar.
ClassTemplate ::= extends Template
| TemplateBody
|
- ConstrExpr ::= this ArgumentExpr
- | `{' this ArgumentExpr {`;' BlockStat} `}'
+ ConstrExpr ::= this ArgumentExprs
+ | `{' this ArgumentExprs {`;' BlockStat} `}'
CompilationUnit ::= [package QualId `;'] {TopStat `;'} TopStat
TopStat ::= {Modifier} ClsDef
@@ -5033,3 +5033,13 @@ package scala.List[a extends Comparable[a]] with Comparable[List[a]] with {
}
+
+}
+\end{lstlisting}
+}
+
+
+nd{lstlisting}
+}
+
+