Skip to content

Add ternary operator #97

@raffopazzo

Description

@raffopazzo

This seems particularly useful to construct types.

func range_up  (u64_t from, u64_t to) -> array_t(u64_t, from < to ? to - from : 0);
func range_down(u64_t from, u64_t to) -> array_t(u64_t, from > to ? from - to : 0);

Also, the returned value might be a dependent type

func zero(bool_t which) -> which ? i32_t : bool_t
{
    return which ? 0 : false;
}

But this is not really surprising because all functional languages have the expression if x then y else z .

Metadata

Metadata

Assignees

No one assigned

    Labels

    featureNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions