[Inquiry] Re: Theme One Program -- Commentary Notes

Jon Awbrey jawbrey at oakland.edu
Tue Mar 18 14:04:46 CST 2003


o~~~~~~~~~o~~~~~~~~~o~~~~~~~~~o~~~~~~~~~o~~~~~~~~~o

TOP.  Commentary Note 5

o~~~~~~~~~o~~~~~~~~~o~~~~~~~~~o~~~~~~~~~o~~~~~~~~~o

Here is another batch of low level input-output functions.
Once again observe how I am wrapping all of the primitive
Pascal procedures for doing "read" and "write" operations
inside functional envelopes.  Once this is done, it will
allow us to construct the great majority of more complex
operations by means of functional composition alone.

There is one other thing to note about the Pascal syntax.
Many of the functions below will be declared as follows:

function f (var thou: text;
                this: idea): idea;

This is a function that ostensibly takes text files and ideas over to ideas,
but because the text file is declared as a "var" parameter, it is actually
tantamount to a function from texts and ideas to texts and ideas, in the
sense that calling the function may change the text file in the process.

o~~~~~~~~~o~~~~~~~~~o~~~~~~~~~o~~~~~~~~~o~~~~~~~~~o

Space.

function space (var thou: text;
                    this: idea): idea;
begin
 space := this;  write (thou, blank)
end;

This is a function from texts and ideas to (texts and) ideas.
It acts as the identity on the input idea, with a side-effect
to write a "blank" (space character) to the output text file.

(5197)(7537)

o~~~~~~~~~o~~~~~~~~~o~~~~~~~~~o~~~~~~~~~o~~~~~~~~~o

Skip.

function skip (var thou: text;
                    tab: numb;
                   this: idea): idea;
var col: numb;
begin
 skip := this;  for col := 1 to tab do write (thou, blank)
end;

This is a function from texts, integers, and ideas to (texts and) ideas.
It acts as the identity on the input idea, with a side-effect of writing
the given number of "blanks" (space characters) to the output text file.

(5198)(7538)

o~~~~~~~~~o~~~~~~~~~o~~~~~~~~~o~~~~~~~~~o~~~~~~~~~o

Pass.

function pass (var thou: text;
                   line: info;
                   this: idea): idea;
begin
 pass := this;  write (thou, line)
end;

This is a function from texts, strings, and ideas to (texts and) ideas.
It acts as the identity on the input idea, with a side-effect to write
the given character string to the output text file.

(5199)(7539)

o~~~~~~~~~o~~~~~~~~~o~~~~~~~~~o~~~~~~~~~o~~~~~~~~~o

Turn.

function turn (this: idea): idea;
begin
 turn := this;  writeln
end;

This is a function from ideas to ideas
that acts as the identity on the input,
with a side-effect to write a carriage
return to the console device, thereby
scrolling the screen (or the printer).

(5200)(7540)

o~~~~~~~~~o~~~~~~~~~o~~~~~~~~~o~~~~~~~~~o~~~~~~~~~o

Verse.

function verse (var thou: text;
                    line: info;
                    this: idea): idea;
begin
 verse := this;  writeln (thou, line)
end;

This is a function from texts, strings, and ideas to (texts and) ideas.
It acts as the identity on the input idea, with a side-effect of writing
the given character string and a carriage return to the output text file.

(5201)(7541)

o~~~~~~~~~o~~~~~~~~~o~~~~~~~~~o~~~~~~~~~o~~~~~~~~~o

Return.

function return (var thou: text;
                     this: idea): idea;
begin
 return := this;  writeln (thou)
end;

This is a function from texts and ideas to (texts and) ideas.
It acts as the identity on the input idea, with a side-effect
of writing a carriage return to the output text file.

(5202)(7542)

o~~~~~~~~~o~~~~~~~~~o~~~~~~~~~o~~~~~~~~~o~~~~~~~~~o

Tort.

function tort (this: idea): idea;
begin
 tort := this;  write ('))')
end;

This is a function from ideas to ideas
that acts as the identity on the input,
with a side-effect of writing a pair of
right parentheses to the console device.

This function is left-over from a developmental
stage of the program when it used to write out
its own execution trace, to use in debugging.

(5203)(7543)

o~~~~~~~~~o~~~~~~~~~o~~~~~~~~~o~~~~~~~~~o~~~~~~~~~o

Till.

function till (this: idea): idea;
begin
 till := this;  write (' ... ')
end;

This is a function from ideas to ideas that
acts as the identity on the input idea, and
has the side-effect of writing an "ellipsis"
to the console device (screen or printer).

(5204)(7544)

o~~~~~~~~~o~~~~~~~~~o~~~~~~~~~o~~~~~~~~~o~~~~~~~~~o




More information about the Inquiry mailing list