[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Sc-devel] SynthDesc.read doesn't protect

On Feb 2, 2008 3:26 PM, James Harkins <jamshark70@xxxxxxxxx> wrote:
protect means, evaluate the 2nd function after the first (whether or not there is an error), and if there's an error, rethrow.

sorry, I did not understand what protect means.   I assumed it was like try / catch so it didn't seem to catch anything.

the Exception help file is clearest:

SuperCollider includes a variant, borrowed from Scheme, in which the exception is always fatal, but the preceding code might have allocated some resources that need to be released before reporting the error. For example, you might open a file and do some processing on it that might encounter an error.

file = File(path, "r");

protect {

work with the file here, which might cause an error

} {



What is the consequence of not having the Error().throw that you added? Do we *need* an full-out error?

SynthDescLib.global.read fails and cannot not explain why it failed.

Maybe a warning would suffice.

only if everything is properly cleaned up and the entire issue is fully handled.

since I don't have the time or knowledge to go through all of that just now, the best thing to do is to declare this a fatal error.

it can be demoted to a warning if the mess is cleaned up.

you are correct in the stuff below.


If the error is really needed, I think you need a protect block in SynthDesc:readSynthDef. The last thing in that method is

UGen.buildSynthDef = nil;

... which seems rather important to do in all cases, even if there's an error.


Index: SynthDesc.sc
--- SynthDesc.sc        (revision 7195)
+++ SynthDesc.sc        (working copy)
@@ -60,6 +60,8 @@
        readSynthDef { arg stream, keepDef=false;
                var numControls, numConstants, numControlNames, numUGens;
+               protect {
                inputs = [];
                outputs = [];
@@ -105,8 +107,11 @@
                        constants = nil;
-               UGen.buildSynthDef = nil;
+               } {
+                       UGen.buildSynthDef = nil;
+               }
        readUGenSpec { arg stream;

: H. James Harkins

: jamshark70@xxxxxxxxxxxxxxxxx

: http://www.dewdrop-world.net


"Come said the Muse,

Sing me a song no poet has yet chanted,

Sing me the universal."  -- Whitman