Skip to content

if-else construct in const-evaluation blocks #56

@theCapypara

Description

@theCapypara

Summary

Add a ternary if-else construct to const-evaluation expressions.

Dependencies

This needs the following features to be implemented first:

Motivation

This allows basic conditional logic in const-evaluation blocks.

Examples

const FOO = ${if 3 > 2 then XYZ else "whatever"}

Language Changes

Parser and Lexer Changes

These expressions must be added to the grammar. Parenthesis may be required or optional, depending on parsability. Even if they are optional, they may be required or at least useful to use for complex expressions.

Behaviour

The new expression is defined as: if X then Y else Z, where Y will be the result of the expression if the integer X > 0, otherwise Z will be the result.
If X is not an integer, this fails.

Compiler Implementation

Compiler Interface Changes

None

Decompiler Changes

None

How to teach

Add to meta programming sections

Alternatives

Different syntax

Backwards compatibility

None

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions