axiom-developer
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Axiom-developer] Re: 1: %


From: Ralf Hemmecke
Subject: [Axiom-developer] Re: 1: %
Date: Wed, 22 Feb 2006 11:57:10 +0100
User-agent: Thunderbird 1.5 (X11/20051201)

On 02/22/2006 12:21 AM, Gabriel Dos Reis wrote:
Ralf Hemmecke <address@hidden> writes:

| > | The problem is the "1: %" as a constant (not a nullary function).
| > The distinction is largely syntactic, not fundamental.
| | I was once told that in Aldor the difference between
|    a: %
| and
|    b: () -> %
| is that
| b() will run a program which might side-effect other things or even
| return something different each time.

expanding on my preivous answer, have a look at the section 5.2 os the
Aldor user guide on literal forming -- you can define your own function
to interpret a string literal as a constant.

I knew about this Literal stuff before...

http://lists.gnu.org/archive/html/axiom-developer/2006-02/msg00154.html

But as you see, if you write a domain that has a function
string: Literal -> %,
it is a function and that means that "1" and "1" need not give identical values.

The following program prints 11 and 12.

-- aldor -laldor -grun domaintest.as
--BEGIN domaintest.as
#include "aldor"
DomainTest: with {
  integer: Literal -> %;
  coerce: % -> Integer;
} == add {
  Rep == Integer;
  local n: Integer := 0;
  integer(l: Literal): % == {
    i: Integer := integer(l)$Integer;
    free n := n + 1;
    per (i + n);
  }
  coerce(x: %): Integer == rep x;
}
main(): () == {
  import from TextWriter, Character, Integer;
  a: DomainTest := 10;
  b: DomainTest := 10;
  stdout << (a::Integer) << newline;
  stdout << (b::Integer) << newline;
}
main();




reply via email to

[Prev in Thread] Current Thread [Next in Thread]