On Sun, Jun 1, 2014 at 9:55 AM, Linus Torvalds
<[email protected]> wrote:
>
> It's also special for the "do I have a tank at all", which sadly git messed
> up by the stupid and wrong default tank size handling, which was then messed
> up even further by the special "unused cylinder" logic that now has a
> configuration flag too.

Side note: that whole cylinder mess is actually pretty similar to what
you are proposing, and for exactly the same reasons: wanting to have
an explicit value where an explicit value wasn't really a good idea.

The fact is, we're better off just leaving things as "empty"  (zero or
NULL or whatever else is appropriate) and considering them
uninitialized and neither loaded nor saved. Then, those empty fields
can have default values when displayed or used. For some things (like
temperature), they mean "don't know/exist". For other things, like gas
contents, zero means "air". For yet other things, it can mean "use the
defaults from the config".

There's nothing wrong with that kind of model, and there's a lot
*right* with it. You never explained why you want to add all your
special cases by hand, but why using "get_o2()" is so onerous.

Side note: if get_o2() were to be changed to also do the type
conversion away from permille, that would probably be a good idea.
Right now we have actively bogus math like

        depth.mm = po2_limit.mbar * 1000 / get_o2(mix) * 10 - 10000;

which does rounding wrong, and only works on a centimeter scale anyway
(see the "* 10" in the wrong place - after the division that doesn't
round).

Of course, it doesn't really matter if our depth estimate might be
wrong by one centimeter, so nobody *cares*, but we might actually be
better off just saying

 (a) if you want to use O2 percentages in actual _calculations_, you
should use "get_o2()" which does it as a floating point value (either
percent or perhaps just as a fraction of 1, which is what you'd
probably mostly want for calculations)

 (b) if you want to *show* the O2 percentage, then get the permille
value, show "0" as air, and do the proper exact integer
FRACTION(o2,10) thing to get the "decimal" value.

those are actually sane and simple rules.

And notice how in the above pre-existing "get_o2()" example, you'd
have the special-case "0" _anyway_. Not because it's air, but because
zero is special.

So the whole whining about "I don't like that special zero" is pure
and utter BS. It's wrong on so many levels.

            Linus
_______________________________________________
subsurface mailing list
[email protected]
http://lists.hohndel.org/cgi-bin/mailman/listinfo/subsurface

Reply via email to