Re: Lightweight Structs - Practical Example (Data Types in Mathematica)
- To: mathgroup at smc.vnet.net
- Subject: [mg63385] Re: Lightweight Structs - Practical Example (Data Types in Mathematica)
- From: "Frank Iannarilli" <frankeye at cox.net>
- Date: Wed, 28 Dec 2005 03:55:41 -0500 (EST)
- References: <dor2p2$amu$1@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
Here's some strengthening of the approach (thanks to my friend Steve Jones for pointing out weaknesses). 1. Protect the instance ID symbols from accidental definition, which would sow havoc into any existing structs. Indeed, strengthen the struct "constructor" to insure this: makeSensor[id_Symbol] := Module[{}, Protect[id]; Sensor[id]@radius = 0; Sensor[id]] 2. Similarly, Protect[] the fieldname symbols: Protect[radius]