amber-lang / amber-lang/amber

[Feature] implement `match` or `switch`

Aberta
#1,108 0 comentários 0 reações 0 responsáveis Ver no GitHub
compiler enhancement
Linguagem predominante
Rust
Estrelas
5.2k
Forks
145
Merge médio
5d 3h
PRs com merge (30d)
7

Descrição

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

Guia de contribuição

Nenhum guia de contribuição indexado para este repositório

Avaliação

Esta issue ainda não foi avaliada.

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.