Empty procedure optimized out?

new topic     » topic index » view thread      » older message » newer message

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 thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu