Skip to content

Instantly share code, notes, and snippets.

@scztt
Created March 21, 2026 14:52
Show Gist options
  • Select an option

  • Save scztt/9ee630f13c4cb0bce84af131ad9907af to your computer and use it in GitHub Desktop.

Select an option

Save scztt/9ee630f13c4cb0bce84af131ad9907af to your computer and use it in GitHub Desktop.
ThreadPostln {
classvar <>all, <>lastChar;
*initClass {
all = ();
lastChar = ();
}
}
+String {
postln {
thisThread.threadPostln(this);
}
post {
thisThread.threadPost(this);
}
prPostln {
_PostLine
^this.primitiveFailed
}
prPost {
_PostString
^this.primitiveFailed
}
}
+Thread {
name_{
|name|
ThreadPostln.all[this] = name
}
name {
^(ThreadPostln.all !? _[this] ?? {
parent !? _.name
})
}
postLastChar {
^(ThreadPostln.lastChar !? _[this])
}
threadPostln {
|str|
var threadName = this.name;
if (threadName.notNil) {
"[%] ".format(threadName).prPost;
};
str.prPostln;
}
threadPost {
|str|
if (this.postLastChar === "\n"[0]) {
if (this.name.notNil) {
"[%] ".format(this.name).prPost;
};
};
str.prPost;
ThreadPostln.lastChar !? { |e| e[this] = str.last };
}
}
(
Pdef(\foo, Pbind(
scale: Scale.hexSus,
degree: Pseq([1, 5, 4, 2, 8], inf).trace,
dur: 1/8,
)).play;
Pdef(\foo).player.routine.name = "Pdef(\\foo)";
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment