questions, questions; always questions :)
- Posted by Hawke <mdeland at NWINFO.NET> Sep 06, 1998
- 501 views
this last round of optimizing simplistic functions (ABS for one) has left me with this real nagging question... *ponder*... how to explain this... hrmmmmmm take Carl's code to do abs for example: return x * (x>0) - (x<0) it's the part where (x>0) is actually looking at the ==whole== sequence. but you cannot do that here: if (x>0) then blah end if because at that point, x must be an atom or the resultant expression must be an atom to be more precise... so why can you make a comparison that involves an entire sequence or an operation that involves an entire sequence in a return line but cannot do the same thing in a ==real== comparison statement??? another example is supposing again x and y are a sequence you cannot do: if (x*3) > y then blah but you can do: return x*3 > y some would say that you should use compare! you can... sometimes... but not for Carl's example, for example--heh. if (compare(x,0)=1) - (compare(x,0)=-1 ) well that doesn't work for sequences cuz 0 is an atom... but compare(x*3,y)=1 would work for the other example... so why the disparity between return statements and any of the conditionals as to how they relate to sequences??? seems to me that if you were to have me choose which commands had more priority, ie: which ones were to get more beefed up interpretations, I woulda picked having the conditionals (if.then,while.do etc) being able to operate on entire sequences before I woulda picked having 'return' operate as it does... seems to me the conditionals are a "higher priority" type of situation as they are used more and and in fact are the ones that should be doing comparisions in the first place... return returns values, and conditionals check conditions. having return check conditions on that magnitude and the conditionals not being able to do that... but i'm not complaining :) --Hawke' (side note: jiri?? was it?? mentioned the counter-intuitive nature of compare... i figured out a way to think about compare that makes sense... if you don't think of it like: is x and y the same? but instead think: is x lessthan, equalto, or greaterthan y? which corresponds to compare equaling -1, 0 or 1... helps me... and i don't wind up forgetting that damned =0 and lest we forget the good ol'fashioned IsSame() command :)