Thread Subject: how to determine whether called from evalc?

Subject: how to determine whether called from evalc?

From: Christian Herdtweck

Date: 6 Jun, 2008 13:44:01

Message: 1 of 3

Hi all you freaks,

  I know it is no good style to use eval and stuff, but
sometimes it is nice. But now it gets me in trouble...

  I have created my own versions of disp, display and
fprintf to do some post-processing with my output.
Unfortunately that gets me into trouble if what these
functions would print to the command window is actually
caught be evalc(..). I tried to insert a test using
dbstack() to see whether there is some evalc in the calling
stack but unfortunately it seems like eval and evalc never
appear in the stack (try e.g. "eval('dbstack')" which should
say 'eval' at least but does not).

  Does anybody have an idea how to find out whether my
function has been called by evalc or not?

  I also thought of using depfun but that seems to not tell
me about this either. Does anybody know another way (except
parsing the calling function's source code)?

  thanks
    Christian Herdtweck

Subject: how to determine whether called from evalc?

From: Ian Clarkson

Date: 6 Jun, 2008 14:23:01

Message: 2 of 3

"Christian Herdtweck"
<first_name.last_name@tuebingen.mpg.de> wrote in message
<g2bev1$fia$1@fred.mathworks.com>...
> Hi all you freaks,
>
> I know it is no good style to use eval and stuff, but
> sometimes it is nice. But now it gets me in trouble...
>
> I have created my own versions of disp, display and
> fprintf to do some post-processing with my output.
> Unfortunately that gets me into trouble if what these
> functions would print to the command window is actually
> caught be evalc(..). I tried to insert a test using
> dbstack() to see whether there is some evalc in the calling
> stack but unfortunately it seems like eval and evalc never
> appear in the stack (try e.g. "eval('dbstack')" which should
> say 'eval' at least but does not).
>
> Does anybody have an idea how to find out whether my
> function has been called by evalc or not?
>
> I also thought of using depfun but that seems to not tell
> me about this either. Does anybody know another way (except
> parsing the calling function's source code)?
>
> thanks
> Christian Herdtweck

could you create some intermediate function that sets a
variable saying that you're about to make an eval call, then
you can just check that variable whenever you need it?

Subject: how to determine whether called from evalc?

From: Christian Herdtweck

Date: 1 Sep, 2008 08:19:02

Message: 3 of 3

Hello Ian,

  sorry for the late reply, I was on holidays. Unfortunately
this solution does not work for me because I cannot change
all the code that might call evalc, some of it I do not even
know yet. But thanks a lot anyway

  Christian


"Ian Clarkson" <ovoidkumquat@hotmail.com> wrote in message
<g2bh85$bb4$1@fred.mathworks.com>...
> "Christian Herdtweck"
> <first_name.last_name@tuebingen.mpg.de> wrote in message
> <g2bev1$fia$1@fred.mathworks.com>...
> > Hi all you freaks,
> >
> > I know it is no good style to use eval and stuff, but
> > sometimes it is nice. But now it gets me in trouble...
> >
> > I have created my own versions of disp, display and
> > fprintf to do some post-processing with my output.
> > Unfortunately that gets me into trouble if what these
> > functions would print to the command window is actually
> > caught be evalc(..). I tried to insert a test using
> > dbstack() to see whether there is some evalc in the calling
> > stack but unfortunately it seems like eval and evalc never
> > appear in the stack (try e.g. "eval('dbstack')" which should
> > say 'eval' at least but does not).
> >
> > Does anybody have an idea how to find out whether my
> > function has been called by evalc or not?
> >
> > I also thought of using depfun but that seems to not tell
> > me about this either. Does anybody know another way (except
> > parsing the calling function's source code)?
> >
> > thanks
> > Christian Herdtweck
>
> could you create some intermediate function that sets a
> variable saying that you're about to make an eval call, then
> you can just check that variable whenever you need it?

Tags for this Thread

Everyone's Tags:

Add a New Tag:

Separated by commas
Ex.: root locus, bode

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Tag Activity for This Thread
Tag Applied By Date/Time
eval stack Christian Herdtweck 6 Jun, 2008 09:45:09
rssFeed for this Thread

Public Submission Policy

NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content. Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available via MATLAB Central. Read the complete Disclaimer prior to use.

Contact us at files@mathworks.com