(It seems likely to me that there were some false starts, because eliminate() returns either `values` or False, when both of its callers would be just as happy if it returned True or False.)
(It seems likely to me that there were some false starts, because eliminate() returns either `values` or False, when both of its callers would be just as happy if it returned True or False.)
if( maybeNullValue ) {
myValue = maybeNullValue;
} else {
myValue = defaultValue;
}
can instead be expressed as this: myValue = maybeNullValue || defaultValue;
I'm personally a little bit torn about it. On the one hand, now that I'm familiar with it I love how much more concise code can be. On the other, it can have a fairly negative impact on code maintainability: if someone comes along who isn't familiar with that idiom, they might have a bad time trying to figure out what's going on (or worse, they might take offense that all these predicates aren't returning True or False values and rewrite the whole mess--or you could end up with a mix of the two, where some functions follow the idiomatic convention and others return actual boolean values which is arguably the worst)Also I'm not trying to say that there's not some YAGNI going on here--just that I suspect he did it that way somewhat reflexively, and that in that particular case we probably cannot infer he had originally intended to do something else with those results and then changed his mind later.
[0] at least in the Lisp world, which Norvig has extensive experience with[1]
https://github.com/dlang/dmd/blob/master/src/dmd/root/spelle...
but I'm sure it was much longer than it took Peter. This checker is used by the D compiler to look for a misspelled identifier when a symbol lookup fails. The identifiers in scope form the dictionary.
It works surprisingly well. I added it to the Digital Mars C++ compiler as well.
https://github.com/DigitalMars/Compiler/blob/master/dm/src/d...
That's pythonic.
You don't convert from a data type to Boolean.