# Alternate syntax, commas in expression and literal #

I came accross this SynthDef. There’s variables a and b that are not defined, but are used as the in argument for PanAZ, as an array. A line above Out.ar there is `#a, b = sig;`

I’m just trying to figure out what is happening here. The # says “a” is a literal array, and that it and “b” are equal to “sig”??

I just don’t get what they are doing here, or how the `var1, var2 = var3` syntax works…:

``````(
SynthDef(\string, {
arg out=0, freq = 360, gate = 1, pan, amp=0.1;
var sig, eg, fc, osc, a, b, w;
fc = LinExp.kr(LFNoise1.kr(Rand(0.25,0.4)), -1,1,500,2000);
osc = Mix.fill(8, { LFSaw.ar(freq * [Rand(0.99,1.01),Rand(0.99,1.01)], 0, amp) }).distort * 0.2;
eg = EnvGen.kr(Env.asr(1,1,1), gate, doneAction: Done.freeSelf);
sig = eg * RLPF.ar(osc, fc, 0.1);

#a, b = sig;

Out.ar(out, Mix.ar(PanAz.ar(4, [a, b], [pan, pan+0.3])));
)
``````

Thanks!

Yes, this is arguably confusing.
`#` denotes a literal array when used when creating an array, e.g. `{arg arr = #[1, 2, 3]; ... }`.

Here however, it means that - assuming `sig` is an array - the two elements of the `sig` array will be assigned to variables `a` and `b`, respectively.

`#a, b = sig;`
is the same as

``````a = sig[0]
b = sig[1]
``````

Also, variables a and b are indeed defined in `var sig, eg, fc, osc, a, b, w;`. If they weren’t, they would be treated as global variables (this applies only to single letter variables in SC)

1 Like

I meant the variables “a” and “b” are “not declared”, not, “not defined”, haha.

I gotcha, thank you for your help. I just never saw that before… . I can see it being very useful actually.

See Multiple Assignment in sc help.

“A multiple assignment statement assigns the elements of a Collection which is the result of an expression on the right hand side, to a list of variables on the left hand side. A multiple assignment statement is preceded by the symbol `#` . If the last variable on the left is preceded by three dots, then the entire remainder of the collection is assigned to that variable. There must be at least one variable name before the ellipsis.”

Language docs are useful, though not organized into a neat sequence.

hjh