Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things

Re: Making my own control flow structure

by Ryszard (Priest)
on Oct 09, 2006 at 12:40 UTC ( [id://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
Domain Nodelet?
Node Status?
node history
Node Type: note [id://577157]
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others admiring the Monastery: (4)
As of 2024-04-23 20:11 GMT
Find Nodes?
    Voting Booth?

    No recent polls found