- Feature Articles
- CodeSOD
- Error'd
- Forums
-
Other Articles
- Random Article
- Other Series
- Alex's Soapbox
- Announcements
- Best of…
- Best of Email
- Best of the Sidebar
- Bring Your Own Code
- Coded Smorgasbord
- Mandatory Fun Day
- Off Topic
- Representative Line
- News Roundup
- Editor's Soapbox
- Software on the Rocks
- Souvenir Potpourri
- Sponsor Post
- Tales from the Interview
- The Daily WTF: Live
- Virtudyne
Admin
Of course, rsEmplExp.MoveFrist only applies when not True!
Admin
The docs make me thing this is the case - it's a read-only Boolean. https://docs.microsoft.com/en-us/office/client-developer/access/desktop-database-reference/recordset-eof-property-dao
Admin
Well indeed. Not all models of reality adhere to Tertium Non Datur.
There is an entire branch of mathematics whose thesis is that TND may not necessarily hold.
The programmer in this case is prudent and sensible, and has written code that is bullet-proof.
Admin
I recognise the pattern. In my case the reason was "standards" (why use two constants when one suffices?) the other (anti-) patterns was to write it like if (true == someCondition) because one developer was once burned by: if (someCondition = true), however this application was written in VBA (yeah, you can poke fun now.)
Admin
Visual Basic, you say? I remember from my kidhood that boolean expressions in MS-BASIC return 0 for false and -1 for true, but IF accepts any non-zero value as true. You just don't want to combine random "boolean" values with AND and OR because there's no && or || like operator. This looks like a cargo cult response by someone who discovered that the hard way.
Admin
It's VBA. This is just a know-nothing version of 'if false or error'. It likely indicates something is mildly broken elsewhere in the code, but I don't think there's much to laugh about when beginners hack away until they get something working.
Admin
Reading that M$ doc, I come to the thought that some steps in the development of the code are nowadays missing: tinkering around with both BOF and EOF and their various combinations. And what ever crap they did with the recordset before they arrived at that line of code...
Admin
Which is why you should just omit the "= true" part: if (someCondition).
Admin
A sane compiler does not allow a boolean constant as an operand of a comparison operator.
Unfortunately, I've never met a sane compiler.
Admin
A looong time ago, I recall in some book with a name like "C++ for Dummies" or "The Complete Idiot's Guide to C++", there was a sidebar titled "How to Annoy a Visual Basic Programmer". It said (presumably in jest) that VB devs do "if x = True" while C++ devs do "if (x != false)". Maybe someone read that, took it seriously, and thought they'd be cute?
Admin
Sure about that? If such a compiler existed, I assure you that a lot of programmers' brains will fry as they attempt a paradigm shift without a clutch.
Admin
This construct was written to deal with Schrodinger's Boolean.
Admin
We've heard of fuzzy logic; perhaps such a language has to allow for statements that are 'less than true' and 'more than false'. We should ask a lecturer in Woolly Thinking about this...
Admin
In general, I'd advocate going a step further and banning the comparison of boolean values (constants or not), as if (in C++ terms)
bool operator ==(bool, bool)
does not and cannot exist.Admin
While it's always fun to speculate, I have a hunch the answer is something much more mundane: style preference.
If my shirt is not red, how did you parse this sentence?
if ( shirt (is not) red ) or if ( shirt is (not red) ) ?
There were probably just two different people who read the sentence differently.
Admin
That would also make something like this impossible:
which does come in handy from time to time. I've used this more than once, if not with
==
then!=
, but same difference. Withoutoperator==
you'd have to do the following, which I don't find more readable:Yes, someone who genuinely needs to compare bools that way can be expected to come up with the alternative, but it doesn't convey the intent the same way.
// let's see if I got those code blocks right... 🤞
Admin
Some languages have EQV and NEQV operators (or XOR) which are equivalent to comparison but more logical (aha).
So you could have if (a EQV b). Anybody who writes if (a EQV True) should hopefully get a compiler warning for writing a stupid operation.
Admin
And you're unlikely ever to meet one, as first you'd have to have a sane language design.
Admin
There's true, false and 'maybe'. 'Maybe' is not false, but also not true.
Admin
That looks like an XNOR operation. Shame there isn't an actual factual boolean XOR in most C-ish languages. Would have been nice if K&R had given us
a^b
for bit XOR anda^^b
for boolean XOR, so your operation would be:although I have seen people abusing C and C++'s silent promotion of
bool
toint
to cheese it as (note single ^):Admin
I think this is the opposite of some Visual Basic / COM problem. I recall vaguely that some configuration of tech glue ends up with True being treated as 1, and False as 0, but sometimes COM APIs return some other non-zero value (like -1) for "true". Doing "<> False" may therefore be necessary, but I don't see why you'd need "<> True".
Admin
The low-level Win32 COM APIs return HRESULTs, which are a 32-bit unsigned integer value, with all "high-bit set" values indicating an error (and the rest of the bits identifying the error).
High-bit clear indicates a success, which is usually
S_OK
(zero), but a few can returnS_FALSE
which is 1.Admin
What would happen if EOF was (null)?
Admin
Perl 6 actually lets you do exactly that -
$x | $y
is a value, represents a superposition of the two values, and can be used anywhere the values can, the result of which is another superposition. Then eventually you end up with a superposition of bools, which when evaluated in a boolean context collapse via OR. Or you can make the superposition with &, or ^, and there's even one for the NOT case, though unfortunately lacking a convenient operator.Admin
Why not call it what it is: an equality operator? There's no problem with
==
if your boolean type properly has only two values, nor!=
which is the same as xor. There is absolutely no problem with such things unless your type standing in for boolean is really an integer and that is the real WTF.Admin
Are you, by any chance, referring to "Logics with Semiring semantics" ?