23

Lets say I am trying to describe my code in a technical meeting.

First, I set the boolean foobar to true

and

Second, I set the boolean foobar to false

seems a bit wordy. If foobar was toggled, I could probably say,

Third, I toggle foobar

Through implication here, you know its a boolean. So shouldnt I be able to:

Fourth, I Truthify foobar

and

Fifth, I Falsify foobar

Which will also through implication, tell my listeners that we are dealing with a boolean variable? Is there proper terminology for this? Thanks.

closed as primarily opinion-based by Robert Harvey, gnat, Thomas Junk, Blrfl, rwong May 5 '18 at 16:39

Many good questions generate some degree of opinion based on expert experience, but answers to this question will tend to be almost entirely based on opinions, rather than facts, references, or specific expertise. If this question can be reworded to fit the rules in the help center, please edit the question.

  • 16
    "I set foobar to true/false" is not that wordy, and it's obvious that's a bool. "Toggle" is fairly clear to listeners, IMO. – Filip Milovanović May 4 '18 at 9:20
  • 8
    "First, I set the boolean foobar to true and, Second, I set the boolean foobar to false". Couldn't you have just set it false in the first place? ;) – David Arno May 4 '18 at 9:38
  • 2
    I always thought it was called flipping, but apparently that's the term for bits, not bools – e_i_pi May 4 '18 at 9:46
  • 16
    I'd read falsify as equivalent to creating a forgery and not setting the value to false. – CodesInChaos May 4 '18 at 9:50
  • 6
    Are you sure you're expected to describe your code on such a low level? Surely if someone wants such a low level description, they'd just read the code. I'm not saying there's never a reason to use such terminology, but I would expect it to be rare. – Dukeling May 4 '18 at 10:44
53
  • Setting a value to true is setting it
  • Setting it to false is clearing it.
  • Changing the current value is toggling it.

You can also use "setting it to true" and "setting it to false", of course.

  • 10
    I don't correlate setting a value to false as clearing it. Clearing for me means: neither true or false. – Pieter B May 4 '18 at 6:57
  • 49
    @PieterB: Well, it depends on the context; if we're talking about a Boolean flag, then "setting" and "clearing" the flag is a fairly common terminology. – Filip Milovanović May 4 '18 at 9:18
  • 7
    @FilipMilovanović In the context of variables, setting a variable means assigning a value to said variable, in the context of boolean variable this value can be true or false. It would be strange to say: hey, setting a variable means assigning a value to it...except when it is a boolean variable then actually when we set it, we mean that we assign the value : "true" – Pieter B May 4 '18 at 12:21
  • 6
    @PieterB If it can be "neither true or false", then its not a binary boolean (which is what most people think about when they hear the word), but a ternary true/false/indeterminate thing. That being said, the set/clear terminology comes from flags. Not all boolean variables are flags, so the terminology is inappropriate for many use cases. – Cubic May 4 '18 at 12:53
  • 7
    @PieterB: Yeas - it would be strange to say "set the bool variable" and to expect everyone to understand it to mean "set it to true"; but if it represents a flag, then "set the flag" is something commonly used and means set the value of the bool representing the flag to true (or the bit representing the flag to 1). (P.S. But the answer by immibis doesn't take that into account.) – Filip Milovanović May 4 '18 at 12:55
66

If at all possible, rather than focusing on the boolean value, you should try to describe what it represents. Some examples:

  • a service? start/stop instead of started=true/false
  • a special effect in a game engine? on/off
  • an electrical signal? set/reset
  • ...

This way you'd talk in more natural terms. And thus in your meeting, instead of "truthifying foobar then falsifying it" you would simply "start foobar then stop it" (if foobar is a service, indeed).

When you really need to talk about a boolean value, you can go with "set/reset", or "set to true" and "set to false". "Toggle" sounds quite nice in all contexts.

And if you work in a boolean shop (whatever that could mean) then you probably need more words than what the dictionary has to offer. In that case, truthify and falsify are simply parts of your microspeak.

  • 16
    Have to agree... boolean is the implementation which models what you are REALLY talking about... so talk about that instead! – Maybe_Factor May 4 '18 at 6:00
  • 2
    I don't like talking about setting a boolean as making it true. Because the way I work with variables they start out uninitialized, meaning basically you can't use them yet and the act of setting a variable (true or false) is the initializing. For setting to always mean true would cause confusion. – Pieter B May 4 '18 at 7:02
  • 1
    Also, this usage of terminology translates to code as well; It's often - not always of course - better to use a two value enum instead of the builtin boolean type; signal = HighVoltage or signal = Active is IMHO much clearer than signal = true. – Cubic May 4 '18 at 9:58
  • Note that a properly named boolean property/variable will always immediately reveal the name you should be using for the values. Think of isStarted, isActive, isCaseSensitive, mockConnection, ... @PieterB: I partially agree with you. "Set the boolean" does not inherently mean setting it to true. However, "Set the isActive flag" can reasonably be interpreted to mean setting it to true. – Flater May 4 '18 at 12:39
  • 1
    @Cubic: I disagree. Future expansion aside, a binary enum seems unnecessary. signal = true is indeed not clear, but if you're going to use signal = Active then you might as well use isSignalActive = true. Note that this applies mainly to descriptors that are clearly mutually exclusive and exact complements. Active/Inactive fits the bill. HighVoltage does not, since "not high voltage" could e.g. mean "low voltage", or it could mean "low or medium voltage". In the latter case, the boolean argument obviously does not apply. In the former, it does. – Flater May 4 '18 at 12:42
2

I like "set" / "clear", but be careful of ambiguity in your phrasing. As Filip points out, "set the bool variable" could be taken to mean writing some value to the variable. But "setting the flag" is more clear.


Related terminology: turning a 0 / non-zero integer into a 0 / 1 value is called "booleanizing".

If you actually use the 0 / 1 value as an integer (instead of as a true/false bool), you may want to use that word. Otherwise it will probably only come up if you're talking about the cost of the operations the compiler has to perform. (Or if you're manually vectorizing with a SIMD compare to produce all-zero / all-one bits in each vector element).

In C and C++, a bool can implicitly convert back into an integer as 0 or 1, and on normal implementations bool is stored as a one-byte value that is either 0 or 1 (not just any non-zero value). The allows efficient a && b, but in practice many C compilers have missed optimizations.


bool booleanize(int a) { return a; }   // C++

That function compiles to multiple instructions (not including the ret) on most architectures. (MIPS being an interesting exception, having compare-into-register instructions instead of a separate flag / condition-code register). on the Godbolt compiler explorer for x86-64, MIPS, and ARM thumb, we can see the x86-64 version is:

    test    edi, edi    # set flags according to   a & a
    setne   al
    ret                 # return value in AL, the low byte of RAX

Sorry this example of what booleanizing is got a little large / off-topic!

0

I think "set Foobar to true" and "set Foobar to false" are straightforward and succinct. I don't believe there are individual words for those phrases, and when you need to be both technical and precise, it's sometimes better to be willing to be a little wordy than to risk confusing your audience.

-1

"Setting" is the correct way to describe the act of assigning a value to a variable. If you wanted to get pedantic about it, you could call it "assignment", but "set" is very prevalent. In fact, it's idiomatic Java to write setFoobar() (and getFoobar()) methods to perform assignment. C# takes it a step farther with get and set property definitions.

With regards to your second point about using "truthify" and "falsify" to "through implication, tell my listeners that we are dealing with a boolean variable", you are already telling your listeners the variable is Boolean when you say:

I set Foobar to true

  • 1
    The 'standard' in Java for methods that return boolean properties is actually isFoobar() – JimmyJames May 4 '18 at 17:00
-1

Assert or Retract can also be used, most often when talking about propositions rather than simple variables, for example in Prolog. Usually there are different terms depending what the boolean represents, rather than one general term for all languages having boolean values (set/clear flag or bit, enable/disable device or mode, assert/retract proposition, probably more).

  • I'd agree with assert, except that to a programmer that already means something else different (e.g. throwing an exception if the expression is not already true). – ChrisW May 5 '18 at 13:33
  • @ChrisW I don't know what you think people who program Prolog are if not programmers, but it was used in Prolog in 1972, so it's the C macro that changed the existing meaning. – Pete Kirkham May 8 '18 at 8:43
-1

To change a boolean's value from true to false, or vice-versa is called negating.

To set a boolean's value to false is said as falsifying the boolean. I would understand you if you said "truthify", however, this doesn't sound right. I'm not sure what the verb is for making something true, so it could be right.

I would wait for someone with a better answer to come by before you start using "truthify" willy-nilly.

  • 1
    The problem here is that you may use the terms negating, falsifying, but I'd use toggle and reset / clear respectively. In fact until reading this question, I'd never come across falsify. Maybe I'm just getting old though and I'm not up to date with this year's trendy terms :) – David Arno May 4 '18 at 9:35
  • 7
    'falsify' has a meaning in the english language that doesn't really align with your usage for boolean variables; If you told me you're "falsifying" your variables I might understand what you're trying to say, but I'd first parse that as you trying to tell me that you're lying about the values they have. – Cubic May 4 '18 at 12:50
  • 1
    IMO the opposite of "falsifying" would be "asserting", in English, but that ("assert") gives the wrong impression to a programmer. – ChrisW May 4 '18 at 13:48
-3

A boolean is a the equivalent of an SPST (single pole, single throw) electrical switch: one turns it on or off.

  • 2
    "Turn on the done variable" or "The error variable is turned off" both sound a bit off, at least to me. Alternatives suggested by other answers seem more prevalent - "Set the done variable/bool/flag [to true]", or "The error flag is cleared." – Sebi May 5 '18 at 0:16

Not the answer you're looking for? Browse other questions tagged or ask your own question.