alda icon indicating copy to clipboard operation
alda copied to clipboard

Stack-based attributes

Open daveyarwood opened this issue 9 years ago • 2 comments

Moved from https://github.com/alda-lang/alda/issues/46.

See that issue for context -- it's an interesting idea that needs more discussion.

daveyarwood avatar Nov 22 '16 11:11 daveyarwood

I had an interesting thought about this. It might be interesting if event sequences were a scoping mechanism. Meaning: attributes applied inside of an event sequence would be "undone" at the end of the event sequence. For example:

(vol 75) o3

# these notes are played at 75% volume, in octave 3
g a b

# these notes are played at 50% volume, in octave 4
[
  (vol 50) o4
  c d e f
]

# the event sequence is over, so we're back to 75% volume, octave 3
g b g

The only trouble is, this would be a breaking change, and I think it would make a lot of existing scores sound unexpectedly different.

It also seems like if we followed this train of thought, variable definitions would also have their own scope, i.e.:

myVariable = [
  (vol 50) o4
  c d e f g
]

(vol 75) o3

# 75% volume, octave 3
g a b a g a b

# 50% volume, octave 4
myVariable

# 75% volume, octave 3
g b g

But this would also be a breaking change from what we're used to. In particular, I have advocated in the docs that you can use variables as a shorthand for setting specific attribute values, e.g.:

quiet = (vol 50)
reallyQuiet = (vol 30)
loud = (vol 99)

loud c d e f
quiet c d e f
reallyQuiet c d e f

Both of these "scope styles" seem useful to me, and it isn't clear to me how to reconcile them.

Maybe we could add a second kind of event sequence (with a different syntax) that has its own scope for attributes (and maybe voices?), so that we could enable this sort of functionality in a non-breaking way?

daveyarwood avatar Jan 01 '21 20:01 daveyarwood

What about using an exclamation mark to create a scope?

(vol 75) o3 g a b
[! (vol 50) o4 c d e f]
g b g

Maybe we can develop more different sequences (denoted by adding a special symbol behind the [) with different practical functions, like [~ xxx] to denote a long slur (#378), etc.

UlyssesZh avatar Jul 20 '21 12:07 UlyssesZh