NNTP-Posting-Date: Wed, 07 Nov 2012 07:56:26 -0600 From: Chris Hinsley Newsgroups: comp.lang.forth Date: Wed, 7 Nov 2012 13:56:26 +0000 Message-ID: <2012110713562655972-chrishinsley@gmailcom> References: <2012110713421835115-chrishinsley@gmailcom> <2012110713512322818-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: 55 X-Usenet-Provider: http://www.giganews.com X-Trace: sv3-ypYc0u1qnB3MYA1sUoK2jM6tg/hiiTX8sq+UXtLNqA+DejvrEuNmpHgBlBGRsZhgrrPJVnFxq5fdf1s!9PzMI0Ls3IzrkL14PFcRep58b0t9DrtYcZz8X4kc6fPtLYpdl029THtMPn8zASZLGevDnbk= 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: 2959 Path: csiph.com!usenet.pasdenom.info!news.stben.net!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 Xref: csiph.com comp.lang.forth:17117 On 2012-11-07 13:51:23 +0000, Chris Hinsley said: > On 2012-11-07 13:42:18 +0000, Chris Hinsley said: > >> Folks I have implamented an Amiga style double linked list words set a >> few days back and I have an emueration word as follows: >> >> \ ( u xt lh -- ln | 0) >> \ xt api is ( u ln lh -- ln | 0 ) >> : LISTHEAD-ENUMERATE-FORWARDS >> 0 >R >> DUP LISTHEAD-GET-HEAD DUP >> BEGIN >> NIP DUP LISTNODE-GET-SUCC >> DUP >> WHILE >> 4 PICK 2 PICK 4 PICK >> 6 PICK EXECUTE DUP R! >> UNTIL THEN >> 2DROP 2DROP DROP >> R> >> ; >> >> This scans down the list until either it hits the end, or the callback >> for each node returns a value other than 0, that value is returned and >> the scan stops if it isn't 0 ! >> >> I'd like comments and advice on techniuqe, paticularly for things like >> the PICK stuff that gathers paramaters for each callback, and the use >> of the return stack for the returned value. Or if you just plain think >> I could code this a better way ! >> >> I'm not wanting to be pointed to "the novice package", thank you, but >> want this API as stated ! ;) >> >> Regards all >> >> Chris > > I should also add that I wish to retain the 'look ahead' pointer to the > next node as the callback word must be allowed to remove or modify the > node it gets handed ! So the 'NIP DUP LISTNODE-GET-SUCC' is the bit > doing that. > > Chris Plus I do need to pass the list head into the callback, as they are allowed to add elements to the list as a result of scanning it etc. For example I have a 2D rectangle patch list and callbacks that can cut, paste or copy new patches to/from the list, as the callback slices and dices patches on the list new entires are add to the front of the list etc, and the current node can be removed entirely... Chris