Is crawling the stack "bad"? Why?

Russell Warren russandheather at gmail.com
Thu Feb 28 23:06:24 EST 2008


> OK, if you crawl the stack I will seek you out and hit you with a big
> stick. Does that affect your decision-making?

How big a stick? :)

> Seriously, crawling the stack introduces the potential for disaster in
> your program, since there is no guarantee that the calling code will
> provide the same environment i future released. So at best you tie your
> solution to a particular version of a particular implementation of Python.

I'm gathering that the general argument is entirely centered around
portability and future-proofing of code.  This certainly makes sense.
I could try and argue that that doesn't matter for write-once-change-
never code, but anything I'd say there might as well be applied to an
argument saying that writing crappy code is actually ok.  And then I
would need to be committed for thinking that write-once-change-never
code actually exists.  I'm making myself sick as I type this.

> You might as well not bother passing arguments to functions at all,
> since the functions could always crawl the stack for the arguments they
> need.A major problem with this is that it constrains the caller to use
> particular names for particular function arguments.

You know, you're right!  Arguments are overrated.  All future code I
write will be argument free.  Just have to get rid of that pesky
"self" now.

I can't shake "'But I came here for an argument!'  'Oh... this is
abuse'" from my mind.

> What happens if two different functions need arguments of the same name?
> Seriously, forget this craziness.

I will (mostly)... I knew it was bad code and a total hack, I just was
looking for a concise reason as to why.

I appreciate the comments, guys... thanks!



More information about the Python-list mailing list