axiom-developer
[Top][All Lists]
Advanced

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

RE: [Axiom-developer] Re: SPAD and Aldor again


From: Vanuxem Gregory
Subject: RE: [Axiom-developer] Re: SPAD and Aldor again
Date: Fri, 17 Nov 2006 21:46:37 +0100

Le vendredi 17 novembre 2006 à 13:15 -0500, Bill Page a écrit :
> On November 17, 2006 1:03 PM Vanuxem Gregory
> > 
> > Le vendredi 17 novembre 2006 à 17:17 +0100, Martin Rubey a écrit :
> > 
> > [...]
> > 
> > > I want to get rid of
> > > that stupid ANY workaround in the series domains.
> > 
> > Get rid of ANY almost everywhere.
> > 
> 
> Why get rid of ANY? What is wrong with this idea? A very similar
> idea is used in Java that is often called "type ducking". This
> is a way to have dynamic types in an otherwise statically typed
> language. What is wrong with that?

It's difficult and practically impossible to use it in Spad. In the
interpreter there is no problem, it coerces it for you (not sure
though). For example imagine that you want to emulate dependent type in
Spad:

=================================================================
)abbrev package TEST Test
++ test package
Test(): Exports == Implementation where
  I   ==> integer
  Exports ==> with
    test: (n:Integer,p:Integer) -> Any
    ++ just a test
    withtest: (a:Integer,p:Integer) -> Any
    ++ just anaother test
  Implementation ==> add
    test(n,p) ==
      z := coerce(n::PrimeField(p))$AnyFunctions1(PrimeField(p))
      z
    withtest(a,p) ==
      --b := retract(test(a,p))-- + 9::PrimeField(p)
      t := test(a,p)
      b := retract(t)$AnyFunctions1(PrimeField(p))
      b := b + 8::PrimeField(p)
      coerce(b)$AnyFunctions1(PrimeField(p))
      --coerce(b)$AnyFunction1(PrimeField(p))
=================================================================

Here, in function test, you create a type that depends on one of the
parameter passed to this function. In the second function (withtest) you
don't/can't know what is its real type. You first have to coerce it, but
Spad will not allow you to coerce it (via address@hidden) if its
type is not known at compile time. Here it's possible only because the
prime number is known at compile time (p, a function parameter (again)).

Another example:

(4) -> ((1/4)=(1/4)::ANY)@Boolean

   (4)  false

Greg





reply via email to

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