amber-lang / amber-lang/amber

[Feature] implement `match` or `switch`

Aperta
#1,108 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub
compiler enhancement
Lingua principale
Rust
Stelle
5.2k
Fork
145
Merge medio
5g 3h
PR unite (30g)
7

Descrizione

current if-chain solution for matching variables is expensive in terms of performance:
```
if {
arg == "-V" or arg == "--version": show_version()
arg == "-h" or arg == "--help": show_help()
arg == "-v" or arg == "--verbose": VERBOSE = true
else {
error("Invalid argument: {arg}")?
}
}
```

Image

not only it has to execute every `[ ]` command for text match but also uses subshells, which drastically decreases the overall performance

the syntax can be the same as rust's match or C's switch and will generate bash's case block which supports both multiple values and wildcards

Guida per i contributori

Nessuna guida per i contributori indicizzata per questo repository

Valutazione

Questa issue non è ancora stata valutata.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.