27

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.

Anon
  • 3,639

8 Answers8

65

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.

56
  • 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.

1

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!

Peter Cordes
  • 479
  • 5
  • 9
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.

Kevin
  • 731
-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

Assert or Retract can also be used, most often when talking about propositions rather than simple variables, for example in Prolog.

Assert is also fairly common in hardware, meaning to make the signal equivalent to logical true, which is usually a non-zero voltage. See the question on the electronics sister site What does it mean to "assert" a pin?.

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).

Pete Kirkham
  • 2,041
-2

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.

Anders
  • 1,361
-3

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