Skip to content

Commit

Permalink
Merge pull request #16 from jrincayc/fix_12
Browse files Browse the repository at this point in the history
Adding display and newline to specification.
  • Loading branch information
jrincayc authored Sep 11, 2022
2 parents 5403ce8 + e6614c4 commit eb66b95
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 6 deletions.
58 changes: 58 additions & 0 deletions procs.tex
Original file line number Diff line number Diff line change
Expand Up @@ -467,3 +467,61 @@ \section{Control features}
((compose - *) 3 4) \ev -12%
\end{scheme}
\end{entry}

\section{Input and output}

Pico Scheme allows output to a character device. Input is not
specified in this report but an implementation may be extended to
support input. Since expressions are side-effect free, standard Pico
Scheme programs should not perform input or output from expressions
and implementations can require that input or output from them is an
error. Output is only required to be allowed at the outermost level
of a program.

\begin{rationale}
Implementations may choose to allow input and output (IO) from
expressions (like \rsevenrs\ allows) or choose to forbid it. An
implementation that forbids IO side-effects in expressions but
wishes to allow IO in places besides the outermost level would
likely need to extend Scheme in a way that is not compatible with
\rsevenrs.

For example, an implementation could add a command type that allowed
IO, and syntax to create it and then allow {\cf (define displayline
(delta (x) (display x) (newline)))} to define a new command {\cf
displayline}.

Implementations could add a non-expression {\cf do} that allows
IO inside it, similar to \rsevenrs's {\cf do} to support more
flexible IO while remaining a subset of \rsevenrs.

Besides {\cf display} and {\cf newline}, implementations could add
{\cf write-u8}, {\cf (define} \hyper{indentifier} {\cf (read))}, and
{\cf (define} \hyper{identifier} {\cf (read-u8))} to the outermost
level to support more IO. Other IO from \rsevenrs{} can be added if
string or char or port types are added.
\end{rationale}

\subsection{Output}
\label{outputsection}

\begin{entry}{%
\proto{display}{ obj}{input or output}
}

Writes a representation of \var{obj} to the textual output.
For booleans, nulls, numbers, symbols and pairs, this should
be an external representation of the object.
Returns an unspecified value.

\end{entry}

\begin{entry}{%
\proto{newline}{}{input or output}
}

Writes an end of line to textual output. Exactly how this
is done differs
from one operating system to another. Returns an unspecified value.

\end{entry}
2 changes: 1 addition & 1 deletion prog.tex
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ \chapter{Program structure}
\section{Programs}

A Scheme program consists of a sequence of
expressions and definitions.
expressions, definitions and output.
Expressions are described in chapter~\ref{expressionchapter}.
Definitions are variable definitions which are explained in this chapter.
They are valid in some, but not all, contexts where expressions
Expand Down
6 changes: 4 additions & 2 deletions struct.tex
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ \subsection{Base and optional features}
Pico Scheme is already reduced, but if a smaller subset is desired,
either symbols or integers could be removed. Either {\cf cond} or {\cf
if} could be removed. Both {\cf let} and {\cf apply} could be
removed. If extended, it is recommend to use \rsevenrs\ as a
removed. If only a REPL is provided, output could be removed.
If extended, it is recommend to use \rsevenrs\ as a
guide. For cases where both \rsevenrs\ and Pico Scheme are using
defined behavior, it is intended that Pico Scheme should have
identical results.
Expand Down Expand Up @@ -178,6 +179,7 @@ \subsection{Naming conventions}
By convention, \ide{?} is the final character of the names
of procedures that always return a boolean value.
Such procedures are called \defining{predicates}.
Predicates are generally understood to be side-effect free, except that they
Predicates, like all procedures in Pico Scheme, are generally
side-effect free, except that they
may have an error when passed the wrong type of argument.

7 changes: 4 additions & 3 deletions syn.tex
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,9 @@ \subsection{Programs and definitions}

\begin{grammar}%
\meta{program} \:
\> \atleastone{\meta{expression or definition}}
\meta{expression or definition} \: \meta{expression}
\> \| \meta{definition}
\> \atleastone{\meta{expression or definition or io}}
\meta{expression or definition or io} \: \meta{expression}
\> \| \meta{definition} \| \meta{io}
\meta{definition} \: (define \meta{identifier} \meta{expression})
\meta{io} \: (display \meta{identifier}) \| (newline)
\end{grammar}

0 comments on commit eb66b95

Please sign in to comment.