[Aldor-l] rep, per, Rep in SPAD/Aldor

Christian Aistleitner tmgisi at gmx.at
Sat Jul 14 03:41:53 EDT 2007


Hello,

On Fri, 13 Jul 2007 13:57:16 +0200, Ralf Hemmecke <ralf at hemmecke.de> wrote:

> In Aldor we write
>
> Foo: with {
>    coerce: Integer -> %;
>    test?: % -> Boolean;
> } == add {
>    Rep == String;
>    ...
> }
>
> and mean something like
>
>    Foo = ((%, Integer, Boolean), (coerce, test?))
>
> in the multisorted algebra sense. We don't actually make Integer and
> Boolean (not String) an argument to Foo or "with", they are implicit.

I understand why String is not an (implicit) Parameter of the with part.
I am rather convinced that it's not of importance, but why isn't String an  
implicit parameter of Foo (which is made up of the with _and_ the add  
part)?

> Now let us look to the "add" part. There we have yet another domain,
> namely Rep. Inside "add" we actually consider an algebra like
>
>    Foo' = ((%, Rep, Integer, Boolean), (coerce, test?, per, rep))
>
> Hmmm, I have just cooked that all up right now, but it seems a pretty
> coherent view on domains.

I am not too sure whether I can follow you here.
I assume you want us to assume "per" and "rep" occur in the code you gave  
for Foo some lines above.

Then by just looking at the syntax, I'd have to agree.
However, languages allowing macros typically act in two stages. One of  
which is macro expansion/replacement.
In Aldor this is somehow hidden from the user--in languages like C, it is  
more vivid.

Before macro expansion, I'd roughly agree with your signatures. But after  
macro expansion, I'd expect to get

     Foo' = ((%, Rep, Integer, Boolean), (coerce, test?))

. And that is just what you get when using the interactive loop:

> aldor -gloop
> %1 >> #include "aldor"
> %2 >> #include "aldorinterp"
> %3 >> add {Rep==String;coerce(z:Integer):%==per
> "int";test?(x:%):Boolean==true}
>    () @  with
>          Rep: ? == String
>          coerce: (z: AldorInteger) -> %
>          test?: (x: %) -> Boolean

No sign of rep and per, as the interpreter has expanded the macros for you.
rep and per are not functions to me. They are rewrite rules. IMHO, they  
(and the other macros) act on a meta level, when looking at the Aldor  
language.

> That is pretty close, but lacks per and rep. Gaby, I think that is one
> point for you. Here I would like to see rep,per, Rep. Don't you agree?

I do not agree.

> But note if we export Rep, we somehow are in conflict with "hiding the
> representation".

No we are not.
We are exporting a constant Rep.
But you are also exporting two other constants as well, namely coerce and  
test?.

Why should Rep be the representation of the domain and not coerce or test?  
?

Rep is nothing special. In your previous example you used Ying instead of  
Rep.
The export of Rep, Ying, or whatever does not tell "This domain uses this  
representation". It just tells you "This domains exports a Symbol with  
name Rep, Ying, or whatever".
A name is just a name.

Kind regards,
Christian




More information about the Aldor-l mailing list