[Aldor-l] [Axiom-developer] Re: exports and constants

Christian Aistleitner tmgisi at gmx.at
Thu Jul 27 03:20:52 EDT 2006


Hello,

On Wed, 26 Jul 2006 17:36:34 +0200, Page, Bill <Bill.Page at drdc-rddc.gc.ca>  
wrote:

> On Wednesday, July 26, 2006 10:35 AM Ralf Hemmecke wrote:
>> ...
>> I believe reflections are not too complicated once we know
>> how the internal datastructures for domains are. (Yes, yes,
>> we must look inside the compiler sources, or does anybody
>> already have a description of how domains are represented
>> in memory?)
>> ...
>
> I think the documentation that you need for this is Aldor's
> abstract machine layer called FOAM. This is where implementation
> details such as you describe are specified. This abstract
> machine is implemented in Lisp, Scheme, and in a C runtime
> system. I believe that the program code that is generated by
> Aldor before being converted to real machine code is accessible
> in the .asy and .ao files. If we had to parse the output of the
> compiler in order to know what it was doing, then it seems to
> me that this a better and fully portable place to look rather
> Lisp or intermediate C code.

I agree, .asy or Foam is better than C or LISP, for what you are  
considering. But Ralf considered looking into the compiler sources. The  
discussion has now drifted towards "I do not need the sources; I simply  
compile to <some Language> and get the required information by mysolf".  
Thereby, I guess you are barking up the wrong tree.

Assume, you had a domain being able to parse the FOAM code and extract the  
relevant information.
You have to do lots of trickery to get the FOAM code in first place.
You need:
- the compiler
- sources of the object to query
- all necessary include files for the sources
- information where these necessary include files are in the file system
- all necessary library files for the sources
- information where these necessary library files are in the file system
- the correct order in which the libraries have to be passed to the  
compiler
- Knowledge what defines are necessary to get program compiled correctly
- Knowledge what plattform-specific options are necessary to get program  
compiled correctly

probably you'll also need to have the sources of all libraries. (Assume I  
wanted to ask what functions MachineInteger has)

The first of these items is rather trivial -- currently. I guess everybody  
using aldor is a developer and has the compiler at hand.

Would that be really worth the pain?

But assume you solve all these issues -- there is still the assumption  
that you had a domain being able to parse the FOAM code and extract the  
relevant information.
Lots of problems are lukring there as well. For example, if you use  
MachineInteger within the code of interest, the FOAM code would give you  
the declaration
       (GDecl Word "sal_int_AldorInteger_1013410656" -1 4 1 Foam)
You can read off that it's the domain AldorInteger with its magic number  
1013410656. You also know it is defined in sal_int. Assume you somehow  
know that sal_int is in the algebra library. How to guess the "src/arith"  
in the source's filename (src/arith/sal_int.as)? What about extensions of  
AldorInteger?

What you are discussing here is honorable. But its an amazingly huge  
effort.

If Aldor would be freed from it's proprietary trap, you'd be able to look  
up the data structures and work with them directly. Take a look at the  
sources (that came with the compiler some time ago) of the Trace package.  
It's slick. Maybe something similar is possible to achieve "more  
reflection"?
Or maybe even some hackery of the compiler/runtime is necessary?

However, I would hold my horses when it comes to do it with a closed  
compiler. Simply too much trouble.


> [ FOAM ]
> Apparently there is a detailed reference
>
> [6]: Stephen M. Watt and Peter A. Broadbery and Pietro Iglio
> and Scott C. Morrison and Jonathan M. Steinbach,
> FOAM: First Oder Abstract Machine

This repart is a detailed reference. Yes. But it doesn't tell you  
everything. Consider this line of FOAM code
   (Decl Word "TextWriter" -1 4)
. With the help of the paper you'll know that it's a declaration of what's  
called "TextWriter" in Aldor source code. It is of type "Word". But the  
numbers -1 and 4 are still shrouded in darkness (reserved and used by the  
compiler). You get some hints about the 4, if the type (Word) would be Rec  
or Arr. But it is not.

It does not look like it cannot be done, but the cost/benefit ratio is bad.

--
Kind regards,
Christian



More information about the Aldor-l mailing list