Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

if-else construct in const-evaluation blocks #56

Open
theCapypara opened this issue Jul 6, 2024 · 0 comments
Open

if-else construct in const-evaluation blocks #56

theCapypara opened this issue Jul 6, 2024 · 0 comments

Comments

@theCapypara
Copy link
Member

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant