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: 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]


  • Prev by Date: Re: preparing multiple choice questions
  • Next by Date: TableForm vs. GridBox
  • Previous by thread: Lightweight Structs - Practical Example (Data Types in Mathematica)
  • Next by thread: TableForm vs. GridBox