MathGroup Archive 2002

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: OO in Mathematica

  • To: mathgroup at smc.vnet.net
  • Subject: [mg37648] Re: OO in Mathematica
  • From: atelesforos at hotmail.com (Orestis Vantzos)
  • Date: Thu, 7 Nov 2002 06:42:28 -0500 (EST)
  • References: <aqb1dj$mih$1@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

Sseziwa Mukasa <mukasa at jeol.com> wrote in message news:<aqb1dj$mih$1 at smc.vnet.net>...
> But what's wrong with defining fields as upvalues of a head indicating 
> the record type?  If you use the model demonstrated by Orestis 
> (unfortunately due to the change in subject lines this thread seems to 
> have split into 4 separate ones) you can inherit structure and methods 
> etc.  I know Orestis used downvalues but I think upvalues would be more 
> efficient.  I'd also change his method to use a symbol without a 
> definition rather than overloading Dot.  If you are using Mathematica 
> you already have to condition yourself to use Map, Fold et al. rather 
> than Do, For, While etc.  What's wrong with using pattern matching for 
> structures instead of tuples?
> 
> Regards,
> 
> Ssezi

The whole idea is going beyond a simple 'record', all the way to a
full fledged object, complete with methods. I used DownValues, because
I think that the message passing mechanism is best pictured in
Mathematica as obj@method[args] rather than as method[obj,args]. What
I mean to say is that the object obj receives the message method[args]
rather than method is applied on {obj,args}, which would be more
functional in style.
There is a major implementation issue related with my use of
DownValues, instead of UpValues. Although the identity of the object
is obvious, the identity of the method is not, given that inheritance
and polymorphism can identify several pieces of code with the same
'method'. It is therefore wise to enclose the 'unstable' part of the
expression (method[args]) with the definite one (obj), incase some
form of processing is needed before the message is actualy evaluated
(in which case you would SetAttributes[onj,HoldAll] ).

Now, on the use of Dot: I perfectly agree with you. Nevertheless bare
in mind that many people tend to visualy identify Dot with OOP. I,
among other people, have been trying to persuade the Mathematica
community that OOP can and should be available to Mathematica programmers. The
use of Dot is a marketing trick, I'm afraid;-) Feel free to use
whatever pleases you..

Orestis Vantzos


  • Prev by Date: Mathematica is NOT a functional language
  • Next by Date: RE: RE: Re: Seemingly simple gridbox question
  • Previous by thread: Re: Re: OO in Mathematica
  • Next by thread: Re: Re: OO in Mathematica