terrastruct / d2

D2 is a modern diagram scripting language that turns text to diagrams.
https://d2lang.com
Mozilla Public License 2.0
18.14k stars 446 forks source link

proposal: way to create multiple connections with array #742

Open joonas-yoon opened 1 year ago

joonas-yoon commented 1 year ago

I was trying to connect classes in a row as like:

Object -> Fruit -> Apple, Avocado, Banana, Grape, Melon

the output what I expected and what I've got is:

expected but actually
image image

but this is not what I want to do.

so I wrote the code like the following and its result is:

input output
Object -> Fruit -> Apple
Object -> Fruit -> Avocado
Object -> Fruit -> Banana
Object -> Fruit -> Grape
Object -> Fruit -> Melon
image

Do you have any plan to support some of array operations in connection?

I think this will be useful when user want to create N:N connections with same objects.

as is to be
Local -> Processor
Cloud -> Processor
Processor -> CPU
CPU -> 0
CPU -> 1
CPU -> 2
Processor -> GPU
GPU -> 0
GPU -> 1
GPU -> 2
[Local, Cloud] -> Processor -> [CPU, GPU] -> [0, 1, 2]
alixander commented 1 year ago

oh i like this idea, especially that N:M aspect. i'm for it and thinks it fits well in the language design. The arrays would be explicit though, like

Object -> Fruit -> [Apple, Avocado, Banana, Grape, Melon]

instead of

Object -> Fruit -> Apple, Avocado, Banana, Grape, Melon

@nhooyr any thoughts?

(this is a beautiful issue report)

nhooyr commented 1 year ago

Seems reasonable to me!