SuperCollider * 标记构造函数方法不是预期的

SuperCollider * marking the constructor method is not expected

我试图创建一个 Class,但构造函数总是给我一个关于 *new 方法的语法错误,然后我只是从 documentation:

中复制了示例
MyClass {

  // this is a normal constructor method
  *new { | arga, argb, argc |
      ^super.new.init(arga, argb, argc)
   }

   init { | arga, argb, argc |
      // do initiation here
   }
}

仍然得到这个:

ERROR: syntax error, unexpected '*', expecting '}'
 in interpreted text
  line 6 char 5:
  
*new { | arga, argb, argc |
^
    ^super.new.init(arga, argb, argc)
-----------------------------------
ERROR: Command line parse failed
-> nil

从我自己的 class 我得到关于构造函数的相同错误。我哪里错了?

如果您查看写作 类 帮助文件,顶部有一点很容易忽略保存您的 classes 的位置。

https://depts.washington.edu/dxscdoc/Help/Guides/WritingClasses.html

NOTE: Class definitions are statically compiled when you launch SuperCollider or "recompile the library." This means that class definitions must be saved into a file with the extension .sc, in a disk location where SuperCollider looks for classes. Saving into the main class library (SCClassLibrary) is generally not recommended. It's preferable to use either the user or system extension directories.

Platform.userExtensionDir;   // Extensions available only to your user account

Platform.systemExtensionDir; // Extensions available to all users on the machine

It is not possible to enter a class definition into an interpreter window and execute it.

文件菜单下的另存为扩展名选项。然后重新编译解释器并尝试使用你的 class.