On Fri, Mar 11, 2011 at 11:06 AM, Martin Baker <[email protected]> wrote:
> On Thursday 10 Mar 2011 16:24:00 Ralf Hemmecke wrote:
>> Hi Martin Baker,
>>
>> maybe you should fix the line
>>
>> https://github.com/hemmecke/fricas-svn/blob/master/src/algebra/scene.spad.p
>> amphlet#L478
>>
>> It's utterly wrong.
>
> I agree, would it be better to say that FriCAS does not support
> subtype polymorphism with late binding or that it does not support
> virtual functions?
>

I think you will agree that the answer is "no", "no", both are
supported. But it is important first to agree on the definitions of
these terms. Do you agree with:

http://en.wikipedia.org/wiki/Subtype_polymorphism

>From my point of view subtype polymorphism is part of the basic design
of Axiom. There are many many repeated examples of this in the Axiom
library.

http://en.wikipedia.org/wiki/Late_binding

Late binding or "duck typing" is done in Axiom via the "Any" domain.
This domain encapsulates all possible domains as one "infinite union".
Try for example:

(1) -> a:=[1,"xxx",3.0]

   (1)  [1,"xxx",3.0]
                                                              Type: List(Any)
(2) -> domainOf(a.1)

   (2)  PositiveInteger()
                                                             Type: OutputForm
(3) -> domainOf(a.3)

   (3)  Float()
                                                             Type: OutputForm
(4) -> a.2::String

   (4)  "xxx"
                                                                 Type: String

The Any domain has it's place but for reasons well explained the
wikipedia article (e.g. "Late binding necessarily prevents the use of
static type checking.") in general the use of Any should be avoided
when possible.  It is almost always better analyze more carefully the
actual types required and to use a much smaller and more specific
Union only when necessary.

> ...
> So taking this particular example, which is a recursive tree structure
> containing a finite number of node types, then:
>
> 1) Is this the best structure to use for this particular scenegraph
> example?
> 2) Is this structure likely to arise often enough in a CAS to be
> concerned
> about?
> 3) When this structure does occur, how best to represent and code it?
>

Data structures with tree structure occur throughout Axiom again "from
the ground up". The Axiom notion of a List is itself is a recursive
structure. For example checkout "RecursiveAggregate" in HyperDoc.

If you don't mind confusing the issue with more abstract
considerations you might like to take a look at:

http://axiom-wiki.newsynthesis.org/SandBoxAldorInductiveTypes

The fact that this code is written in Aldor is not significant. The
same thing can be done in Spad.

Regards,
Bill Page.

-- 
You received this message because you are subscribed to the Google Groups 
"FriCAS - computer algebra system" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/fricas-devel?hl=en.

Reply via email to