#1 Implement a new language construct: `macro`

Zamknięty
otworzone 4 dni temu przez Archivist · 0 komentarzy
Archivist skomentował(-a) 4 dni temu

The macro language constructs operates like a compile time function. The code is executed during the compilation phase, and then it is made into a function that outputs the remaining stack left behind by the routine that executed the macro.

Syntax

let cnt a function that returns a single integer, from the sequence {1, 2, 3, 4, 5, 6, 7, 8, 9, 10...} in order with each call. cnt has not been called.

macro my-macro do
	cnt cnt + cnt cnt + +
end
usage:
my-macro print_int 20 print_utf8 my-macro print_int 20 print_utf8
expected output:
10
10


usage:
cnt drop my-macro print_int cnt drop cnt drop 20 print_utf8 my-macro print_int 20 print_utf8
expected output:
10
10

Proposed way of implementation

The implementation could be performed as a normal function that just outputs to stack the stored value. This depends on the system to preserve function contents during GC #2.

The `macro` language constructs operates like a compile time function. The code is executed during the compilation phase, and then it is made into a function that outputs the remaining stack left behind by the routine that executed the macro. ## Syntax let `cnt` a function that returns a single integer, from the sequence {1, 2, 3, 4, 5, 6, 7, 8, 9, 10...} in order with each call. cnt has not been called. ``` macro my-macro do cnt cnt + cnt cnt + + end ``` ###### usage: ``` my-macro print_int 20 print_utf8 my-macro print_int 20 print_utf8 ``` ###### expected output: ``` 10 10 ``` -------------- ###### usage: ``` cnt drop my-macro print_int cnt drop cnt drop 20 print_utf8 my-macro print_int 20 print_utf8 ``` ###### expected output: ``` 10 10 ``` ## Proposed way of implementation The implementation could be performed as a normal function that just outputs to stack the stored value. This depends on the system to preserve function contents during GC #2.
Archivist dodał(-ęła) etykietę
enhancement
4 dni temu
Archivist przypisuje to na siebie 4 dni temu
Archivist zamknął(-ęła) to zgłoszenie 4 godzin temu
Zaloguj się, aby dołączyć do tej rozmowy.
Brak kamienia milowego
Brak przypisanych
Uczestnicy 1
Powiadomienia
Termin realizacji

Brak ustawionego terminu realizacji.

Zależności

To zgłoszenie nie ma w tej chwili żadnych zależności.

Ładowanie…
Nie ma jeszcze treści.