On Mar 2, 4:47 am, Steven D'Aprano <[EMAIL PROTECTED]> wrote: > On Thu, 01 Mar 2007 20:24:33 -0800, Paul Rubin wrote: > > Steven D'Aprano <[EMAIL PROTECTED]> writes: > >> But if you used Apps Hungarian, and saw this line of code: > > >> if hmmCurrentHeight <= hinCriticalHeight: > > >> then you should instantly recognise that there's a problem. Comparing > >> a height in millimetres to a height in inches is not a good thing to do, > >> no matter that they're both floats. > > > That still sounds like an unreliable manual type system, > > It's unreliable in the sense that the coder has to follow the naming > convention, and must have some bare minimum of sense. If your coders are > morons, no naming convention will save you. (For that matter, nothing will > save you.) > > > instead of an > > automatic type system that includes dimension analysis. You might > > like this: > > > http://futureboy.homeip.net/frinkdocs/ > > > There are many Python implementations of dimensioned units as well. I > > posted one here a few weeks ago. > > Sure, and I love the Unix utility "units", and my HP calculator. > Dimensioned units are useful. > > But dimensioned units are still only part of the story. Joel describes the > situation the early Word developers found: when you're writing a word > processor, you are doing a LOT of conversions between screen coordinates > and window pane coordinates. Both have the same type (a pair of ints), > both have the same dimensional units (length/pixels) but they are > semantically different. If you place the character "N" at coordinates 0,0, > it makes a big difference if the coordinates are relative to the current > window or relative to the screen. > > Apps Hungarian is a heuristic for dealing with semantic differences, not > data types. It deals with more than just dimensional analysis. > Basically what you want are dimensions such as "screen coordinate" and "window coordinate" as well as "pixel", and also other kinds of dimensions which combine differently. For example:
The dimension "pixel" works one way and the dimensions "relative to screen" and "relative to window" work a differnt way. If: p is a point relative to the screen: integer, <pixel>, +<relative to screen> q is a point relative to the window: integer, <pixel>, +<relative to window> r is the window relative to the screen: integer, <pixel>, +<relative to screen>, -<relative to window> then: p = q + r <pixels> = <pixels> + <pixels> <relative to screen> = <relative to window> + (<relative to screen> - <relative to window>) -- http://mail.python.org/mailman/listinfo/python-list