[Aldor-l] Re: Aldor %% bindings
Ralf Hemmecke
ralf at hemmecke.de
Wed Mar 15 05:13:19 EST 2006
On 03/14/2006 09:56 AM, Page, Bill wrote:
> Ralf, and other Aldor experts;
>
> Section "7.5 Subtypes" of the Aldor Users Guide says:
>
> Note that Aldor is constructed so that a domain is only a
> member of a named category if it explicitly inherits from
> the category -- not if it merely exports the same collection
> of (explicit) declarations\1.
> Footnote \1 says:
>
> In the current implementation, each named category C
> implicitly exports a symbol named \%%" with type C (see
> Section 8.12), whose presence is tested for in checking
> category membership.
>
> Note: 8.12 is a typo. It should say 8.11.
>
> Section "8.11 With" says::
>
> A 'with' expression also defines a constant named "%%" for
> each category from which the 'with' expression inherits.
> The type of %% is the inherited category, and the value
> is the domain viewed as a member of that category...
> The %% bindings are generally most useful for checking
> conditions.
>
> -------
>
> Can anyone explain the usage of %% and give some examples
> where it is used to "check conditions"?
For example "has" constructs, but I don't know if there is anything else.
#include "aldor"
define CatDummy: Category == PrimitiveType with {foo: () -> ()}
If you compile this with via "aldor -fasy aaa.as" then you get
something like that ...
((|Declare|
|CatDummy|
(|Define|
(|Declare| (|Label| |CatDummy| ()) |Category|)
(|With|
|PrimitiveType|
(|Declare|
|foo|
(|Apply| -> (|Comma|) (|Comma|))))))
((|catExports|
(|Declare|
=
(|Apply| -> (|Comma| % %) |Boolean|))
(|Declare|
~=
(|Apply| -> (|Comma| % %) |Boolean|)
((|default| . 1))
(|Declare|
%%
|PrimitiveType|)
(|Declare|
|foo|
(|Apply| -> (|Comma|) (|Comma|)))
(|Declare|
%%
|CatDummy|)))))
To make it shorter here, I have removed some
((|symeNameCode| . 243941740) (|symeTypeCode| . 83337439)) stuff.
What you see is that the Category CatDummy, not only exports %% for
PrimitiveType but also %% for CatDummy.
As I understand this... apart from encoding the category hierarchy in
that way it also could make the evaluation of "DOM has CatDummy" faster
since the need only be a lookup whether there is some %% for CatDummy.
No check for all the corresponding exported functions is necessary. (Am
I wrong?)
> What does it mean to be a "domain viewed as a member of
> a specific category"?
I have only seen %% in places as above. So I have no idea what that
could mean. Maybe it is used in conditional exports, I haven't checked that.
> Apparently %% can have multiple bindings. About the
> example in section 8.11 we read that:
>
> In the example, %% bindings are in scope for the
> following categories:
> BinaryAggregate, BooleanArithmeticType,
> BoundedFiniteLinearStructureType Boolean,
> BoundedFiniteDataStructureType Boolean,
> FiniteLinearStructureType Boolean, PrimitiveType,
> and so on.
>
> How can I access the value (associated domain?) of a
> particular binding?
>
> Any hints about how to understand this would be greatly
> appreciated.
Maybe Stephen Watt or Peter Broadbery could help.
Ralf
More information about the Aldor-l
mailing list