init commit again

This commit is contained in:
Peter
2023-11-01 09:29:33 +01:00
parent 448147e7da
commit d6c745207b
250 changed files with 15552 additions and 1 deletions

View File

@@ -0,0 +1,81 @@
### Objects
[
Datatype objects
Funcon object
Funcon object-identity
Funcon object-class-name
Funcon object-feature-map
Funcon object-subobject-sequence
Funcon object-tree
Funcon object-single-inheritance-feature-map
]
Datatype
objects ::= object(_:atoms, _:identifiers, _:environments, _:objects*)
/*
`object( A, C, Env, O*)` is an object:
* distinguished by an atom `A`,
* of a class named `C`,
* with an environment `Env` with the features of the object, and
* a sequence `O*` of subobjects of the direct superclasses of `C`.
`object( A, C, Env)` is an object of a base class.
`object( A, C, Env, O')` is an object of a class with a single superclass.
With multiple inheritance, subobjects due to repeated inheritance of the
same class may be shared.
Implementations of objects generally represent an object as a vector of
fields, and use pointers and offsets for efficient access to individual
fields. The representation of objects used in this specification is
independent of such implementation concerns.
*/
Funcon
object-identity(_:objects) : =>atoms
Rule
object-identity
object(A:atoms, _:identifiers, _:environments, _*:objects*) ~> A
Funcon
object-class-name(_:objects) : =>identifiers
Rule
object-class-name
object(_:atoms, C:identifiers, _:environments, _*:objects*) ~> C
Funcon
object-feature-map(_:objects) : =>environments
Rule
object-feature-map
object(_:atoms, _:identifiers, Env:environments, _*:objects*) ~> Env
Funcon
object-subobject-sequence(_:objects) : =>objects*
Rule
object-subobject-sequence
object(_:atoms, _:identifiers, _:environments, O*:objects*) ~> O*
Funcon
object-tree(_:objects) : =>trees(objects)
/*
`object-tree O` forms a tree where the branches are the object trees for
the direct subobjects of `O`.
*/
Rule
object-tree(O:objects)
~> tree(O,
interleave-map (
object-tree given,
object-subobject-sequence O))
Funcon
object-single-inheritance-feature-map(O:objects) : =>environments
~> map-override left-to-right-map(
object-feature-map given,
single-branching-sequence object-tree O)
/*
For multiple inheritance, different resolution orders can be specified
by using difference linearisations of the object tree.
*/

View File

@@ -0,0 +1,119 @@
---
layout: default
title: "Objects"
parent: Composite
ancestor: Funcons-beta
---
[Funcons-beta] : [Objects.cbs]
-----------------------------
### Objects
<div class="highlighter-rouge"><pre class="highlight"><code>[
<i class="keyword">Datatype</i> <span class="name"><a href="#Name_objects">objects</a></span>
<i class="keyword">Funcon</i> <span class="name"><a href="#Name_object">object</a></span>
<i class="keyword">Funcon</i> <span class="name"><a href="#Name_object-identity">object-identity</a></span>
<i class="keyword">Funcon</i> <span class="name"><a href="#Name_object-class-name">object-class-name</a></span>
<i class="keyword">Funcon</i> <span class="name"><a href="#Name_object-feature-map">object-feature-map</a></span>
<i class="keyword">Funcon</i> <span class="name"><a href="#Name_object-subobject-sequence">object-subobject-sequence</a></span>
<i class="keyword">Funcon</i> <span class="name"><a href="#Name_object-tree">object-tree</a></span>
<i class="keyword">Funcon</i> <span class="name"><a href="#Name_object-single-inheritance-feature-map">object-single-inheritance-feature-map</a></span>
]</code></pre></div>
<div class="highlighter-rouge"><pre class="highlight"><code><i class="keyword">Datatype</i>
<span class="name"><span id="Name_objects">objects</span></span> ::= <span id="Name_object">object</span>(_:<span class="name"><a href="../../../Computations/Normal/Generating/index.html#Name_atoms">atoms</a></span>, _:<span class="name"><a href="../../../Computations/Normal/Binding/index.html#Name_identifiers">identifiers</a></span>, _:<span class="name"><a href="../../../Computations/Normal/Binding/index.html#Name_environments">environments</a></span>, _:<span class="name"><a href="#Name_objects">objects</a></span><sup class="sup">*</sup>)</code></pre></div>
<code><span class="name"><a href="#Name_object">object</a></span>( <i class="var">A</i>, <i class="var">C</i>, <i class="var">Env</i>, <i class="var">O<sup class="sup">*</sup></i>)</code> is an object:
* distinguished by an atom <code><i class="var">A</i></code>,
* of a class named <code><i class="var">C</i></code>,
* with an environment <code><i class="var">Env</i></code> with the features of the object, and
* a sequence <code><i class="var">O<sup class="sup">*</sup></i></code> of subobjects of the direct superclasses of <code><i class="var">C</i></code>.
<code><span class="name"><a href="#Name_object">object</a></span>( <i class="var">A</i>, <i class="var">C</i>, <i class="var">Env</i>)</code> is an object of a base class.
<code><span class="name"><a href="#Name_object">object</a></span>( <i class="var">A</i>, <i class="var">C</i>, <i class="var">Env</i>, <i class="var">O&prime;</i>)</code> is an object of a class with a single superclass.
With multiple inheritance, subobjects due to repeated inheritance of the
same class may be shared.
Implementations of objects generally represent an object as a vector of
fields, and use pointers and offsets for efficient access to individual
fields. The representation of objects used in this specification is
independent of such implementation concerns.
<div class="highlighter-rouge"><pre class="highlight"><code><i class="keyword">Funcon</i>
<span class="name"><span id="Name_object-identity">object-identity</span></span>(_:<span class="name"><a href="#Name_objects">objects</a></span>) : =><span class="name"><a href="../../../Computations/Normal/Generating/index.html#Name_atoms">atoms</a></span>
<i class="keyword">Rule</i>
<span class="name"><a href="#Name_object-identity">object-identity</a></span>
<span class="name"><a href="#Name_object">object</a></span>(<span id="Variable326_A"><i class="var">A</i></span>:<span class="name"><a href="../../../Computations/Normal/Generating/index.html#Name_atoms">atoms</a></span>, _:<span class="name"><a href="../../../Computations/Normal/Binding/index.html#Name_identifiers">identifiers</a></span>, _:<span class="name"><a href="../../../Computations/Normal/Binding/index.html#Name_environments">environments</a></span>, _*:<span class="name"><a href="#Name_objects">objects</a></span><sup class="sup">*</sup>) ~> <a href="#Variable326_A"><i class="var">A</i></a></code></pre></div>
<div class="highlighter-rouge"><pre class="highlight"><code><i class="keyword">Funcon</i>
<span class="name"><span id="Name_object-class-name">object-class-name</span></span>(_:<span class="name"><a href="#Name_objects">objects</a></span>) : =><span class="name"><a href="../../../Computations/Normal/Binding/index.html#Name_identifiers">identifiers</a></span>
<i class="keyword">Rule</i>
<span class="name"><a href="#Name_object-class-name">object-class-name</a></span>
<span class="name"><a href="#Name_object">object</a></span>(_:<span class="name"><a href="../../../Computations/Normal/Generating/index.html#Name_atoms">atoms</a></span>, <span id="Variable405_C"><i class="var">C</i></span>:<span class="name"><a href="../../../Computations/Normal/Binding/index.html#Name_identifiers">identifiers</a></span>, _:<span class="name"><a href="../../../Computations/Normal/Binding/index.html#Name_environments">environments</a></span>, _*:<span class="name"><a href="#Name_objects">objects</a></span><sup class="sup">*</sup>) ~> <a href="#Variable405_C"><i class="var">C</i></a></code></pre></div>
<div class="highlighter-rouge"><pre class="highlight"><code><i class="keyword">Funcon</i>
<span class="name"><span id="Name_object-feature-map">object-feature-map</span></span>(_:<span class="name"><a href="#Name_objects">objects</a></span>) : =><span class="name"><a href="../../../Computations/Normal/Binding/index.html#Name_environments">environments</a></span>
<i class="keyword">Rule</i>
<span class="name"><a href="#Name_object-feature-map">object-feature-map</a></span>
<span class="name"><a href="#Name_object">object</a></span>(_:<span class="name"><a href="../../../Computations/Normal/Generating/index.html#Name_atoms">atoms</a></span>, _:<span class="name"><a href="../../../Computations/Normal/Binding/index.html#Name_identifiers">identifiers</a></span>, <span id="Variable484_Env"><i class="var">Env</i></span>:<span class="name"><a href="../../../Computations/Normal/Binding/index.html#Name_environments">environments</a></span>, _*:<span class="name"><a href="#Name_objects">objects</a></span><sup class="sup">*</sup>) ~> <a href="#Variable484_Env"><i class="var">Env</i></a></code></pre></div>
<div class="highlighter-rouge"><pre class="highlight"><code><i class="keyword">Funcon</i>
<span class="name"><span id="Name_object-subobject-sequence">object-subobject-sequence</span></span>(_:<span class="name"><a href="#Name_objects">objects</a></span>) : =><span class="name"><a href="#Name_objects">objects</a></span><sup class="sup">*</sup>
<i class="keyword">Rule</i>
<span class="name"><a href="#Name_object-subobject-sequence">object-subobject-sequence</a></span>
<span class="name"><a href="#Name_object">object</a></span>(_:<span class="name"><a href="../../../Computations/Normal/Generating/index.html#Name_atoms">atoms</a></span>, _:<span class="name"><a href="../../../Computations/Normal/Binding/index.html#Name_identifiers">identifiers</a></span>, _:<span class="name"><a href="../../../Computations/Normal/Binding/index.html#Name_environments">environments</a></span>, <span id="Variable566_O*"><i class="var">O<sup class="sup">*</sup></i></span>:<span class="name"><a href="#Name_objects">objects</a></span><sup class="sup">*</sup>) ~> <a href="#Variable566_O*"><i class="var">O<sup class="sup">*</sup></i></a></code></pre></div>
<div class="highlighter-rouge"><pre class="highlight"><code><i class="keyword">Funcon</i>
<span class="name"><span id="Name_object-tree">object-tree</span></span>(_:<span class="name"><a href="#Name_objects">objects</a></span>) : =><span class="name"><a href="../Trees/index.html#Name_trees">trees</a></span>(<span class="name"><a href="#Name_objects">objects</a></span>)</code></pre></div>
<code><span class="name"><a href="#Name_object-tree">object-tree</a></span> <i class="var">O</i></code> forms a tree where the branches are the object trees for
the direct subobjects of <code><i class="var">O</i></code>.
<div class="highlighter-rouge"><pre class="highlight"><code><i class="keyword">Rule</i>
<span class="name"><a href="#Name_object-tree">object-tree</a></span>(<span id="Variable657_O"><i class="var">O</i></span>:<span class="name"><a href="#Name_objects">objects</a></span>)
~> <span class="name"><a href="../Trees/index.html#Name_tree">tree</a></span>(<a href="#Variable657_O"><i class="var">O</i></a>,
<span class="name"><a href="../../../Computations/Normal/Giving/index.html#Name_interleave-map">interleave-map</a></span> (
<span class="name"><a href="#Name_object-tree">object-tree</a></span> <span class="name"><a href="../../../Computations/Normal/Giving/index.html#Name_given">given</a></span>,
<span class="name"><a href="#Name_object-subobject-sequence">object-subobject-sequence</a></span> <a href="#Variable657_O"><i class="var">O</i></a>))</code></pre></div>
<div class="highlighter-rouge"><pre class="highlight"><code><i class="keyword">Funcon</i>
<span class="name"><span id="Name_object-single-inheritance-feature-map">object-single-inheritance-feature-map</span></span>(<span id="Variable707_O"><i class="var">O</i></span>:<span class="name"><a href="#Name_objects">objects</a></span>) : =><span class="name"><a href="../../../Computations/Normal/Binding/index.html#Name_environments">environments</a></span>
~> <span class="name"><a href="../Maps/index.html#Name_map-override">map-override</a></span> <span class="name"><a href="../../../Computations/Normal/Giving/index.html#Name_left-to-right-map">left-to-right-map</a></span>(
<span class="name"><a href="#Name_object-feature-map">object-feature-map</a></span> <span class="name"><a href="../../../Computations/Normal/Giving/index.html#Name_given">given</a></span>,
<span class="name"><a href="../Trees/index.html#Name_single-branching-sequence">single-branching-sequence</a></span> <span class="name"><a href="#Name_object-tree">object-tree</a></span> <a href="#Variable707_O"><i class="var">O</i></a>)</code></pre></div>
For multiple inheritance, different resolution orders can be specified
by using difference linearisations of the object tree.
____
From the [PLanCompS Project] | [CBS-beta issues...] | [Suggest an improvement...]
[Objects.cbs]: Objects.cbs
"CBS SOURCE FILE"
[Funcons-beta]: /CBS-beta/docs/Funcons-beta
"FUNCONS-BETA"
[Unstable-Funcons-beta]: /CBS-beta/docs/Unstable-Funcons-beta
"UNSTABLE-FUNCONS-BETA"
[Languages-beta]: /CBS-beta/docs/Languages-beta
"LANGUAGES-BETA"
[Unstable-Languages-beta]: /CBS-beta/docs/Unstable-Languages-beta
"UNSTABLE-LANGUAGES-BETA"
[CBS-beta]: /CBS-beta "CBS-BETA"
[PLanCompS Project]: https://plancomps.github.io
"PROGRAMMING LANGUAGE COMPONENTS AND SPECIFICATIONS PROJECT HOME PAGE"
[CBS-beta issues...]: https://github.com/plancomps/CBS-beta/issues
"CBS-BETA ISSUE REPORTS ON GITHUB"
[Suggest an improvement...]: mailto:plancomps@gmail.com?Subject=CBS-beta%20-%20comment&Body=Re%3A%20CBS-beta%20specification%20at%20Values/Composite/Objects/Objects.cbs%0A%0AComment/Query/Issue/Suggestion%3A%0A%0A%0ASignature%3A%0A
"GENERATE AN EMAIL TEMPLATE"

View File

@@ -0,0 +1,17 @@
general {
funcon-term:
initialise-giving initialise-generating finalise-failing
sequential (
print object-feature-map object(fresh-atom,"A",map()),
print object-feature-map object(fresh-atom,"B",map(),
object(fresh-atom,"C",map()))
)
;
}
tests {
result-term: null-value;
standard-out: [
map(), map()
];
}

View File

@@ -0,0 +1,17 @@
general {
funcon-term:
initialise-giving initialise-generating finalise-failing
sequential (
print object-identity object(fresh-atom,"A",map()),
print object-identity object(fresh-atom,"B",map(),
object(fresh-atom,"C",map()))
)
;
}
tests {
result-term: null-value;
standard-out: [
atom("@1"), atom("@2")
];
}

View File

@@ -0,0 +1,28 @@
general {
funcon-term:
initialise-giving initialise-generating finalise-failing
sequential (
print object-single-inheritance-feature-map
object(fresh-atom,"A",{"a"|->"A"}),
print object-single-inheritance-feature-map
object(fresh-atom,"B",{"a"|->"B"},
object(fresh-atom,"C",{"a"|->"C"})),
else(
is-value object-single-inheritance-feature-map
object(fresh-atom,"D",map(),
object(fresh-atom,"E",map(),
object(fresh-atom,"F",map())),
object(fresh-atom,"G",map())),
print "OK")
)
;
}
tests {
result-term: null-value;
standard-out: [
{"a"|->"A"},
{"a"|->"B"},
"OK"
];
}

View File

@@ -0,0 +1,27 @@
general {
funcon-term:
initialise-giving initialise-generating finalise-failing
sequential (
print [object-subobject-sequence
object(fresh-atom,"A",map())],
print [object-subobject-sequence
object(fresh-atom,"B",map(),
object(fresh-atom,"C",map()))],
print [object-subobject-sequence
object(fresh-atom,"D",map(),
object(fresh-atom,"E",map(),
object(fresh-atom,"F",map())),
object(fresh-atom,"G",map()))]
)
;
}
tests {
result-term: null-value;
standard-out: [
[],
[object(atom("@3"),"C",map-empty)],
[object(atom("@5"),"E",map-empty,object(atom("@6"),"F",map-empty)),
object(atom("@7"),"G",map-empty)]
];
}

View File

@@ -0,0 +1,32 @@
general {
funcon-term:
initialise-giving initialise-generating finalise-failing
sequential (
print object-tree
object(fresh-atom,"A",map()),
print object-tree
object(fresh-atom,"B",map(),
object(fresh-atom,"C",map())),
print object-tree
object(fresh-atom,"D",map(),
object(fresh-atom,"E",map(),
object(fresh-atom,"F",map())),
object(fresh-atom,"G",map()))
)
;
}
tests {
result-term: null-value;
standard-out: [
tree (object(atom("@1"),"A",map-empty)),
tree (object(atom("@2"),"B",map-empty,object(atom("@3"),"C",map-empty)),
tree (object(atom("@3"),"C",map-empty))),
tree (object(atom("@4"),"D",map-empty,
object(atom("@5"),"E",map-empty,object(atom("@6"),"F",map-empty)),
object(atom("@7"),"G",map-empty)),
tree (object(atom("@5"),"E",map-empty,object(atom("@6"),"F",map-empty)),
tree (object(atom("@6"),"F",map-empty))),
tree (object(atom("@7"),"G",map-empty)))
];
}

View File

@@ -0,0 +1,25 @@
general {
funcon-term:
initialise-giving initialise-generating finalise-failing
sequential (
print object(fresh-atom,"A",map()),
print object(fresh-atom,"B",map(),
object(fresh-atom,"C",map())),
print object(fresh-atom,"D",map(),
object(fresh-atom,"E",map(),
object(fresh-atom,"F",map())),
object(fresh-atom,"G",map()))
)
;
}
tests {
result-term: null-value;
standard-out: [
object(atom("@1"),"A",map-empty),
object(atom("@2"),"B",map-empty,object(atom("@3"),"C",map-empty)),
object(atom("@4"),"D",map-empty,
object(atom("@5"),"E",map-empty,object(atom("@6"),"F",map-empty)),
object(atom("@7"),"G",map-empty))
];
}