Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #16903
| From | Les Cargill <lcargill99@comcast.com> |
|---|---|
| Newsgroups | comp.lang.c, comp.lang.c++, comp.unix.programmer, comp.lang.javascript, comp.lang.lisp |
| Subject | Re: avcall, callback, trampoline, vacall, etc |
| Date | 2012-10-26 12:42 -0500 |
| Organization | A noiseless patient Spider |
| Message-ID | <k6ei2s$ivp$1@dont-email.me> (permalink) |
| References | <dfa26195-ed53-41e7-afb6-6f59d556a154@3g2000yqn.googlegroups.com> <k6dvjn$r9j$1@dont-email.me> <bde60f28-41e5-465a-862f-81844bb2d428@j12g2000vbm.googlegroups.com> |
Cross-posted to 5 groups.
gnuist007@hotmail.com wrote:
> On Oct 26, 5:27 am, Les Cargill <lcargil...@comcast.com> wrote:
>> gnuist...@hotmail.com wrote:
>>> Dear Programming Gurus,
>>
>>> These concepts are rather well talked about .. over the internet and
>>> usenet, however, I cant find any clear explanation.
>>
>>> avcall, callback, trampoline, vacall, etc
>>
>>> I looked in a book of C programming, ie k&r and also the rationale for
>>> C, an old copy and could not find any explanation.
>>
>>> I know that javascript books talk a lot about callbacks and there is
>>> the style of programming involving writing callbacks and registering
>>> them. Unfortunately, in the age when I took my C class, there was no
>>> discussion along these lines.
>>
>>> Can anyone give clear definition, example, benefits, variations,
>>> origin or citation to a paper where it originated and explained first,
>>> as well as some modern text that does the better than most job of
>>> illustrating it and its applications.
>>
>> "Callbacks" are a method of storing pointers to functions
>> and exploiting them.
>>
>> I'm answering from comp.lang.c so one thing I would start with is to
>> learn the concept of an ioctl(). It's one of the oldest ways to
>> do this sort of thing. Just google for "device driver programming in
>> linux" and follow some of the simpler examples. ioctl() is a pattern
>> that occurs quite frequently, in and out of kernel/driver
>> development.
>
> For starters, I always start with google and wikipedia. I could not
> find any examples.
>
> I am asking here so that you guys can give me whetted and good
> examples for a newbie.
>
Yes, you made that clear :). There is a superset of the callback()
concept embedded in developing device drivers. That's where Google
is helpful.
They offer trivial "device drivers" so you can learn the toolset.
The point is that device drivers are one of the most venerable
ways to do callbacks.
> there are books on defice driver programming. I need the part that you
> can make into a small paper. Give me a reference to read that you have
> read yourself and appreciate, maybe a citeseer link to paper etc.
>
So fill in the code I posted directly. It's a simple enough
example template. Try it, and ask questions if you get stuck.
It's not necessarily *worth* a paper; it's a couple dozen lines
of 'C'...
>>
>> After that, just do plain old callbacks in 'C' - declare...
>>
>> //a typedef
>>
>> typedef void (*cbtype)(char *);
>>
>> // an array of them
>>
>> cbtype cbtab[3];
>>
>> // an initializer
>>
>> void set_cb(cbtype a,int idx)
>> {
>> ...
>>
>> }
>>
>> // and reference the callbacks
>>
>> void thing(char *s)
>> {
>> ...
>>
>> }
>>
>> ...
>>
>> set_cb(thing,2);
>> cbtab[2]("Calling Elvis");
>>
>> --
>> Les Cargill
>
--
Les Cargill
Back to comp.lang.javascript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
avcall, callback, trampoline, vacall, etc gnuist007@hotmail.com - 2012-10-25 12:24 -0700
Re: avcall, callback, trampoline, vacall, etc James Kuyper <jameskuyper@verizon.net> - 2012-10-25 16:04 -0400
Re: avcall, callback, trampoline, vacall, etc Gene Wirchenko <genew@ocis.net> - 2012-10-25 14:55 -0700
Re: avcall, callback, trampoline, vacall, etc Paavo Helde <myfirstname@osa.pri.ee> - 2012-10-25 15:46 -0500
Re: avcall, callback, trampoline, vacall, etc Cortez <relativeflux@hotmail.co.uk> - 2012-10-25 13:47 -0700
Re: avcall, callback, trampoline, vacall, etc Joe Pfeiffer <pfeiffer@cs.nmsu.edu> - 2012-10-25 20:18 -0600
Re: avcall, callback, trampoline, vacall, etc gnuist007@hotmail.com - 2012-10-26 10:11 -0700
Re: avcall, callback, trampoline, vacall, etc "Pascal J. Bourguignon" <pjb@informatimago.com> - 2012-10-28 18:56 +0100
Re: avcall, callback, trampoline, vacall, etc Rivka Miller <rivkaumiller@gmail.com> - 2012-11-05 16:28 -0800
Re: avcall, callback, trampoline, vacall, etc Les Cargill <lcargill99@comcast.com> - 2012-10-26 07:27 -0500
Re: avcall, callback, trampoline, vacall, etc gnuist007@hotmail.com - 2012-10-26 10:16 -0700
Re: avcall, callback, trampoline, vacall, etc Les Cargill <lcargill99@comcast.com> - 2012-10-26 12:42 -0500
Re: avcall, callback, trampoline, vacall, etc James Kuyper <jameskuyper@verizon.net> - 2012-10-26 14:08 -0400
csiph-web