In article
<da297d6d-0115-4c19-83dd-c316a2449fbd@[EMAIL PROTECTED]
>,
Xah Lee <xah@[EMAIL PROTECTED]
> wrote:
....
I think you are seriously confused when it comes to programming
language models. Don't take that offensive, just as a recommendation
to clear up basic things like: 'expression', 'object', 'process',
'interpretation'. Part of that may come from that Mathematica only
has a weak specification of the core programming language.
> Thanks Rainer and others for correcting some errors about my statement
> of lisp's "list" and "quote" in relation to the read/print syntax.
> (and thanks Rainer for the technical exposition on lisp's objects)
>
> Rainer wrote:
> 「What are two lists then internally if you read them? Define two
> variables. Set both to some lists. What are these lists now? Say you
> pass one of these lists to a function. Does the function get a copy?
> The same? Don't know? If you print the Mathematica list and then read
> it back. What do you get? A new list (Why?)? The old list? Don't
> know? What with symbols. Print a symbol. Read the symbol? Is it a
> different symbol? The same? Don't know?」
>
> I don't quite understand your questions.
>
> One way to understand Mathematica is by the so-called term-rewriting
> and or graph-rewriting of computer "scientist". When you think of
> these computing models, you'll see that there's no "behind the
> scenes" language model like Lisp's Objects, or Java's Objects and
> References and other types, or C's pointers... etc,
Of course there is. Term Rewriting is only part of the story
in Mathematica. Mathematica has control constructs,
functions and all kind of weird stuff.
What is a Term? A Term is recursively
defined as either a object or a construct with subterms.
Objects are symbols, strings, numbers, lists, and so on.
There are also functions and 'pure function' (like
anonymous functions in Lisp). You can creare
lists of functions, just like in Lisp.
A Mathematica runtime system is quite similar
to what a Lisp system does.
Example:
Find the equivalent
in Mathematica (which has functions, global variables,
local variables, data constructors, mutable data structures,
Set, Equal, SameQ, List, ...) for the following:
You can set global variables with values:
(setf foo1 'bar)
You can define functions with parameters and code:
(defun foo (a)
(list a a))
You can call functions:
(foo foo1)
You get results from these functions.
(foo foo1) -> (bar bar)
see below for more
>
> 「Say you pass one of these lists to a function. Does the
function get
> a copy? 」
>
> Think of term-writing, then its easy to see that in Mathematica, with
> respect to the so-called "getting a copy" "behind-the-scenes" concepts
> in most computer languages, then Mathematica does gets a copy, and
> always.
That's not true. If you set the nth element of an list,
the original list will be modified. Not a copy.
If you pass that list around and change it, the original
list will be modified. Not a copy.
See above. The list (bar bar). What are the symbols?
are they copies of the symbols or is there just one
symbol and the list points to them from two places?
Do the equivalent to the following in Mathematica:
(setf bar1 (list 'bar-symbol))
(setf bar2 (foo bar1))
(print bar2)
(setf (first bar1) 'new-bar-symbol)
(print bar1)
(print bar2)
Now, what does bar2 print? Is bar2 changed or not?
See also:
http://reference.wolfram.com/mathematica/tutorial/MakingListsOfObjects.html
http://reference.wolfram.com/mathematica/tutorial/PrinciplesOfEvaluation.html
Also note that above uses the word 'object'.


|