Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 0 additions & 38 deletions documentation/src/reference/ReferencePart.tex
Original file line number Diff line number Diff line change
Expand Up @@ -2507,44 +2507,6 @@ \subsection{Repeated Parameters}\label{sec:repeated-params}
sum(xs: _*)
\end{lstlisting}

\subsection{Procedures}\label{sec:procedures}

\syntax\begin{lstlisting}
FunDcl ::= FunSig
FunDef ::= FunSig [nl] `{' Block `}'
\end{lstlisting}

Special syntax exists for procedures, i.e.\ functions that return the
\verb@Unit@ value \verb@()@.
A procedure declaration is a function declaration where the result type
is omitted. The result type is then implicitly completed to the
\verb@Unit@ type. E.g., ~\lstinline@def $f$($\ps$)@~ is equivalent to
~\lstinline@def $f$($\ps$): Unit@.

A procedure definition is a function definition where the result type
and the equals sign are omitted; its defining expression must be a block.
E.g., ~\lstinline@def $f$($\ps$) {$\stats$}@~ is equivalent to
~\lstinline@def $f$($\ps$): Unit = {$\stats$}@.

\example Here is a declaration and a definition of a procedure named \lstinline@write@:
\begin{lstlisting}
trait Writer {
def write(str: String)
}
object Terminal extends Writer {
def write(str: String) { System.out.println(str) }
}
\end{lstlisting}
The code above is implicitly completed to the following code:
\begin{lstlisting}
trait Writer {
def write(str: String): Unit
}
object Terminal extends Writer {
def write(str: String): Unit = { System.out.println(str) }
}
\end{lstlisting}

\subsection{Method Return Type Inference}\label{sec:meth-type-inf}

\comment{
Expand Down
3 changes: 1 addition & 2 deletions documentation/src/reference/SyntaxSummary.tex
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ \chapter{Scala Syntax Summary}\label{sec:syntax}

ValDcl ::= ids `:' Type
VarDcl ::= ids `:' Type
FunDcl ::= FunSig [`:' Type]
FunDcl ::= FunSig `:' Type
FunSig ::= id [FunTypeParamClause] ParamClauses
TypeDcl ::= id [TypeParamClause] [`>:' Type] [`<:' Type]

Expand All @@ -255,7 +255,6 @@ \chapter{Scala Syntax Summary}\label{sec:syntax}
VarDef ::= PatDef
| ids `:' Type `=' `_'
FunDef ::= FunSig [`:' Type] `=' Expr
| FunSig [nl] `{' Block `}'
| `this' ParamClause ParamClauses
(`=' ConstrExpr | [nl] ConstrBlock)
TypeDef ::= id [TypeParamClause] `=' Type
Expand Down