amber-lang / amber-lang/amber

[Feature] compile time macros

Aberta
#452 1 comentário 0 reações 1 responsável Reivindicada por @b1ek Ver no GitHub
compiler enhancement feature proposal syntax
Linguagem predominante
Rust
Estrelas
5.2k
Forks
145
Merge médio
5d 3h
PRs com merge (30d)
7

Descrição

i think we should allow for some macro-like syntax that is evaluated at compile time to save runtime.

not sure how to implement this, though. i think that they should emit amber code that is inserted into the places where they are called. like this:

```ab
macro compile_env(var: Text): Text {
return text_value(trust $\${var}$);
}

echo compile_env("LANG");
```

which will evaluate to something like this, assuming that `LANG` is `en` on compile time:

```ab
echo "en"
```

`text_value()` returned a text literal with the value of `trust $\${var}$`, which was evaluated on compile time

---

ref #436 , but this issue is for discussing the implementation of macros themselves, not the `compile_env!()` macro specifically

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.