Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW

Re: Making my own control flow structure

by Ryszard (Priest)
on Oct 09, 2006 at 12:40 UTC ( #577157=note: print w/replies, xml ) Need Help??

in reply to Making my own control flow structure

mmmm interesting question, care to share the problem you are trying to solve? TIMTOWTDI!
  • Comment on Re: Making my own control flow structure

Replies are listed 'Best First'.
Re^2: Making my own control flow structure
by Anonymous Monk on Oct 09, 2006 at 12:44 UTC
    I am writing a scripting language for test automation of a certain product for a certain company. One of the features of the language is that every function, whether or not it is executed should output something so it can be correctly audited by a test auditor. So there may be situations such as if(condition1){ doAction(1); } now in this situation, even if condition1 is not true, I still need doAction to print something out saying that it is not running because of condition1. I know I could do ... else{ print "Not doing doAction(1) because of condition1\n"; } but that is not sufficient for what I need. It's not standard, not auditable, and leaves the output up to the scripter (the language is supposed to be usable by non scripters) Hope that kinda explains my problem
      ok, so how about this:
      if ($condition) { &doAction; } else { print "doAction not executed due to a failure of $condition\n"; }
      if you have a whole bunch of $conditions then you could easily pregenerate the codeblock. cool, dynamic code... !
        I did discuss that in my reply. That solution is not enough, because the print statement is generated by the script writer, and therefore could be diffrent every time. I need a system where the output is generated automatically, so it is repeatable and auditable 100% of the time

      If you're writing a scripting language, then it's easy.

      Just write your if keyword in such a way that when a condition is not true you walk the AST of the then block and dump it as 'Not doing this, that or the other because of condition1', or whatever you need.

      But, more generally, this seems to be a barking mad thing to want to do. What are you going to do about nested ifs? Case statements? Loops? "None of these functions got executed because the loop terminated". If you continue down that road you could well end up with a situation where the audit information swamps the test output, which is in nobody's best interest. Any auditor worth their pay is going to be able to do a far better job of auditing by reading the code than they are by examining the entrails of a run trace.

      How about "None of these functions got run, because nobody executed the script"?

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://577157]
[oiskuu]: Someone needs to re-read How do I use the power of consideration responsibly? carefully. Consideration is not intended for stamping out humor, AFAIK.
[oiskuu]: E.g. Re^3: Big thank you to the Perl community. is surely dry humor (not mine). Don't they teach humor in german schools!?
[LanX]: you don't see the whole picture

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (13)
As of 2017-04-27 19:49 GMT
Find Nodes?
    Voting Booth?
    I'm a fool:

    Results (512 votes). Check out past polls.