Hello,

On Tue, 16 May 2006 15:08:16 +0200, Ralf Hemmecke <[EMAIL PROTECTED]> wrote:

DomA( a: List Integer ):with {...} == add {...}
 a: List Integer := [ 1, 2, 3 ];
R == DomA( a );
a . 2 := 300;
S == DomA( a );
a still refers to the same memory location, but it is different. Would R equal S?

Well, here I would comment the following.

a.2 := 300

is the same as

set!(a, 2, 300)

Everyone sees the exclamation mark? This exclamation mark is a _convention_ in Aldor to say that a function is destructive,

Yes.

ie it destroys one of its parameters.

No. It may destroy _all_ of its parameters. But thats not the point.

Since it is hard -- or rather impossible -- for a developer to deceide whether or not a value he returns will be or has been used in a type constructing function, you'd practically forbid using destructive functions at all.
You'd not even be allowed to act destructivly on a value you just copied:

SomeDom: with {
  CopyableType;
  ...
} == add {
  copy( a: % ): % == {
    local copiedValue: %;
    ...
    copiedValue := ...;
    ...
assert( hasBeenProperlyCopied $ ProperlyCopiedHelperDomain( a, copiedValue ) );
    copiedValue;
  }
  ...
}

local a: SomeDom := ...
local b: SomeDom := copy a;
destructiveFunction!( b ); -- b has already been used in via copiedValue in ProperlyCopiedHelperDomain( a, copiedValue ).

So practically no destructive functions...
I wouldn't want to have a functional-type system performing equality checks by comparing pointers. Besides, huge Integers representing the same number most likely do not share the same memory. Besides, Lists of the same integers most likely do not share the same memory. Most "elements of domains", which represent the same value most likely do not share memory. However, they can be used as parameters to domain constructing functions. What would be the worth of "functionality" if it stops there?

--
Kind regards,
Christian


_______________________________________________
Axiom-developer mailing list
[email protected]
http://lists.nongnu.org/mailman/listinfo/axiom-developer

Reply via email to