Skip to content

Why does convert_int_to_bool convert? #166

@sunfishcode

Description

@sunfishcode

The Canonical ABI says

Integer-to-boolean conversions treats 0 as false and all other bit-patterns as true

Why does it work this way, instead of doing trap_if(i >= 2) similar to what i32_to_char does?

(Aside: the names convert_int_to_bool and i32_to_char are a little inconsistent.)

Rust and many popular C and C++ ABIs use a convention of 0 meaning false and 1 meaning true, and could perform a no-op conversion of things like list<bool> into the source language if the Canonical ABI would guarantee that representation as well.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions