Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.soft-sys.math.mathematica > #8916 > unrolled thread

Using Throw/Catch in MeshFunctions doesn't work? (8.0.4)

Started bybradc355113@yahoo.com
First post2012-03-08 09:37 +0000
Last post2012-03-09 11:11 +0000
Articles 2 — 1 participant

Back to article view | Back to comp.soft-sys.math.mathematica


Contents

  Using Throw/Catch in MeshFunctions doesn't work? (8.0.4) bradc355113@yahoo.com - 2012-03-08 09:37 +0000
    Re: Using Throw/Catch in MeshFunctions doesn't work? (8.0.4) bradc355113@yahoo.com - 2012-03-09 11:11 +0000

#8916 — Using Throw/Catch in MeshFunctions doesn't work? (8.0.4)

Frombradc355113@yahoo.com
Date2012-03-08 09:37 +0000
SubjectUsing Throw/Catch in MeshFunctions doesn't work? (8.0.4)
Message-ID<jj9uld$dqp$1@smc.vnet.net>
I've written a function that uses Throw/Catch internally, and I'm having trouble using it in the MeshFunctions option in Plot3D. My Catches seem to be disabled in this case -- I get an "Uncaught Throw" error. My function works fine in other scenarios.

Here's a simple example that generates the Throw::nocatch error:

Plot3D[x^2 + y^2, {x, -1, 1}, {y, -1, 1}, MeshFunctions -> {Catch[Throw[#1 #2]]&}]

Is this a bug, or am I not understanding something?

(I've been able to get my function to work as a MeshFunction by modifying it to use Goto/Label instead of Catch/Throw, but bleh goto.)

Any info would be appreciated. :)
Thanks,
Brad C

[toc] | [next] | [standalone]


#8937

Frombradc355113@yahoo.com
Date2012-03-09 11:11 +0000
Message-ID<jjcoho$q9g$1@smc.vnet.net>
In reply to#8916
Oops, the Goto/Label workaround that I described previously doesn't actually seem to work either. I get a "Label not found" error. Again, this only happens when used in the MeshFunctions option. In other scenarios the Goto/Label work fine.

Here's a simple example that generates the Goto::nolabel error:

Plot3D[x^2 + y^2, {x, -1, 1}, {y, -1, 1}, MeshFunctions -> {(Goto[tag]; Label[tag]; #1 #2) &}]

My workaround now is to use nested If statements like this:

f[...] := Module[
    {ret},
    DoStepA[];
    If[StepAFailed[],
        Message[...]; ret = $Failed,
        (* else success so far *)
        DoStepB[];
        If[StepBFailed[],
            Message[...]; ret = $Failed,
            (* else success so far *)
            ...
            ret = DoFinalCalculation[]
        ]
    ];
    ret
]

Plot3D[..., MeshFunctions -> {f[#1, #2] &}]

[toc] | [prev] | [standalone]


Back to top | Article view | comp.soft-sys.math.mathematica


csiph-web