From: Clark C . E. <cc...@cl...> - 2002-05-03 18:33:00
|
| > | > - I fix the graph model to include keyed/series | > | > in the distinctio | > | > - We forget about (and remove from the spec) all of the cuteness | > | > regarding the !seq transfer method and keyed (for sparse arrays). | > | > - We introduce !sparse for sparse arrays if necessary. | | I'm perfectly agreeable to this. I always thought the "!seq {}" was a stupid | pet trick anyway. Make it so. Cool. | PS If you ever think of a real world example, I'd be intrigued. Ok. Let's be imaginative. Suppose that I'm an employee of Big Motor Co. and I'm writing an application to handle defects at particular location in a steel casting for an engine. A casting may have over 100 identifyable locations, often numbered 0,...,100. To save space, I use a decide to use a sparse array; and being a good programmer and following the YAML specification, I use the {} trick. castings: - model: 427 Hemi serial: 29302-23945A defects: !seq 0: Malformed hole - model: 427 Hemi serial: 29302-23998A defects: !seq 23: Excess shaff 45: Raised ridge Ok. Suppose that the following gets saved from my python program, and then loaded into a Perl program written by another programmer, which accumulates some summary information (say it adds a defect-count). Then this is saved, and re-loaded back into my Python program. At this point, the first defetct above will be listed... defects: - Malformed hole And will be loaded into python as a regular array. Now suppose that my program detects another "defect" to be added to the list, this time in position 63. So, my code does a "set" on what it believes is a sparse array... but it isn't since my sparse array got replaced with a regular arrray. Anyway, the assignment fails, throws an exception and stops the defect reporting process. This causes the feeding program (attached to a sensor) to have an "overflow" error in the "incoming defects" buffer, which causes the entire line to shut down (about $2,000 per minute at Cleveland Casting). By the time the programmer is called in, and pulls his hair out since his sample data set happened never to have a series of contiguous defects starting at index 0. This takes him about 2 hours to diagnose, fix, and bring the production back on-line, total bill: $240K I'm probably not fired... yet. It may seem contrived, but not really. Subtle bugs like this, infrequent as they may be, are what nightmares (frequent as they may be) in Plant Floor Operations are made of. ;) Clark |