1. Empty procedure optimized out?
- Posted by Tommy Carlier <tommy.carlier at telenet.be> Nov 19, 2004
- 588 views
Robert, couldn't you remove calls to empty procedures while parsing a program? I have a procedure to ignore the return value of a function, that looks like this:
global procedure ignore(object ignored) -- ignores its parameter end procedure
And it's used like this:
ignore(someFunction(someParameter1, someParameter2))
The function 'someFunction' should be executed, but the call to the empty procedure could be removed. That could also optimize this situation:
constant DEBUG = 0 procedure writeToLog(sequence line) if DEBUG then puts(logfile, line & '\n') end if end procedure
'if DEBUG then' can be removed, because you know before running the code than it will never be called. That makes the 'writeToLog'-procedure an empty procedure that can be optimized out. -- Recycle your pets. tommy online: http://users.telenet.be/tommycarlier tommy.blog: http://tommycarlier.blogspot.com
2. Re: Empty procedure optimized out?
- Posted by Tone Škoda <tskoda at email.si> Nov 19, 2004
- 539 views
- Last edited Nov 20, 2004
Tommy Carlier wrote: > > Robert, couldn't you remove calls to empty procedures while parsing > a program? ... > And it's used like this: > }}} <eucode> > ignore(someFunction(someParameter1, someParameter2)) > </eucode> {{{ > The function 'someFunction' should be executed, but the call to the > empty procedure could be removed. It would be much more logical if someFunction would not be executed.
3. Re: Empty procedure optimized out?
- Posted by Tone Škoda <tskoda at email.si> Nov 19, 2004
- 546 views
- Last edited Nov 20, 2004
Tone Škoda wrote: > It would be much more logical if someFunction would not be executed. > on second thought maybe not
4. Re: Empty procedure optimized out?
- Posted by Robert Craig <rds at RapidEuphoria.com> Nov 19, 2004
- 557 views
- Last edited Nov 20, 2004
Tommy Carlier wrote: > > Robert, couldn't you remove calls to empty procedures while parsing > a program? I have a procedure to ignore the return value of a function, > that looks like this: > }}} <eucode> > global procedure ignore(object ignored) > -- ignores its parameter > end procedure > </eucode> {{{ > And it's used like this: > }}} <eucode> > ignore(someFunction(someParameter1, someParameter2)) > </eucode> {{{ > The function 'someFunction' should be executed, but the call to the > empty procedure could be removed. That could also optimize this > situation: > }}} <eucode> > constant DEBUG = 0 > > procedure writeToLog(sequence line) > if DEBUG then > puts(logfile, line & '\n') > end if > end procedure > </eucode> {{{ > > 'if DEBUG then' can be removed, because you know before running the > code than it will never be called. That makes the 'writeToLog'-procedure > an empty procedure that can be optimized out. Thanks. I'll add it to my list of possible optimizations. By the way, this was too trivial for the release notes, but I took out the warning about parameters declared but not used. Regards, Rob Craig Rapid Deployment Software http://www.RapidEuphoria.com
5. Re: Empty procedure optimized out?
- Posted by cklester <cklester at yahoo.com> Nov 19, 2004
- 578 views
- Last edited Nov 20, 2004
Robert Craig wrote: > By the way, this was too trivial for the release notes, > but I took out the warning about parameters declared but not used. Rob, that's about the only reason I ever used "with warning!" You gotta keep that in there. :) How else am I gonna get rid of the extraneous declarations?! -=ck "Programming in a state of EUPHORIA." http://www.cklester.com/euphoria/
6. Re: Empty procedure optimized out?
- Posted by Pete Lomax <petelomax at blueyonder.co.uk> Nov 20, 2004
- 541 views
On Fri, 19 Nov 2004 13:58:55 -0800, Robert Craig <guest at RapidEuphoria.com> wrote: >By the way, this was too trivial for the release notes, >but I took out the warning about parameters declared but not used. <shakes head in despair> You think no-one wanted to know you'd done that!!?? A very simplistic cop-out to deal with the problem, IMNSHO. BTW, there /are/ some cases when that warning should remain. </shakes head in despair>
7. Re: Empty procedure optimized out?
- Posted by CoJaBo <CoJaBo_EUforum_Address at CJBN.net> Nov 20, 2004
- 529 views
(attempt 2, first one seems to have failed to send due to router trouble...) Pete Lomax wrote: > > On Fri, 19 Nov 2004 13:58:55 -0800, Robert Craig > <guest at RapidEuphoria.com> wrote: > > >By the way, this was too trivial for the release notes, > >but I took out the warning about parameters declared but not used. That is probably the most annoying "feature" of Eu. I for one am glad at its demise! > > <shakes head in despair> > You think no-one wanted to know you'd done that!!?? > A very simplistic cop-out to deal with the problem, IMNSHO. > BTW, there /are/ some cases when that warning should remain. > </shakes head in despair> > >
8. Re: Empty procedure optimized out?
- Posted by Patrick Barnes <mrtrick at gmail.com> Nov 20, 2004
- 540 views
On Fri, 19 Nov 2004 18:08:37 -0800, CoJaBo <guest at rapideuphoria.com> wrote: > > On Fri, 19 Nov 2004 13:58:55 -0800, Robert Craig > > <guest at RapidEuphoria.com> wrote: > > > > >By the way, this was too trivial for the release notes, > > >but I took out the warning about parameters declared but not used. > That is probably the most annoying "feature" of Eu. > I for one am glad at its demise! But you can turn it off! And unless you're using a library that has call-backs, if you see the warning, it means that there's something that you should do about it. I'd like to have seen the warning remain... but maybe some flag to stop the warnings appearing in those call_back functions? In any case, a simple 'without warning' fixed all the remaining warnings when your code was ready for release. -- MrTrick
9. Re: Empty procedure optimized out?
- Posted by "Juergen Luethje" <j.lue at gmx.de> Nov 20, 2004
- 558 views
Robert Craig wrote: > Tommy Carlier wrote: >> >> Robert, couldn't you remove calls to empty procedures while parsing >> a program? <snip> That would be great! > Thanks. I'll add it to my list of possible optimizations. > > By the way, this was too trivial for the release notes, > but I took out the warning about parameters declared but not used. Previously, we could turn it off by using without warning if we wanted to do so. But now, we can *not* turn it on, if we want to do so. May I ask you please to reconsider this decision? Regards, Juergen
10. Re: Empty procedure optimized out?
- Posted by Robert Craig <rds at RapidEuphoria.com> Nov 20, 2004
- 573 views
- Last edited Nov 21, 2004
Juergen Luethje wrote: > Robert Craig wrote: > > By the way, this was too trivial for the release notes, > > but I took out the warning about parameters declared but not used. > > Previously, we could turn it off by using > without warning > if we wanted to do so. > > But now, we can *not* turn it on, if we want to do so. > May I ask you please to reconsider this decision? There's a line of code commented out in symtab.e line 510
or equal(vtype, "parameter") -- this is rarely a real problem
If you put that back in, eu.ex will report the warning. You always have to strike a balance when reporting warnings. You'd like to catch legitimatate problems, but you don't want to generate a lot of false alarms. In this case I felt the false alarm rate was maybe 100x the legitimate problem rate, so I took it out. For instance, people might be calling a set of routines via call_proc() or call_func(), and some of those targetted routines might not use all of the arguments that are passed to them. The situation is different with other private variables. If you get a warning that one of those was declared but not used, it's a simple matter to remove the useless declaration. Those warnings remain. Most of them are legitimate. Regards, Rob Craig Rapid Deployment Software http://www.RapidEuphoria.com
11. Re: Empty procedure optimized out?
- Posted by Tony Steward <tony.steward at gmail.com> Nov 21, 2004
- 545 views
Here Here please reconsider I want the warnings. regards Tony Steward On Sat, 20 Nov 2004 12:27:44 +0100, Juergen Luethje <j.lue at gmx.de> wrote: > > Robert Craig wrote: > > > Tommy Carlier wrote: > >> > >> Robert, couldn't you remove calls to empty procedures while parsing > >> a program? > > <snip> > > That would be great! > > > Thanks. I'll add it to my list of possible optimizations. > > > > By the way, this was too trivial for the release notes, > > but I took out the warning about parameters declared but not used. > > Previously, we could turn it off by using > without warning > if we wanted to do so. > > But now, we can *not* turn it on, if we want to do so. > May I ask you please to reconsider this decision? > > Regards, > Juergen > > > > -- Regards Tony Steward www.locksdownunder.com IF IT IS TO BE IT IS UP TO ME!
12. Re: Empty procedure optimized out?
- Posted by CoJaBo <CoJaBo_EUforum_Address at CJBN.net> Nov 21, 2004
- 555 views
(Take 2, stupid router) Tony Steward wrote: > > Here Here please reconsider I want the warnings. Those warnings only affect routine parameters, not other variables. Those warnings seem to have no real use. > > regards > Tony Steward > > > On Sat, 20 Nov 2004 12:27:44 +0100, Juergen Luethje <j.lue at gmx.de> wrote: > > > > Robert Craig wrote: > > > > > Tommy Carlier wrote: > > >> > > >> Robert, couldn't you remove calls to empty procedures while parsing > > >> a program? > > > > <snip> > > > > That would be great! > > > > > Thanks. I'll add it to my list of possible optimizations. > > > > > > By the way, this was too trivial for the release notes, > > > but I took out the warning about parameters declared but not used. > > > > Previously, we could turn it off by using > > without warning > > if we wanted to do so. > > > > But now, we can *not* turn it on, if we want to do so. > > May I ask you please to reconsider this decision? > > > > Regards, > > Juergen > > > > > -- > Regards > Tony Steward > www.locksdownunder.com > > IF IT IS TO BE IT IS UP TO ME! > >