Discussion:
Call-Site Code Replacement
(too old to reply)
Jan Burse
2012-10-22 17:58:57 UTC
Permalink
Dear All,

I just wonder whether it is possible in a functional
language to do call site replacement. I envision this
as a special form of lazyness.

Basically I would call somewhere a function f
with an argument a:

... (f a) ...

The function would then manage to replace itself
by a function g with an argument b:

... (g b) ...

So that the next time the original call site of (f a)
is invoked in fact (g b) is invoked.

Hints welcome.

Bye
Stefan Palme
2012-10-22 20:39:52 UTC
Permalink
Post by Jan Burse
... (f a) ...
The function would then manage to replace itself by a function g with an
... (g b) ...
Isn't this the same as simply defining

f a = g b

?

Whenever you call (f a), you get (g b) instead...

-stefan-
Jan Burse
2012-10-22 21:20:23 UTC
Permalink
Post by Stefan Palme
Isn't this the same as simply defining
f a = g b
If I would be able to specify a dynamic inlining strategy, yes.

Continue reading on narkive:
Loading...