Path: csiph.com!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!eternal-september.org!feeder.eternal-september.org!border3.nntp.ams.giganews.com!Xl.tags.giganews.com!border1.nntp.ams.giganews.com!nntp.giganews.com!local2.nntp.ams.giganews.com!news.giganews.com.POSTED!not-for-mail NNTP-Posting-Date: Thu, 08 Nov 2012 14:29:52 -0600 From: Chris Hinsley Newsgroups: comp.lang.forth Date: Thu, 8 Nov 2012 20:29:52 +0000 Message-ID: <2012110820295238952-chrishinsley@gmailcom> References: <2012110713421835115-chrishinsley@gmailcom> <509bb9a2$0$6999$882e7ee2@usenet-news.net> <2012110814115169871-chrishinsley@gmailcom> <2012110814312086525-chrishinsley@gmailcom> <2012110814515560672-chrishinsley@gmailcom> <509bf899$0$19587$882e7ee2@usenet-news.net> <2012110820040689990-chrishinsley@gmailcom> <2012110820173759604-chrishinsley@gmailcom> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1; format=flowed Content-Transfer-Encoding: 8bit Subject: Re: Genral advise and comments on callback style words User-Agent: Unison/2.1.9 Lines: 64 X-Usenet-Provider: http://www.giganews.com X-Trace: sv3-MCoYw4SvF+qne9AFAPDj0DV7CPi28w/sALXS5iDkEfEWK/3yJoxjyfIyCBHZr+X3i671ddoY/WZmvzP!fd3OHxT0ASL2IUKeBnlmiqsKwzHTloKrMBtJdhUDaSacYyC0CGEyJ4zMjO2vlngIV9Tfof4= X-Complaints-To: abuse@giganews.com X-DMCA-Notifications: http://www.giganews.com/info/dmca.html X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly X-Postfilter: 1.3.40 X-Original-Bytes: 3365 Xref: csiph.com comp.lang.forth:17182 On 2012-11-08 20:17:37 +0000, Chris Hinsley said: > On 2012-11-08 20:04:06 +0000, Chris Hinsley said: > >> On 2012-11-08 18:23:21 +0000, Josh Grams said: >> >>> Chris Hinsley wrote: <2012110814515560672-chrishinsley@gmailcom> >>>> On 2012-11-08 14:31:20 +0000, Chris Hinsley said: >>>>>> Josh Grams wrote: >>>>>>> >>>>>>> : LISTHEAD-ENUMERATE-FORWARDS ( u xt lh -- ln | 0 ) >>>>>>> TUCK SWAP 2>R >>>>>>> LISTHEAD-GET-HEAD BEGIN >>>>>>> 2DUP LISTNODE-GET-SUCC >>>>>>> DUP WHILE >>>>>>> 2R@ EXECUTE >>>>>>> ?DUP UNTIL ELSE NIP THEN >>>>>>> NIP NIP 2R> 2DROP ; >>>>> >>>>> Err, I'm not sure that works! You are skipping the first node. >>> >>> Yeah, sorry; I thought that's what your code was doing; see my response >>> to your first reply to mine. >>> >>>>> Isn't the 2DUP also blowing up the stack with an extra copy of the >>>>> original LH each time ? >>>> >>>> And it's not passing the user value into the callback at all ? >>> >>> In this case, EXECUTE is ( u ln lh xt -- ln | 0 ), right? So the 2DUP >>> provides two of those four items, and the 2R@ provides the other two. >>> >>> : LISTHEAD-ENUMERATE-FORWARDS ( u xt lh -- ln | 0 ) >>> TUCK SWAP 2>R LISTHEAD-GET-HEAD >>> BEGIN DUP WHILE ( u ln ) ( R: lh xt ) >>> 2DUP LISTNODE-GET-SUCC 2SWAP >>> 2R@ EXECUTE >>> ?DUP UNTIL THEN ( u ln ln|0 ) NIP NIP 2R> 2DROP ; >>> >>> --Josh > > Ah, no that crashes ! Reason is that you end up processing the end of > list marker, ie the bottom two thirds of the listheader as if it was an > actual node ! Nice try ! ;) > > Chris This however does work, but leaves me debateing that single PICK and ROT verses the 2SWAP 2DUP and the extra NIP needed at the ELSE ! \ ( u xt lh -- r | 0 ) \ xt api is ( u ln lh -- r | 0 ) : LISTHEAD-ENUMERATE-FORWARDS SWAP OVER 2>R LISTHEAD-GET-HEAD BEGIN 2DUP LISTNODE-GET-SUCC DUP WHILE 2SWAP 2R@ EXECUTE ?DUP UNTIL ELSE NIP THEN 2RDROP NIP NIP ; Chris