vitreo12 / omni

DSL for low-level audio programming.
https://vitreo12.github.io/omni/
MIT License
188 stars 6 forks source link

[RFC] reduce boilerplate: alias #138

Closed vitreo12 closed 3 years ago

vitreo12 commented 3 years ago

This syntax is very awful, but it's just to show the purpose of something like this:

struct Something:
    data Data

init:
    something = Something(Data())

sample:
    alias bubu = something.data
    out1 = bubu[0]
    bubu[0] = in1
vitreo12 commented 3 years ago

the implementation is dead easy:

template bubu() : untyped =
    something.data
vitreo12 commented 3 years ago

maybe using the := operator?

template `:=`(what : untyped, with : untyped) : untyped =
    template what() : untyped {.dirty.} =
        with

a := 10
struct Something:
    data Data

init:
    something = Something(Data())

sample:
    bubu := something.data
    out1 = bubu[0]
    bubu[0] = in1
vitreo12 commented 3 years ago

Coming with 0.3