Page Numbers: Yes First Page: 1
Heading:
April 26, 1979 6:36 PM[IVY]<KRL>document>str-lev-mem-comp-decl-old
Units For Compaction Declarations

The following units and associated functionals are used for declarations for compact perspectives.
# InternalKrlObject↑11: HasFunctional(address, WhichIs KrlPointer)
self: A [My type]
address: An Integer
type: MemberOf({CompiledRecord, LispAtom, LispList, LispString, LispNumber})
# CompactRecordInstance↑11: HasFunctional(declaration, CompactFormFor, prototypeUnit)
HasFunctional(prototypeUnit, CompactedBy, declaration)
self: An InternalKrlObject
prototypeUnit: A Unit
declaration: A Unit
fields: SequenceOf(WhichIs KrlPointer)
# CompactRecordDeclaration↑11: HasFunctional(self, CRD, unit, fieldDeclarations)
self: A Unit
unit:A Unit with name = My unitName
unitName: A LispAtom
fieldDeclarations: SequenceOf(A FieldDeclaration with unit = My unit)
compactFields:SequenceOf(A LispAtom)
SequenceMap(My fieldDeclarations,
the slotName from
a FieldDeclaration thatIs thisElement())
# FieldDeclaration
self: <My slotName , My slotForm>
unit: A Unit
slotName: A LispAtom, MemberOf(the slotNames from My unit)
slotForm: Or(MemberOf({LispAtom, LispList, LispString, LispNumber})
<CompactForm, A Unit>
<List , Or(MemberOf({LispAtom, LispList,
LispString, LispNumber})
<CompactForm, A Unit>)>)
Some Simple Examples
These examples contain pairs of units, one of which acts as a template for a compact perspective. Each such unit is linked via the functional CompactedBy to a unit which acts as declaration for the compaction. Following the declaration unit is the Lisp record Declaration which corresponds to the given the KRL-1 declaration.
# StudentProgram↑11: CompactedBy(StudentProgramDeclaration)
studentName: A PersonName
year:An Integer
courses:↑2 SetOf(A CourseSpecifier)2: A GrowingSet
# StudentProgramDeclaration↑11: CompactedFormFor(StudentProgram)
self: A CompactRecordDeclaration with
unitName = ’StudentProgram
fieldDeclarations = <<’studentName, <CompactForm, PersonName>>
<’year, LispNumber>
<’courses, <List, <CompactForm,
CourseSpecifier>>>>
# StudentProgramDeclaration↑11: Comment("An Alternative form for the above unit")
CompactedFormFor(StudentProgram)
self: CRD(StudentProgram,
<<’studentName, <CompactForm, PersonName>>
<’year, LispNumber>
<’courses, <List, <CompactForm, CourseSpecifier>>>>)
(RECORD StudentProgram (type escape studentName year courses)
type ← ’StudentProgram)
# PersonName↑11: CompactedBy(PersonNameDeclaration)
firstName: A LispString
middleName: A LispString
lastName: A LispString
# PersonNameDeclaration↑11: CompactedFormFor(PersonName)
self: A CompactRecordDeclaration with
unitName = ’PersonName
fieldDeclarations = <<’firstName, LispString>
<’lastName, LispString>>
(RECORD PersonName (type escape firstName lastName)
type ← ’PersonName)
# CourseSpecifier↑11: CompactedBy(CourseSpecifierDeclaration)
HasFunctional(self, Course, dept, courseNumber)
dept: Or(Mathematics, English, Astrology)
courseNumber: An Integer
professor: A PersonName
# CourseSpecifierDeclaration↑11: CompactedFormFor(CourseSpecifier)
self: A CompactRecordDeclaration with
unitName = ’CourseSpecifier
fieldDeclarations = <<’dept, <CompactForm Unit>>
<’courseNumber, LispNumber>
<’professor, <CompactForm PersonName>>>
(RECORD CourseSpecifier (type escape dept courseNumber professor)
type ← ’CourseSpecifier)
# CourseRecord↑11: CompactedBy(CourseRecordDeclaration)
course: A CourseSpecifier
courseGrades: SequenceOf↑2(An Integer)2: A Queue
currentAverage:↑3 An Integer3: A ChangingValue
incompleteAssignments:↑4 SetOf(A CourseAssignment)4: WhenAugmented(AugmentDescribe([
the courseGrades from a CourseRecord thatIs !this Description] 0 ))
# CourseRecordDeclaration↑11: CompactedFormFor(CourseRecord)
self: A CompactRecordDeclaration with
unitName = ’CourseRecord
fieldDeclarations = <<’course, <CompactForm CourseSpecifier>>
<’courseGrades, <List, LispNumber>>
<currentAverage, LispNumber>
<incompleteAssignments,
<List <CompactForm, CourseAssignment>>>>
(RECORD CourseRecord (type escape course courseGrades currentAverage incompleteAssignments)
type ← ’CourseRecord)
In all the record declarations above we have shown an explicit escape field which would be used for uncompacted filler pairs and descriptions for compacted fields which did not fit the type declaration. In practice escapes should be very uncommon, and the escape field can be "hidden behind" the type field at the cost of a type check on the type field. If the type field is a list, car would be the type, and cdr the escape; if not, there is only a type and no escape field.

Bootstrapping the Basic Descriptor Forms
An obvious use of the compacting strategy described here is to define units for the basic decriptive forms in KRL-1, and then make declarations for compact perspectives based on those units. The important implication of bottstrapping in this fashion is that all data access in the system would then be done through the basic forms of Seek, Describe and Match, including those for the basic data structures.
Declaration Units for the Basic Descriptor Forms
All we present here are the declarations for the basic descriptor forms. The other slots not mentioned in the declaration will be those which are necessary for the semantics, but which will rarely be needed. They can appear in the escape field as a filler pair. This list is not yet complete.

# UnitDeclaration↑11: CompactedFormFor(Unit)
self: CRD(Unit,
<<’unitName, LispAtom>
<’slots, <List, <CompactForm, Slot>
<’uNotes, <CompactForm, FootNote>>>)

# FootNoteDecalaration↑11: CompactedFormFor(FootNote)
self: CRD(FootNote,
<<metaDescription, <CompactForm, Description>>
<systemNotes, <CompactForm, Description>>>)
# DescriptionDeclaration ↑11: Comment("Union of Descriptor Forms,
each marked with type")
Comment("This is for documentation only, to show shared fileds") CompactedFormFor(Description)
self: CRD(Description,
<<’notes, <CompactForm, FootNote>>
<’type, LispAtom>>>
# PerspectiveDeclaration↑11: CompactedFormFor(Perspective)
self: CRD(Perspective,
<<’notes, <CompactForm, FootNote>>
<’prototype, <CompactForm, Unit>>
<’fillerPairs, <List, <CompactForm PairFiller>>>)

# SpecificationDeclaration↑11: CompactedFormFor(Specification)
self: CRD(Specification,
<<’notes, <CompactForm, FootNote>>
<’slotSpecifier, LispAtom>
<’view, <CompactForm, Perspective>>
<’targetSpecification, Unit>)




Some Easy Cases For Seek, Describe, Match
For a detailed description of the arguments to Seek, Describe, and Match, see the file <bsmith>interparam.bravo which describes the parameters to the Main Interpreter Funtions.
For the examples of the calls, I will use the following instance units based on the Student World units given earlier.
# StudentProgram1
self: A StudentProgram with
studentName = a PersonName with firstName = "Danny"
year = 24
courses = <Course(Astrology, 69)>
# CS2 ↑11: Comment("This will be described as a course below
in Describe examples")

self: A SchoolActivity
Seek Examples

x ← (Seek \the year from a StudentProgram thatIs StudentProgram1/
returning \A Pointer/
allowwing \An AccessOnly)

results in

x ← 24

CLisped (approximately) as

(SETQ x (fetch StudentProgram.year of
(GetCompactPerspective ’StudentProgram ’StudentProgram1)))

***
x ← (Seek \the studentName from a StudentProgram thatIs StudentProgram1/
returning \A Pointer/)

results in x being set to a pointer to the compact perspective for a PersonName and is CLisped (approximately) as

(SETQ x (fetch StudentProgram.studentName of (GetPerspective \StudentProgram \StudentProgram1)))

y ← (Seek \the firstName of a PersonName thatIs !x/ \A Pointer/)

results in

y← "Danny"

and is Clisped approximatelyas

(SETQ y (fetch PersonName.firstName of x))

All the fetches shown here are done with a preliminary type check. If declarations change, all functions which use the declarations must be recompiled or reClisped.
Describe Examples
(Describe \CS1 \Course(English, 312)/)

Clispifies as

(SETQ temp (OR (GetPerspective ’CourseSpecifier ’CS1)
(Create ’CourseSpecifier)))
(temp:CourseSpecifier.dept ← ’English)
(temp:CourseSpeifier.courseNumber ← 312)