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)
Previous text:
2003-09-03 19:36: 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.
Should we add Array.zip and Array.unzip to merge and split arrays.
how does that work?
array a = ({ 1,3,5,7 }); array b = ({ 2,4,6,8 }); Array.zip(a,b); ({1,2,3,4,5,6,7,8});
zip and unzip sound rather unintuitive in what they would do.
No, its a zipper. The name is from Haskell, merd, Python, Scheme and SML, which has the functionality.
/ Martin Nilsson (ja till euro, nej till cent)