[Inquiry] Re: Theme One Program -- Commentary Notes
Jon Awbrey
jawbrey at oakland.edu
Tue Mar 18 23:56:33 CST 2003
o~~~~~~~~~o~~~~~~~~~o~~~~~~~~~o~~~~~~~~~o~~~~~~~~~o
TOP. Commentary Note 15
o~~~~~~~~~o~~~~~~~~~o~~~~~~~~~o~~~~~~~~~o~~~~~~~~~o
Peg.
Peg is a generic constructor of idea-to-form flags.
In some areas of math, an edge incident to a node,
or a line incident to a point, is called a "flag".
The function call, here := peg (mark, when, thus, that, this, what),
leaves the idea 'here' pointing to a newly generated form that has
its fields set in turn as follows:
here^.sign := mark
here^.as := when
here^.up := thus
here^.on := that
here^.by := this
here^.code := what
For example, the effect of here := peg ("a", p, q, r, s, 1),
assuming the proper data types, can be indicated as follows:
^ ^ ^
p\|q r|
o-----o s
| a 1 |--->
o-----o
^
here |
@
function peg ( mark: char;
when, thus, that, this: idea;
what: numb): idea;
var here: idea;
begin
new (here); with here^ do
begin
sign := mark;
as := when; up := thus; on := that; by := this;
code := what
end;
peg := here
end;
(5242)(7582)
o~~~~~~~~~o~~~~~~~~~o~~~~~~~~~o~~~~~~~~~o~~~~~~~~~o
Dot.
Dot is a special constructor that
uses the generic constructor Peg
to create an idea-form structure
of the following shape:
o-----o
| ø 0 |
o-----o
^
dot |
@
Notice that Dot generates a form
whose 'sign' field is initialized
as the 'nul' character (#0), here
written "ø".
function dot: idea;
begin
dot := peg (nul, nil, nil, nil, nil, 0)
end;
(5243)(7583)
o~~~~~~~~~o~~~~~~~~~o~~~~~~~~~o~~~~~~~~~o~~~~~~~~~o
Eye.
Eye is a special constructor that
uses the generic constructor Peg
to create an idea-form structure
of the following shape:
o-----o
| 0 |
o-----o
^
eye |
@
Notice that Eye generates a form
whose 'sign' field is initialized
as the blank character (" "), here
left blank.
function eye: idea;
begin
eye := peg (blank, nil, nil, nil, nil, 0)
end;
(5244)(7584)
o~~~~~~~~~o~~~~~~~~~o~~~~~~~~~o~~~~~~~~~o~~~~~~~~~o
Tag.
Tag is a special constructor that
initiates an idea of a form with
a specific character as its sign.
For example, if mark = "a", then tag (mark)
is an initialized idea-form structure with
the letter "a" in the sign field, like so:
o-----o
| a 0 |
o-----o
^
tag |
@
function tag (mark: char): idea;
begin
tag := peg (mark, nil, nil, nil, nil, 0)
end;
(5245)(7585)
o~~~~~~~~~o~~~~~~~~~o~~~~~~~~~o~~~~~~~~~o~~~~~~~~~o
Tog.
Tog is a special constructor that
initiates an idea of a form whose
'as' value is set to a given idea.
For example, if 'this' is given as the argument idea, whether
nil or otherwise, then tog (this) is an initialized idea-form
structure with the 'as' field of the form set equal to 'this',
as shown in the following picture:
^
this \
o-----o
| 0 |
o-----o
^
tog |
@
function tog (this: idea): idea;
begin
tog := peg (blank, this, nil, nil, nil, 0)
end;
(5246)(7586)
o~~~~~~~~~o~~~~~~~~~o~~~~~~~~~o~~~~~~~~~o~~~~~~~~~o
Tip.
Tip is function from keyboard inputs to ideas.
It waits on the user to press a key, normally
in response to a previous prompt, and creates
an idea-form structure that records the event.
The additional degree of complication in the function is
necessary to deal with the way that the readkey function
handles escape sequences in this version of Turbo Pascal.
Case 1. Readkey gets ordinary character.
o-----o
| a 0 |
o-----o
^
tip |
@
Case 2. Readkey gets escape sequence.
o-----o
| a 0 |
o-----o
^
| on
o-----o
| ø 0 |
o-----o
^
tip |
@
function tip: idea;
var here: idea;
begin
here := tag (readkey);
with here^ do if sign = nul then on := tip;
tip := here
end;
(5247)(7587)
o~~~~~~~~~o~~~~~~~~~o~~~~~~~~~o~~~~~~~~~o~~~~~~~~~o
More information about the Inquiry
mailing list