1. Empty procedure optimized out?

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

new topic     » topic index » view message » categorize

2. Re: Empty procedure optimized out?

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.

new topic     » goto parent     » topic index » view message » categorize

3. Re: Empty procedure optimized out?

Tone Škoda wrote:
> It would be much more logical if someFunction would not be executed.
> 


on second thought maybe not

new topic     » goto parent     » topic index » view message » categorize

4. Re: Empty procedure optimized out?

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

new topic     » goto parent     » topic index » view message » categorize

5. Re: Empty procedure optimized out?

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/

new topic     » goto parent     » topic index » view message » categorize

6. Re: Empty procedure optimized out?

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>

new topic     » goto parent     » topic index » view message » categorize

7. Re: Empty procedure optimized out?

(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>
> 
>

new topic     » goto parent     » topic index » view message » categorize

8. Re: Empty procedure optimized out?

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

new topic     » goto parent     » topic index » view message » categorize

9. Re: Empty procedure optimized out?

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

new topic     » goto parent     » topic index » view message » categorize

10. Re: Empty procedure optimized out?

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

new topic     » goto parent     » topic index » view message » categorize

11. Re: Empty procedure optimized out?

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!

new topic     » goto parent     » topic index » view message » categorize

12. Re: Empty procedure optimized out?

(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!
> 
>

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu