aspl-lang/aspl

aspl: add (inline) `if` expressions/a ternary operator

Offen

#38 geöffnet am 16.07.2026

 (0 Kommentare) (0 Reaktionen) (0 zugewiesene Personen)C (6 Forks)auto 404
enhancementhelp wanted

Repository-Metriken

Stars
 (30 Sterne)
PR-Merge-Metriken
 (PR-Metriken ausstehend)

Beschreibung

Feature idea

There is currently no clean way to conditionally assign/select values inside a single expression in ASPL, leading to a lot of boilerplate code like temporary or wrongly-typed variables. See this code, which is taken from the ASPL compiler, for an example:

var string? mainOutFile = null
// ...
if(Options:targetOs == "android"){
    mainOutFile = tempFile
}else{
    // ...
    mainOutFile = exeFile
}

Possible solutions/implementations

An if expression, analogous to if statements, or a ternary operator, which is just a different notation for the same thing.

Alternatives considered

Match expressions (see #37) are the more general solution to this problem but also unnecessary clutter for just a simple binary condition, so additional if expressions are still worth it, imo.

Additional context

No response

Contributing guidelines

  • I agree to follow this project's contributing guidelines

Contributor Guide