diff --git a/procs.tex b/procs.tex index 5bbb178..34f32da 100644 --- a/procs.tex +++ b/procs.tex @@ -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} diff --git a/prog.tex b/prog.tex index bda6396..2724f87 100644 --- a/prog.tex +++ b/prog.tex @@ -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 diff --git a/struct.tex b/struct.tex index ddbb7b5..6c1f551 100644 --- a/struct.tex +++ b/struct.tex @@ -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. @@ -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. diff --git a/syn.tex b/syn.tex index 8780822..584efc0 100644 --- a/syn.tex +++ b/syn.tex @@ -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}