".ar" after parentheses

Hi, I would like to know, because I have not found explanation anywhere, what is the difference in placing in the declaration of an envelope “.ar” before the arguments inside parentheses or after like the following:
env = Env.new(
[\atk.ir(0), \sus.ir(0.03), \rel.ir(0)],
And also the meaning of the number 2 in parenthesis.

.ar is a method like any other, nothing special. That means it always applies to a receiver and it’s the receiver that determines the meaning.

In SinOsc.ar, the receiver is the class named SinOsc, and the meaning is to create an audio-rate instance of SinOsc.

Env.new( ... args ... ) creates an instance of an envelope. Putting .ar after this calls ar on the Env instance – the Env object is the receiver. So Env’s instance method ar determines the meaning, which here is a shortcut for creating an EnvGen for the given envelope.

Before/after parentheses is not the right mental category – it should be, what is the receiver?

Incidentally this is why I’ve come to dislike shortcuts like this one – they confuse incoming users. I avoid this construction in my own code and I tend to write EnvGen.ar explicitly.



Perfectly understood, thank you very much!!

you could also write ar(SinOsc, 440, ar(SinOsc))