From: Sam S. <sd...@gn...> - 2017-12-22 16:56:06
|
Hi, > * <Wbret-Plevy.Ubruyr@g-flfgrzf.pbz> [2017-12-22 10:52:46 +0000]: > > Sam Steingold wrote: >> (and the committee did not reach a consensus because implementing this >> behavior is relatively hard > > Uh? Implementations are mentioned (old Genera, MIT LOOP) and they did no > particular magic. Yes, but those that did not do that, had a hard time implementing it. But this is not relevant. > Here we have some fundamental disagreement. I claim that LOOP should > not be hard because no used expects it to expand into some too clever > magic that would require special operators not yet invented that, Users don't care about how LOOP is implemented. They care that it works as naively expected based on its text. > would prevent code walking projects out there from processing > clisp's LOOP -- not a good idea. No, the special operator TAGLET will have a macroexpansion (based on your code) which will keep code walkers working. > - from (loop for x on list finally (return x) ; some want nil, others > the last restlist last restlist?! okay, I can imagine people wanting this. > - from (loop for x below N finally (return x) ; some want N-1 (undefined > if N<=0), others N! hah! here is an argument for nil above and N here: undefined is _never_ a good value, so, for consistency, it should always be N and nil. ;-) > But that's left for a future 2018 "About values in the LOOP epilogue". > I'll be off email for the next 3 weeks. Enjoy your vacation! >>> (loop for a = (princ 1) then b for b below (princ 2) do (princ (list a b))) >>> would print 21 by that proposal. >>This behavior does not stand the WTF test. > [...] >>if VARS is bound to non-NIL, this does not stand the WTF test. > > Please explain WTF. "What the f**k?!" this is the reaction you have when told that `(loop for x in '(1 2 3) collect x)` should return `(3 2 1)` ;-) > Is this test case not relevant? Don't you want to > assign semantics to this form? No, it's just that the user sees (princ 1) before (princ 2) and he will never accept "21" as output. Cf. this with the pandas sum([]) issue. Mathematically, the associativity of addition requires sum([])==0. However, they changed it to NA for some absurd reasons (consistency with SQL) - and that started a firestorm. We do not want to go the same path. LOOP users should never have the WTF feeling long enough to file a bug report ;-) >>Let us start with code samples and what they should return, not with >> "how we should macroexpand LOOP". > > You are right, I have code samples in mind constantly, but nowhere in > the text. I am glad we agree. The right sequence is: * test cases which we agree upon * spec which describes the tests * implementation that conforms to the spec This is similar to the scientific process: * experiments where we observe the nature * theory that predicts the experimental outcome * machine that uses the theory to perform useful work >> (let ((x '(a b c d))) (loop repeat 2 for x in x collect x)) >>==> (a b) > Sure. Where is the problem? I see no problem at all. That's the semantic > I want to give it. Yes, that's what I meant - this is the correct behavior. I am glad we agree! I would even add --8<---------------cut here---------------start------------->8--- (let ((x '(a b c d)) y) (list (loop repeat 2 for x in x collect x finally (setq y x)) y)) ==> ((a b) c) --8<---------------cut here---------------end--------------->8--- (although SBCL returns ((A B) B)). Thanks! -- Sam Steingold (http://sds.podval.org/) on darwin Ns 10.3.1504 http://steingoldpsychology.com http://www.childpsy.net http://memri.org http://thereligionofpeace.com http://iris.org.il http://no2bds.org Your mouse has moved - WinNT has to be restarted for this to take effect. |