|
[Date Index]
[Thread Index]
[Author Index]
Re: Mathematica daily WTF
- To: mathgroup at smc.vnet.net
- Subject: [mg115061] Re: Mathematica daily WTF
- From: kj <no.email at please.post>
- Date: Thu, 30 Dec 2010 04:09:06 -0500 (EST)
- References: <ifcnhn$bai$1@smc.vnet.net> <iff45b$r5s$1@smc.vnet.net>
In <iff45b$r5s$1 at smc.vnet.net> David Bailey <dave at removedbailey.co.uk> writes:
>I can't see why programmers would assume that the attributes of a symbol
>would, or would not, get copied with an assignment, because languages
>like C++ or Fortran don't have any equivalent of attributes. LISP does
>have property lists, and as far as I can remember, these also don't get
>copied with assignment.
OK, perhaps I omitted a step in my argument. Let me clarify.
Mathematica's notion of, and notation for, a symbol's multiple
"associated values" inverts the one that has become commonplace in
mainstream programming through the the object-oriented model: in
this view, instead of writing
Attributes[symbol]
Messages[symbol]
DownValues[symbol]
Options[symbol]
etc.
one would write
symbol.attributes
symbol.messages
symbol.downvalues
symbol.options
etc.
IOW, what Mathematica calls a symbol's various associated values,
in OOP become "encapsulated" as properties (or slots/methods/attributes,
etc) of the "symbol object". (BTW, there's a similar syntactic
inversion in R, so instead of writing list.names one writes
names(list).)
In the OOP view, "cloning a symbol object" would mean copying all
its properties. Hence, coming from an OOP background, it is
surprising to me that writing "B = A" in Mathematica does not copy
all of attributes of A to B.
Yes, even in OOP languages it can be the case that assignment
results in shallow copying, as opposed to deep copying. But
Mathematica's assignment does not produce even a shallow copy.
~kj
Prev by Date:
Behavior of Eigenvalues and Eigensystem
Next by Date:
Re: About TeXForm
Previous by thread:
Re: Mathematica daily WTF
Next by thread:
Re: Mathematica daily WTF
|