axiom-developer
[Top][All Lists]
Advanced

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

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


From: Ralf Hemmecke
Subject: Re: [Aldor-l] [Axiom-developer] Re: exports and constants
Date: Thu, 27 Jul 2006 16:40:53 +0200
User-agent: Thunderbird 1.5.0.4 (X11/20060516)

On 07/27/2006 03:50 PM, root wrote:
> Ralf,
>
> Reflection involves inspecting the internal details of a program.
> A reflection domain would be able to look into other domains for details.
> A reflection domain would export a set of methods like fetchSignatures.
>
> So how would REFLECT get this information?

Let me give you a part of the Trace package...

Trace: with {
        name: Type -> String;
        shortName: Type -> String;
} == add {
        -- from gf_rtime.
        macro DbgTypes == 'assign,entry,exit,dominit';
        macro I == MachineInteger;

        name(T:Type):String == { import from Boolean; name(T, false); }
        shortName(T:Type):String== {import from Boolean; name(T, true);}

        -- horrible hack to get the type name,
        -- at least this avoids linking with langx.as from axllib!
        macro DN == Record(tag:I, p:Pointer);
        local name(T:Type, abbr?:Boolean):String == {
                macro DV == Record(tag:I, namer:Type -> DN);
                macro Dom == Record(dispatcher:DV, domainRep:Type);
                import from DV, Dom;
                dom := T pretend Dom;
                dn := (dom.dispatcher.namer) (dom.domainRep);
                name(dn, abbr?);
        }

        local name(dn:DN, abbr?:Boolean):String == {
                import from List DN;
                dn.tag = 0 => string(dn.p);
                dn.tag = 1 => {
                        ldn := (dn.p) pretend List DN;
                        assert(~empty? ldn);
                        s := string(first(ldn).p) + "(";
                        empty?(ldn := rest ldn) => s + ")";
                        t := { abbr? => "*"; name(first ldn, abbr?) };
                        s := s + t;
                        while ~empty?(ldn := rest ldn) repeat {
                                s := s + ",";
                                t := { abbr? => "*"; name(first ldn, abbr?) };
                                s := s + t;
                        }
                        s + ")";
                }
                empty;
        }
}

The code says it itself... "horrible hack to get the type name".

This code is part of libaldor. And it should NOT be. It should belong to the runtime environment since whenever the compiler changes the representation of domains, the above code will most likely fail.

But suppose something like that would be runtime support.

Then I can simply write

  (name$Trace)(Character)

and get the String "Character" as a result.

Ralf




reply via email to

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