Mathematica 9 is now available
Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2005
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2005

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

Search the Archive

Re: UML-like diagrams for Mathematica

  • To: mathgroup at smc.vnet.net
  • Subject: [mg63042] Re: UML-like diagrams for Mathematica
  • From: "Steven T. Hatton" <hattons at globalsymmetry.com>
  • Date: Sun, 11 Dec 2005 22:25:16 -0500 (EST)
  • References: <dnbn24$5ru$1@smc.vnet.net><dned04$t4s$1@smc.vnet.net> <dngv71$nc2$1@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

Chris Chiasson wrote:

> One problem with trying to find structure in symbols is that rules
> which can only work with a certain symbol may not even be associated
> with that symbol.
> 
> cf: y[x]=expr ... the rule is only "associated" with y, but will only
> work if both y and x are present.

This is correct.  But they are inevitably associated with /some/ Symbol
(AFAIK).  You could easily write a program that examined all Symbols
currently visible to see if they have a rule applying to one Symbol in
particular.

> It seems like symbols don't have any structure besides context (the
> stuff in front of `) (I would guess symbols themselves are Atomic).

They are Atomic. Nonetheless, they (appear to) have a lot of internal
structure.
 
> My guess is that a symbol is really "defined by" what rules are
> eventually applied to it.

What the evaluator does is basically traverse the expression in depth first
order, left to right.  As it encounters each node (expression) in the tree,
it examines it to find out what attributes and values it has.  The values
are actually transformation rules of one form or another.

This is a very condensed explanation of what happens:
http://documents.wolfram.com/mathematica/book/section-A.4.1


The following are the attributes of a Symbol.  I don't consider attributes
to be present or absent.  I view them to be set or unset. (true or false, 1
or 0)

http://documents.wolfram.com/mathematica/book/section-2.6.3
Orderless
Flat
OneIdentity
Listable
Constant
NumericFunction
Protected
Locked
ReadProtected
HoldFirst
HoldRest
HoldAll
HoldAllComplete
NHoldFirst
NHoldRest
NHoldAll
SequenceHold
Temporary
Stub

These are the types of values associated with symbols.
http://documents.wolfram.com/mathematica/book/section-A.5.3

Attributes
DefaultValues
DownValues
FormatValues
Messages
NValues
Options
OwnValues
UpValues

If there are no OwnValues, the Head is Symbol.  If the Symbol has an
explicit value such as an Integer, Real, List or another Symbol associated
with it by using Set, that (value) Symbol will be the Head.  If the
assignment is conditional the Head will be Condition. 

Note that Context is not mentioned above in the list of values, nor is the
SymbolName.  All Symbols are expressions so they handle queries such as
Depth, Length, Part, etc.  Atomic Symbols have internal data as show here:
http://documents.wolfram.com/mathematica/book/section-A.1.4

> P.S. Calling SetOptions seems much like calling Set. Neither of these
> commands actually prevents you from doing what you want with a
> particular symbol. They just operate on lists of rules that are used in
> "default" transformations. One may override SetOptions with an option
> in the "function call". One may override Set with Block.

Options are not really much different from other values.  To define options
for a symbol you do:

Options[cmd]={optionName->optionVar}

 In order for a function to use Options the programmer has to explicitly
apply them to some local variable.  In order to override the value set by
SetOptions[], you have to do this:
cmd[some, args, opts___?OptionQ]:=Module[{localVar},
....
localVar = optionName /. {opts} /. Options[cmd];
....
]

That way if a rule for optionName is found in opts, it is applied to set the
value of localVar, if not, the default rule is applied.  See
AddOns/ExtraPackages/ProgrammingInMathematica/OptionUse.m

-- 
The Mathematica Wiki: http://www.mathematica-users.org/
Math for Comp Sci http://www.ifi.unizh.ch/math/bmwcs/master.html
Math for the WWW: http://www.w3.org/Math/


  • Prev by Date: Re: Simple task with Mathematica
  • Next by Date: Re: Skewness problem
  • Previous by thread: Re: UML-like diagrams for Mathematica
  • Next by thread: q: Code for GARCH model in Mathematica