That's stupid. The teacher should of course show the student a refactoring tool which can do the rename while automatically preserving semantics. :-)
/ Marcus Comstedt (ACROSS) (Hail Ilpalazzo!)
Previous text:
2003-09-04 17:08: Subject: Re: Language comparisions
Should we have an identity function for the fun of it (Haskell has id and Smalltalk has yourself)?
how is that different from this_object() ?
It would be an this_function() or a magic variable this_function. No, I don't know what it should be used for.
I belive (as in 'don't know for sure') that this_function() would be used to reduce the possibility of function renaming errors when writing recursive functions.
Student code:
// Recursive function that returns !n int oink(int n) { if(n == 0) return 1; else return oink(n-1); }
Teacher comment: rename function fac New student code:
// Recursive function that returns !n int fac(int n) { if(n == 0) return 1; else return oink(n-1); }
Which of course is trivial to detect in this simple function, but could have been avoided by writing
int oink(int n) { if(n == 0) return 1; else return this_function(n-1); }
Perhaps it could also be of use when a function is passed around in a variable - I'm not sure.
/ Peter Lundqvist (disjunkt)