xenharmonic-devs / sonic-weave

The SonicWeave DSL for manipulating musical frequencies, ratios and equal temperaments
MIT License
4 stars 4 forks source link

Make blocks legal expressions evaluating to arrays #352

Closed frostburn closed 3 months ago

frostburn commented 3 months ago

ref #351

frostburn commented 3 months ago

@inthar-raven Assigning you as the reviewer based on your reaction on Discord.

I would be inclined to change record syntax to #[fif: 3/2] now too to make containers more alike, but I'd like to hear your overall opinion of this feature first.

This is mostly for conceptual consistency with blocks unrolling their contents onto the parent block which makes them look like arrays in a way. Unfortunately I couldn't find any practical uses for this feature in the prelude.

frostburn commented 3 months ago

Ideally, I like block expressions that evaluate to any type. (I don't know if that requires a stronger type system.) I think this is a good start for that.

I can make return statements legal to achieve that.

frostburn commented 3 months ago

No reaction to tweaking the record syntax further. I'm pretty sure we're adding sets as containers so maybe #[1,2,2] would be syntax for the set {2, 1} later on. (Just to say that both #{} and #[] are going to be used so it doesn't matter which of them is the record from a grammar design perspective.)