[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Self-awareness of functions?
- From: Drake Wilson <drake@...>
- Date: Wed, 29 Dec 2010 01:38:12 -0700
Quoth Dirk Laurie <dpl@sun.ac.za>, on 2010-12-29 10:22:22 +0200:
> fac = fact
> fact = "Napoleon escaped from Elba."
> fac(5)
I have not once seen a practical situation where this is a problem
specifically for self-recursive functions. If you don't want to write
to the resultant local, don't write to it. Yes, if you clobber the
function symbol you're in trouble. You could also write:
getmetatable('').__index.sub = 'kaboom'
but you don't, do you? In particular, I have never seen a case where
accidentally clobbering the symbol a function uses to recurse in that
way won't also horribly break something else, often in the same way
that clobbering a non-recursive function would: replace « fact = »
with « fac = » in the above and you still lose your ability to call
the function properly through the 'fac' symbol. The set of cases
where that doesn't matter, but having existing recursive invocations
still work is a priority, seems pretty negligible to me.
---> Drake Wilson