[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Axiom-developer] Re: [Aldor-l] [Axiom-math] Are Fraction and Complex do
From: |
Christian Aistleitner |
Subject: |
[Axiom-developer] Re: [Aldor-l] [Axiom-math] Are Fraction and Complex domains. |
Date: |
Tue, 16 May 2006 14:46:31 +0200 |
User-agent: |
Opera Mail/9.00 (Linux) |
Hello,
On Tue, 16 May 2006 00:35:36 +0200, Ralf Hemmecke
<address@hidden> wrote:
| System(): with {
| timestamp: Integer;
| cpuTemperature: Integer;
| } == add {
| timestamp: Integer == { obtain the timestamp somehow }
| cpuTemperature: Integer == { obtain the timestamp somehow }
| }
[...]
| | System: with {
| grabData: () -> %
| timestamp: % -> Integer;
| cpuTemperature: % -> Integer;
| } == add {
| macro Rep == Record( ts: Integer, temp: Integer );
| | grabData(): % == {
| per record( obtain the timestamp somehow, obtain the
temperature | somehow );
| }
| | timestamp( a: % ): Integer == { (rep a) . ts; };
| cpuTemperature( a: % ): Integer == { (rep a) . temp; };
| }
I would also claim the second is better. Christian, if you call the
first System() only once then you wouldn't make it a function, but you
certainly like to call System() several times.
Yes, certainly. Consider the following piece of code:
printSystemStats(): () == {
import from System(), ...;
stdout << cpuTemperature << " " << timestamp << newline;
}
monitor(): () == {
repeat {
printSystemStats();
some code to sleep 10 seconds
}
}
There, System() would get called again and again. Every ten seconds a new
instance.
| To determine the given temperature and timestamp for the system
involves 1 | Function call for non functional Domains and 3 for
functional Domains.
I guess you are wrong.
In the first case, each time you want a time-temperature pair you must
do like...
S == System();
t := timeStamp$S;
T := cpuTemperature$S;
in the second case it is
d := grabData()$System;
t := timeStamp(d)$System;
T := cpuTemperature(d)$System;
So what do you gain?
Again: The first piece of code has one function call ... namely System().
Then obtaining timeStamp and cpuTemperature is getting constants and not
calling functions.
1 function call.
In the second case, grabData() is "calling a function". Same holds for
timeStamp(d) and cpuTemperature.
3 function calls.
In a general setting, calling functions is slow, so we do not want to do
it often.
Again. I am not saying, this is the way to go ... It is just an example,
where non functionality might be usefull.
If I do not have a functional type system, how am I supposed to do
"separate compilation"? How am I supposed to do calls?
[ Ralf clairifying how it can be done ]
Also have in mind, that "with" statements are a anonymous. You can check
whether
Dom: with {
f:() -> ();
g:() -> ();
}
has the f function by
Dom has with { f:() -> (); }
Note that these are two completely different with statements!
But it has to be discussed what "equality of arguments" actually means
in order to be able to speak about the functionality property, since not
every type exports "=: (%, %) -> %".
This is the main point to the whole discussion and the main drawback of
functionality. "How to check equality"?
Even and if everything exports "=", we do not know about the semantics of
"=". We would have to bind them :(.
The interesting part is that with in a purely functional setting we will
also run into troubles soon, when using pointer comparison:
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?
--
Kind regards,
Christian
- [Axiom-developer] Re: [Aldor-l] [Axiom-math] Are Fraction and Complex domains., (continued)
- [Axiom-developer] Re: [Aldor-l] [Axiom-math] Are Fraction and Complex domains., Gabriel Dos Reis, 2006/05/15
- [Axiom-developer] Re: [Aldor-l] [Axiom-math] Are Fraction and Complex domains., Martin Rubey, 2006/05/16
- [Axiom-developer] Re: [Aldor-l] [Axiom-math] Are Fraction and Complex domains., Christian Aistleitner, 2006/05/17
- [Axiom-developer] Re: [Aldor-l] [Axiom-math] Are Fraction and Complex domains., Martin Rubey, 2006/05/17
- [Axiom-developer] Re: [Aldor-l] [Axiom-math] Are Fraction and Complex domains., Christian Aistleitner, 2006/05/17
- [Axiom-developer] Re: [Aldor-l] [Axiom-math] Are Fraction and Complex domains., Stephen Watt, 2006/05/17
- [Axiom-developer] Re: [Aldor-l] [Axiom-math] Are Fraction and Complex domains., Christian Aistleitner, 2006/05/18
- [Axiom-developer] Re: [Aldor-l] [Axiom-math] Are Fraction and Complex domains., Christian Aistleitner, 2006/05/15
- [Axiom-developer] Re: [Aldor-l] [Axiom-math] Are Fraction and Complex domains., Gabriel Dos Reis, 2006/05/15
- [Axiom-developer] Re: [Aldor-l] [Axiom-math] Are Fraction and Complex domains., Ralf Hemmecke, 2006/05/15
- [Axiom-developer] Re: [Aldor-l] [Axiom-math] Are Fraction and Complex domains.,
Christian Aistleitner <=
- [Axiom-developer] Re: [Aldor-l] [Axiom-math] Are Fraction and Complex domains., Ralf Hemmecke, 2006/05/16
- [Axiom-developer] functional type system using pointer comparisons to check equality [was: Re: [Aldor-l] [Axiom-math] Are Fraction and Complex domains.], Christian Aistleitner, 2006/05/16
- [Axiom-developer] Re: [Aldor-l] [Axiom-math] Are Fraction and Complex domains., Christian Aistleitner, 2006/05/16