Path: csiph.com!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!feeder.erje.net!eu.feeder.erje.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 NNTP-Posting-Date: Thu, 08 Nov 2012 11:02:00 -0600 From: Chris Hinsley Newsgroups: comp.lang.forth Date: Thu, 8 Nov 2012 17:02:00 +0000 Message-ID: <2012110817020085080-chrishinsley@gmailcom> References: <2012110713421835115-chrishinsley@gmailcom> <2012Nov7.145519@mips.complang.tuwien.ac.at> <2012110715375130718-chrishinsley@gmailcom> <2012Nov8.173134@mips.complang.tuwien.ac.at> 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: 29 X-Usenet-Provider: http://www.giganews.com X-Trace: sv3-eD0jMuKfacZ4KKVFGOKhxLB5Zj3PwJjt1wHfwB/3z5HQxPS/1nUEf5grwm4HCsJe4TUPVW5RnAlY1Om!w2tm5b9ULikrwyh9C/vrwS17eekd4dqVRkRdGl19otlqUJbl5epUASclEHJjJimLpq+W6Fk= 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: 2519 Xref: csiph.com comp.lang.forth:17170 On 2012-11-08 16:31:34 +0000, Anton Ertl said: > Chris Hinsley writes: >>> However, the may thing I want to point out is that in my experience >>> it's a good idea if the wrapper word (LISTHEAD-ENUMERATE-FORWARDS in >>> this case) does not keep its data on the data stack during the >>> callback, and thus allows the caller to pass additional data to the >>> called-back word >> >> The u paramater here is exactly that ! A user data value, pointer to >> structure or whatever. It can be used to pass information to the >> callback or be used by the callback to pass data onto the next callback >> invocation etc. It's very flexable. > > It's even more flexible if you avoid any internal data on the data > stack during the callback, because that allows passing an arbitrary > number of stack elements into and out of the callback, not just one. > > - anton Yes, but then surely there will just be similar issues with marshalling multiple paramaters on the data stack in the callback and an arguement for just passing in a structure pointer and letting the callback accsess that structure as required ? It all get's tricky to judge the best approach, but I have this API used in other projects in C/C++, so kind of like the familiarity of how it works. Chris