These are chat archives for supercollider/supercollider

27th
Feb 2017
Nathan Ho
@snappizz
Feb 27 2017 07:48
@brianlheim Good call, best not to clutter the primitives with bullshit that we'll regret later
Brian Heim
@brianlheim
Feb 27 2017 18:18
yup. i've never actually written a functioning primitive before so that was a fun experience though
this all boils down to a design problem IMO—the parser is not written to be tested as a separate component.
Nathan Ho
@snappizz
Feb 27 2017 21:02
Would it be worthwhile to write up a language spec for sclang at some point?
Brian Heim
@brianlheim
Feb 27 2017 21:06
i don't want to do it, but it would be nice to have
it wouldn't be mentally demanding work, the bison file == the spec, and the tokenization rules are implied in PyrLexer
i think 'writing up a spec' would be more of a diagnostic process that could accompany a rewriting of the ruleset. having looked it over yesterday while I was composing tests for the parser, I'm of the opinion that actually stating all the rules in english would reveal a lot of inconsistencies and redundancy
Nathan Ho
@snappizz
Feb 27 2017 21:12
A fun fact I recently discovered: y(x) = 3 is equivalent to x.y = 3
Brian Heim
@brianlheim
Feb 27 2017 21:16
hah
every language has its quirks... in C, if you have an array char a[10];, the statements a[6] and 6[a] are equivalent
Nathan Ho
@snappizz
Feb 27 2017 21:17
Also, key binary operators can take adverbs: foo bar:.baz quux is valid
Brian Heim
@brianlheim
Feb 27 2017 21:19
haha
hm if i add .size to one of the smaller parser test alphabets, that one is actually covered
by the test [abc, abc, :, .size, abc]
Nathan Ho
@snappizz
Feb 27 2017 21:21
Adverbs were a mistake. I've never seen them used in the wild
Brian Heim
@brianlheim
Feb 27 2017 21:21
i've seen them in an SC tweet
they can be pretty concise for array manipulations
[1,2,3,4] pow:.x [1,2]
but, the rules are arcane and obscure compared to the rest of the language
oh also one of my favorite things that i keep forgetting and remembering is that SC has a configurable preprocessor

thisProcess.interpreter.preProcessor_(_.tr($?, $.))

3?pow(5?2)

Nathan Ho
@snappizz
Feb 27 2017 21:25
I didn't know about that until a month or so ago, haha
Brian Heim
@brianlheim
Feb 27 2017 21:25
so you could implement the C preprocessor in SC
Nathan Ho
@snappizz
Feb 27 2017 21:26
I'm curious exactly what the scope of the preprocessor is
Brian Heim
@brianlheim
Feb 27 2017 21:26
or really any language honestly
Nathan Ho
@snappizz
Feb 27 2017 21:26
Does it affect .interpret, e.g.
it does apparently
So if you have a quark or something that uses .interpret (yuck), modifying the preprocessor could fuck it up
Brian Heim
@brianlheim
Feb 27 2017 21:27
how are you testing that?
Nathan Ho
@snappizz
Feb 27 2017 21:28
the wrong way apparently
Brian Heim
@brianlheim
Feb 27 2017 21:28
thisProcess.interpreter.preProcessor_(nil)
a = "3?pow(5?2)"
thisProcess.interpreter.preProcessor_(_.tr($?, $.))
a.interpret
produces an error
if you did "3?pow(5?2".interpret, it would replace the ?'s in the string beforehand
Nathan Ho
@snappizz
Feb 27 2017 21:28
oops
Brian Heim
@brianlheim
Feb 27 2017 21:29
which is its own level of :(
Nathan Ho
@snappizz
Feb 27 2017 21:29
so it only affects interactively executed code
Brian Heim
@brianlheim
Feb 27 2017 21:29
except not really, because you can just configure the preprocessor to ignore things between quotes
well, interpreter is an instance, not a singleton, so each process has its own interpreter with its own preprocessor
it's very inceptiony
i love how much reflection SC offers
Nathan Ho
@snappizz
Feb 27 2017 21:33
yeah it's actually a pretty nice language
Brian Heim
@brianlheim
Feb 27 2017 21:35
i was talking to someone from the NY SC group who's basically developing a strong-typed version of SC within SC?
i'm not exactly sure how that's going to work out
but i was intrigued
Nathan Ho
@snappizz
Feb 27 2017 21:41
supercollider/supercollider#2752
Brian Heim
@brianlheim
Feb 27 2017 21:42
nice. would you mind also clarifying that the passed function takes a code string as an argument and returns the processed result?
oh actually, it gets passed two arguments - the code string and the interpreter itself
also, if you sufficiently fuck up the preProcessor, you have to recompile the class library because you'll be unable to interpret the code that would reset it
Nathan Ho
@snappizz
Feb 27 2017 21:49
i just found something weird
preProcessor is called by interpretPrintCmdLine, but not interpretCmdLine
what's the difference between those?
Brian Heim
@brianlheim
Feb 27 2017 22:01
i think interpretCmdLine is the more bare-bones version
it's basically the same as .interpret