An extremely dumb question

I have a problem and isolated it down to a very simple but stupid hangup… I have simply two lines in an otherwise empty .scd file, they are:
line1: d = 123;
line2: dd = 123;

Why does this work

d = 123;
(outputs “-> 123”)

but this doesn’t:

dd = 123;
outputs: "ERROR: Variable ‘dd’ not defined.
in interpreted text
line 1 char 9:

dd = 123; "

I’m guessing what you have is this:

(
var dd;
d = 123;
dd = 123;
)

I don’t know how ‘dd’ would work without this.

all single letters are declared within the interpreter as ‘environment’ variables - you can use them freely, they are global (and I suggest avoiding that - especially since ’s’ is used by convention for the synthesis server).

However - if you were to evaluate that code block above - the var ‘dd’ ONLY has that code block as scope. evaluating just ‘dd’ outside those parens will be out of scope, and the interpreter doesn’t know what do do with it.

Hope that helps.

Josh

1 Like

Seems like that I know the answer of this.

In the tutorial page, you can find the description about why they are doing this at the bottom:

You may be wondering why we haven’t needed to declare variables like f, and why they don’t seem to have any particular scope (i.e. they keep their values even when executing code one line at a time). The letters a to z are what are called interpreter variables. These are pre-declared when you start up SC, and have an unlimited, or ‘global’, scope. This makes them useful for quick tests or examples. You’ve already encountered one of these, the variable ‘s’, which you’ll recall by default refers to the localhost server.

And, for why that is possible, at the bottom of document page of Interpreter, you will find that it defines all the single character identifier. This makes it possible to use them globally.

I am also new to SuperCollider, and now I am mainly working on tools for it, but not using this software itself. Hope what I wrote solves your question !

1 Like

I’d like to point out the fact that there are no dumb questions, only stupid answers.

4 Likes

thanks for the replies. I should have known this as I went over it when doing some introductory tutorials. I knew there was a special consideration for single character variables but wasn’t clear on it.