[Aldor-l] Boolean known to the Aldor language?

tmgisi at gmx.at tmgisi at gmx.at
Wed Nov 21 16:22:00 EST 2007


Hello Ralf,

On Sat, 17 Nov 2007 17:26:40 +0100, Ralf Hemmecke <ralf at hemmecke.de> wrote:

> Please compile
>
> ---BEGIN bbb.as
> Type: with == add;
> define CatA: Category == with;
> define CatB(A: Type): Category == with {
> 	if A has CatA then CatA;
> }
> ---END bbb.as
>
> via "aldor bbb.as". My compiler (1.1.0) tells me
>
>  >aldor bbb.as
> "bbb.as", line 3: define CatB(A: Type): Category == with {
>                    .......................................^
> [L3 C40] #1 (Fatal Error) Missing vital semantic information: please add
> `import from Boolean' to this scope!

Same situation here. But this constraint to abort with import from Boolean is ... not really necessary. Some more lines below, I show how to bootstrap Aldor without the usual definition of Boolean.

> I somehow have the impression that "Boolean" must be built-in, how else
> would "if" statements be possible? However, Boolean is defined in
> LibAldor or AxlLib.

I guess the name "Boolean" is built-in. Just as with "Category", "Type", ...
But its actual implementation is not too relevant for the compiler.
However, importing from it is required. For no good reason, as Aldor works quite nicely, without the usual definition of the domain Boolean:

---demo.as
Category: with == add;
Type: with == add;

( (A: Tuple( Type )) -> (B: Tuple( Type ))): with {} == add {}
Tuple( A: Type ): with {} == add {};

NamedType: Category == with {
  name: String;
};

Literal: with {} == add {};
String: with {
  string: Literal -> String;
} == add {
  string( lit: Literal ): % == { lit pretend String; };
}

import {
  puts: String -> ()
} from Foreign C;

Boolean: with {
  NamedType;
} == add {
  name: String == "Boolean";
}

import from Boolean;
Wrapper(A: with {}): with {
    if A has NamedType then {
      markerB: String;
    }
    marker: String;
} == add {
  if A has NamedType then {
    markerB: String == "Wrapper with A having NamedType";
  }

  marker: String == {
    if A has NamedType then {
      markerB;
    } else {
      "Wrapper with A __not__ having NamedType";
    }
  }
}

puts( marker$(Wrapper(String)) );
puts( marker$(Wrapper(Boolean)) );
import from String;
if ( Boolean has (with {true: %;}) ) then {
  puts( "The domain Boolean has a notion of true" );
} else {
  puts( "The domain Boolean does __not__ have a notion of true" );
}
---END demo.as

____________________________________________
tmgisi at spencer
cwd: ~/aldor
aldor -Fx -l aldor demo.as && ./demo
Wrapper with A _not_ having NamedType
Wrapper with A having NamedType
The domain Boolean does _not_ have a notion of true


Kind regards,
Christian
-- 
GMX FreeMail: 1 GB Postfach, 5 E-Mail-Adressen, 10 Free SMS.
Alle Infos und kostenlose Anmeldung: http://www.gmx.net/de/go/freemail



More information about the Aldor-l mailing list