petdance/scratch — Issue #444: Parrot lacks a boolean type
Author: petdance
Created: 2011-11-01 05:42:21+00:00
State: open
Labels: bug, core, Pri-normal, Sev-medium

And instead, boolean contexts fall back to expecting ints. This is not semantically correct, and leads to issues, especially when trying to expose a HLL's object system to the rest of parrot.
In my specific case, I implemented get_bool on Python objects, but Rosella's is_true and winxed's if coerce to int. Rosella and Winxed are doing the least wrong thing possible with that they've got.

Implementing get_integer to return 0 for false, 1 for true and the value for Python ints is simply incorrect. At least in python 0 is falsy, which makes it possible to have this workaround, in other languages it would be required to simply not implement get_bool or get_integer, to not break things.

The workaround in Winxed is the ternary operator (bla ? 1 : 0), which ends up calling bla.get_bool.

Originally http://trac.parrot.org/parrot/ticket/2178