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 [EMAIL PROTECTED]) 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



_______________________________________________
Axiom-developer mailing list
[email protected]
http://lists.nongnu.org/mailman/listinfo/axiom-developer

Reply via email to