Project

General

Profile

Actions

Feature #13125

closed

MRI has too much Qtrue : Qfalse;

Added by shyouhei (Shyouhei Urabe) about 7 years ago. Updated over 2 years ago.

Status:
Closed
Assignee:
-
Target version:
-
[ruby-core:79066]
Tags:

Description

% git grep -P 'Q(true|false|nil|undef)\s+:\s+Q(true|false|nil|undef)' | wc -l
211

Out of those 211 occurrences the most interesting lines include:

complex.c:#define f_boolcast(x) ((x) ? Qtrue : Qfalse)
math.c:#define f_boolcast(x) ((x) ? Qtrue : Qfalse)
range.c:#define RBOOL(v) ((v) ? Qtrue : Qfalse)
rational.c:#define f_boolcast(x) ((x) ? Qtrue : Qfalse)

I strongly believe that we need an orthodox way to do this.

Updated by shyouhei (Shyouhei Urabe) about 7 years ago

We looked at this issue at yesterday's developer meeting. Nobody was against introducing a macro. No consensus over its name was made though.

  • RBOOL() seems like a member of RSTRING(), RARRAY() and family so not very good.
  • It is in fact a INT2FIX()'s family so I proposed BOOL2BOOL() but this sounds too strange.
  • What is needed is a "reverse" of RTEST() so RUNTEST() is proposed (I believe it was not serious).

Updated by rmosolgo (Robert Mosolgo) about 7 years ago

"reverse" of RTEST()

How about ...

  • CTEST()
  • TEST2BOOL()
  • C2BOOL()

Hope those help brainstorm a bit :)

Updated by znz (Kazuhiro NISHIYAMA) about 7 years ago

How about BOOL2RBOOL?

Updated by phluid61 (Matthew Kerwin) about 7 years ago

Seem to me like VALUE2BOOL, except perhaps for the way it casts Qnil to Qtrue

Updated by nobu (Nobuyoshi Nakada) about 7 years ago

Someone suggested RB_BOOL at the meeting.

Actions #6

Updated by jeremyevans0 (Jeremy Evans) almost 4 years ago

  • Tracker changed from Bug to Feature
  • Backport deleted (2.2: UNKNOWN, 2.3: UNKNOWN, 2.4: UNKNOWN)

Updated by jeremyevans0 (Jeremy Evans) over 2 years ago

  • Status changed from Open to Closed

RBOOL was recently introduced for this purpose.

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0Like0