axiom-math
[Top][All Lists]
Advanced

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

[Axiom-math] Re: [Axiom-mail] Dynamically constructed return types


From: Martin Rubey
Subject: [Axiom-math] Re: [Axiom-mail] Dynamically constructed return types
Date: Mon, 10 Jan 2005 17:57:42 +0100

Dear Marcus,

Marcus Better writes:
 > Martin,
 > 
 > >   with {f:(n:Integer)->IntegerMod(hairyfunction(n)) }
 > > 
 > > which would fit your case exactly, I suspect.
 > 
 > That's impressive. I think however that it will be too complicated for me to
 > start looking at Aldor at this point.

Aldor is not that much of a problem: the languages are nearly identical. You
can even use the "pile" syntax, used in spad. The following will probably look
more familiar to you:

#pile

Foo(): Exports == Implementation where

  Exports == with
    
    f:(n:Integer)->IntegerMod(n) 

  Implementation == add

    f(n:Integer):IntegerMod(n) == coerce(10)$IntegerMod(n)

This is perfectly valid Aldor, too. (modulo typos)

 > > With every Category, there is also a Domain containing only the default
 > > operations, you get it by appending an (within spad: escaped) ampersand.
 > 
 > Interesting, I did not know that. So this is a kind of "abstract base
 > class". It's a bit surprising that it cannot be used as such. 

You can use it for package calling. I.e., if the function is implemented in the
category -- as "default" implementation -- you can use it.

 > > Maybe you can use a type that contains all elements of
 > > SimpleAlgebraicExtension?
 > 
 > Perhaps I will just inline the functions, and do without function calls.
 > This will be ugly since I will have to do without recursion, but it looks
 > like the simplest solution.

I don't understand, but this is probably due to my ignorance...

Martin





reply via email to

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