But aPattern.collect
follows another model: aCollection.collect
. A collection represents multiple values. The pattern makes a stream, which represents multiple values. If it makes sense to âcollectâ over multiple values from a collection, then it also makes sense to âcollectâ over multiple values from a stream.
I believe the concept for collections came first (related to map
in other languages). So, if we justify something.rest
on the basis that we have something.collect
, then [0, 1, 2].rest
needs to make sense in the same way that [0, 1, 2].collect
makes sense.
I donât think it does. [Rest(0), Rest(1), Rest(2)]
? I donât get it.
I think that users are often detained from Pattern constructs because they end up in a mass of brackets.
I think one reason for that is because the documentation, and list and forum postings, rarely demonstrate the use of indentation to make pattern notation clearer.
That is, we would tend to see examples written like this:
(
p = Pbind(
\degree, Pseq([Pseries({ rrand(-7, 0) }, 1, { rrand(3, 9) }), Pn(-10, { rrand(4, 8) }), Pseries({ rrand(5, 12) }, -1, { rrand(3, 5) })], inf),
\dur, Pswitch1([0.125, Rest(0.125)], Pwhite(0.0, 1.2, inf))
).play;
)
p.stop;
Now, Iâm used to working with patterns, but that \degree pattern makes even me dizzy.
(
p = Pbind(
\degree, Pseq([
Pseries({ rrand(-7, 0) }, 1, { rrand(3, 9) }),
Pn(-10, { rrand(4, 8) }),
Pseries({ rrand(5, 12) }, -1, { rrand(3, 5) })
], inf),
\dur, Pswitch1(
[0.125, Rest(0.125)],
Pwhite(0.0, 1.2, inf)
)
).play;
)
p.stop;
Syntactically equivalent, but crystal clear.
I get what Simon is saying in an e-mail post, but [ ... super long list of nested patterns ...].seq
is still messy to read, without indentation.
Also, especially for live coding, what I would really like to see is more intelligent cursor behavior. The problem Simon is pointing to is, if you have array
, then to sequence it, you need to put something before the array and something after, which is slow and inconvenient for live coding (whereas, with his suggestion, you only need to put something after it). But, in the IDE, we are stuck with cursor movement key bindings that are designed for text rather than programming code. We should be able to hit keys to select syntactic elements, and then hit other keys to wrap the selected element in some template.
For live coding performances, I use a TextView instead of an IDE document, with some custom keyDownActions that navigate through my live coding syntax more intelligently. Itâs a huge help.
hjh