Scheme Semantics: Introduction | Print Statement | Declaration/Assignment Statements | Let Statement | Lambda Statement | Define Statement | If Statement
Remainder of this Paper: Scheme Introduction | Lexer | Parser | Continuations

Scheme Printing (Output)


Scheme is an expression-based functional language. It has no formal output command. When you type any sort of expression, whether it contains integers, a string, a call to a built-in function, or a variable, the interactive Scheme terminal will simply evaluate the expression to the best of its ability and display the answer. If the expression is its most evaluated form, Scheme just echoes the value. For example,


2 => 2
"Hello World" => "Hello World"
'(a b) => (list 'a 'b)
If you type an identifier that has already been defined previously in the current scope, Scheme will return to you the current value, or, in the case of a simple function that's been defined before, the function's identifying name. For example,

(define x 5)

...

x => 5
or


(define square
    (lambda (x) (* x x)))
	
...

square => square

The semantic structure is as follows:
Env_0
I/O_0
	exprlist
	Return: Val_0, ...
	
I/0_1 = I/O_0 + (terminal_output:Val_0, ...)


This construction returns only the evaluation of an expression, which is output to the screen.
Environment doesn't really change here, as no identifier are created or the values bound to them changed. The display statement, good for printing messages, such as error messages, prints only strings and characters found within an object. For example,

(display "(a b c)")		=> (a b c)

(display '("a b" c))	=> (a b c)
The semantic structure of this statement is as follows:

Env_0
I/O_0

( display

	object		;most often a string, but it seems that display parses the characters (tokens) looking for strings
				;and characters only, and prints them to the screen.	
	Return:Val_0		;the string created by the parsing action of the display statement
)
Env_0
I/O_1 = I/O_0 + (terminal_output:Val_0)