How to forcibly override a built-in core method using Quarks

Hi there,

I am revising a draft of my being tested quark. I would like to have the method cpsoct in this Quark which overrides the built-in core method cpsoct. When evaluating MethodOverride.printAll after recompiling the sc libraries after adding the following line in a SC file in my Quark:

+ SimpleNumber {
	cpsspn {
		arg style = \lily;
		^SPN.midi(this.cpsmidi, style)
	cpsoct {
	midispn {
		arg style = \lily;
		^SPN.midi(this, style)
	midioct {

there are the following lines where sclang returns in the post window:

Overwritten methods in class library:

		/Users/prko/Library/Application Support/SuperCollider/downloaded-quarks/Notator/Classes/
		/Users/prko/Dropbox/prko/__myDocs/Writings/Making Sound using Open Sources/mixed/dev - Bleeding edge/

However, when evaluating the following code:


the built-in core method is still applied and my quark does not affect it.
How could I override a built-in core method using quarks?

I have also found the following warning:

WARNING: Extension in '/Users/prko/Library/Application Support/SuperCollider/downloaded-quarks/Notator/Classes/' overwrites SimpleNumber:cpsoct in main class library.
Intentional overwrites must be put in a 'SystemOverwrites' subfolder.

I also found the following warning

I did not know where the SystemOverwrites folder was. Using the Finder’s ‘Find’ feature, I was able to understand how to save this part. Currently, the part I asked about in the previous post is stored in /Users/prko/Library/Application Support/SuperCollider/downloaded-quarks/Notator/Classes/SystemOverwrites/ There is no warning anymore, but the method I want to use is still unaffected, but the built-in core method of SimpleNumber is affected.

You cannot override it. Why do you want to do this?

1 Like

This is because it’s not a method call – it’s a special unary math op.

{ 1.cpsoct }.def.dumpByteCodes

  0   64       PushSpecialValue 1
  1   B0       TailCallReturnFromFunction
  2   0D 18    SendSpecialUnaryArithMsgX 'cpsoct'
  4   F2       BlockReturn

AFAICS, “SendSpecialUnaryArithMsgX” in this context means you will need to name your method differently.


1 Like

The method I made is very similar to the built-in method and has only a short explanation before output, so I think my method can replace the built-in method for future users of my Quarks, if any. However, it seems better to use a different method name.

Thanks for the clarification!

Oh! I clearly understood why it could not be overridden! Thank you so much!