Re: Question about UpSet vs SetDelayed
- To: mathgroup at smc.vnet.net
- Subject: [mg63823] Re: Question about UpSet vs SetDelayed
- From: albert <awnl at arcor.de>
- Date: Mon, 16 Jan 2006 02:16:51 -0500 (EST)
- References: <dq7u2s$3r6$1@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
Hi, > Say I want to have some 'properties' of a symbol 's', I can do: > > someFunc[s] := True; > > and I can also do: > > someOtherFunc[s] ^= True; > I have seen that others have given two of the most important differences: 1) someFunc[s]:=True will store a rule within the DownValues of someFunc, which you can check with DownValues[someFunc]. On the other hand someOtherFunc[s] ^= True; will store a rule within the UpValues of s, which you can also check: UpValues[s]. 2) using Patterns that are more complicated than just atoms, you can formulate rules with one form that you can't formulate with the other: f[x_]:=Print[x] f_?(MemberQ[Attributes[#], NumericFunction]&)[s]^=Print["s is not numeric!"] Still I could not resist do note that even the simple case in 1) results in important differences because of the order that various rules are used in the evaluation chain. You have to look details in the HelpBrowser to get a good understanding of what exactly happens when, to see why it matters try to guess what the result of evaluating the following lines would be: f[x] := 1; _[x] ^= 10; f[x] hth albert