Re: Re: Set::setps error? Twitter.m's OOP-like approach?
- To: mathgroup at smc.vnet.net
- Subject: [mg104843] Re: [mg104813] Re: Set::setps error? Twitter.m's OOP-like approach?
- From: Daniel Lichtblau <danl at wolfram.com>
- Date: Wed, 11 Nov 2009 04:29:53 -0500 (EST)
- References: <200911030757.CAA01654@smc.vnet.net> <hcr7ps$8th$1@smc.vnet.net> <200911101103.GAA19964@smc.vnet.net>
Erik Max Francis wrote: > Daniel Lichtblau wrote: >> Erik Max Francis wrote: >>> I was experimenting with vaguely OOP-like wrappers around data similar >>> to how Twitter.m does things: >>> >>> http://blog.wolfram.com/2009/04/30/twittering-with-mathematica/ >>> >>> I was experimenting with "mutable objects" and I'm running into a >>> scoping problem of some type that I don't understand. Here's some >>> sample code creating a wrapper around an "account balance": >>> [...hope I'm not snipping too much...] > > Okay. I see that since Mathematica is far more functional a language > than other languages that I've used and so what I was trying to do there > was quite alien -- sufficiently so that I really shouldn't try. (In > this particular case, I was just taking a rather typical OOP example and > playing with it in Python, it wasn't central to my question below ...) I'm not sure why this seems alien. People use such constructs in Mathematica quite often. > [...] > Well, when I boil down when I'm talking about here it's not so much OOP > per se but rather opaque types, giving the ability to pack lots of stuff > in an object, hide it with a nice face by using Format[..., Standard] := > ...., and then define a bunch of functions that take it at the first > argument and manipulate it. > > The context I mentioned above is a tensor library where you don't really > want to see the components of the tensor unless you specifically ask for > it -- a 4-dimensional Riemann tensor, after all, has 4^4 components -- > but instead you just want to specify a set of coordinates, a metric > using those coordinates, and then go to town creating and manipulating > those tensors, then crank out specific calculations based on them. > > Does that make more sense as being something reasonably Mathematica-ish, > using that approach for type opaqueness? Yes. I see no reason not to do that in Mathematica. I won't say it is common, but people do use Mathematica in the way you describe. Often it is for similar reasons: hide the mess, expose the functionality (that may not be an entirely accurate paraphrasing of what you describe, but I think it is not too far from the mark). Daniel Lichtblau Wolfram Research
- References:
- Set::setps error? Twitter.m's OOP-like approach?
- From: Erik Max Francis <max@alcyone.com>
- Re: Set::setps error? Twitter.m's OOP-like approach?
- From: Erik Max Francis <max@alcyone.com>
- Set::setps error? Twitter.m's OOP-like approach?