`where` concerns
I’m debating the where operator I proposed here.
Currently, where functions like a find-and-replace tool:
color = (r,g,b)
where {
r = 0.1;
b = someFunction();
g = foo
}
the variables r,g, andb get replaced by the expresisons in the where clause. I think this works fine and doesn’t pose any problems. Everything you’re replacing you can see directly in the expression above, so there is no real risk of replacing something in a way you didn’t mean to.
The bigger issue is the more “meta” functionality of where that allows you to syntactic replace parts of a definition well after defining it. For example lets say I had
img[3] = camera(@x,@y)
so img has three signals, which are the red, green, and blue channels of the camera, evaluated over x-y pixel space. If, when I originally defined img, I had wanted to flip the x-axis, I could’ve written:
img[3] = camera(1-@x, @y)
But lets say I didn’t know I wanted to do that, and now I’m too deep in to go back and change it. With where, I can change it on the fly:
img_flipped[3] = img where {@x = 1-@x}
This takes the definition of img, and replaces @x with 1-@x. It feels like it could be super powerfu,