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

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




On Feb 1, 2008, at 9:52 PM, felix wrote:

there's a protect around this:
*read { arg path, keepDefs=false, dict;

but it didn't work.  I had redXMplayer.synthdef in my synthdefs folder, but the UGen and file are missing right now.

I fixed SynthDesc so that it throws an error


ERROR: No UGen class found for  RedPhasor  which was specified in synth def:  redXMplayer

but I don't get why the protect didn't work.

What do you mean by "protect didn't work"? (You've been around long enough to know -- "didn't work" is useless for troubleshooting. Be specific.)

protect means, evaluate the 2nd function after the first (whether or not there is an error), and if there's an error, rethrow.

try means, evaluate the 2nd function after the first ONLY IF there is an error, and don't rethrow the error.


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

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.

hjh

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;
                };
                this.makeMsgFunc;
-               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