nevalang / neva

🌊 Dataflow programming language with static types and implicit parallelism. Compiles to machine code and Go
https://nevalang.org
MIT License
128 stars 8 forks source link

`Struct` syntax sugar WIP #730

Open emil14 opened 1 month ago

emil14 commented 1 month ago

Before

flow NewPixel(x int, y int, c image.RGBA) (pixel image.Pixel) {
    Struct<image.Pixel>
    ---
    :x -> struct:x
    :y -> struct:y
    :c -> struct:color
    struct -> :pixel
}

After

flow NewPixel(x int, y int, c image.RGBA) (pixel image.Pixel) {
    image.Pixel{
        x: :x,
        y: :y,
        color: c,
    } -> :pixel
}

I don't like that -> is omitted, like it lacks dataflow readability


Another option:

flow NewPixel(x int, y int, c image.RGBA) (pixel image.Pixel) {
    image.Pixel{
        x     <- :x,
        y     <- :y,
        color <- :c,
    } -> :pixel
}

Or (weird?)

flow NewPixel(x int, y int, c image.RGBA) (pixel image.Pixel) {
    image.Pixel{
        :x -> x
        :y -> y
        :c -> c
    } -> :pixel
}
emil14 commented 1 month ago

I don't like that -> is omitted, like it lacks dataflow readability

It's something we need to think about very carefully in context of #724 as well