List Info

Thread: Re: "ocaml_beginners"::[] Re: multiple callbacks




Re: "ocaml_beginners"::[] Re: multiple callbacks
country flaguser name
Germany
2007-09-21 13:35:12
Am Freitag 21 September 2007 09:21:16 schrieb Florent
Monnier:
>
>   register_sample_file_type("mp3", load_mp3,
NULL);
>   register_sample_file_type("ogg", load_ogg,
NULL);
>
> So as you can see here, the function
register_sample_file_type() can be
> called with *several* different callbacks, in this
example the correct
> callback will be called according to the file type when
the user calls
>   load_sample(filename);

yes, it looks like storing the function pointer in a map
with the filetype as 
key.

But what is the difference to "Callback.register name
fun" ?
Callback.register can be called with *several* different
callbacks too. It 
does the same: it stores a callback which can be found using
the given name 
as key.

> As said previously a hack have to be found to bind this
kind of functions,
> since the method given in the ocaml manual will not
work here.

not sure. Can't you give the c-code you want to have a
binding to?

cheers
 Michael


Archives up to November 11, 2006 are also downloadable at http://www.connettivo.net/cntprojects/ocaml_beginners/

The archives of the very official ocaml list (the seniors'
one) can be found at http://caml.inria.fr
Attachments are banned and you're asked to be polite, avoid
flames etc. 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http:/
/groups.yahoo.com/group/ocaml_beginners/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    ht
tp://groups.yahoo.com/group/ocaml_beginners/join
    (Yahoo! ID required)

<*> To change settings via email:
    mailto:ocaml_beginners-digest@yahoogroups.com 
    mailto:ocaml_beginners-fullfeatured@yahoogroups.com

<*> To unsubscribe from this group, send an email to:
    ocaml_beginners-unsubscribe@yahoogroups.com

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.c
om/info/terms/
 

Re: "ocaml_beginners"::[] Re: multiple callbacks
country flaguser name
France
2007-09-21 15:25:00
> >   register_sample_file_type("mp3",
load_mp3, NULL);
> >   register_sample_file_type("ogg",
load_ogg, NULL);
> >
> > So as you can see here, the function
register_sample_file_type() can be
> > called with *several* different callbacks, in this
example the correct
> > callback will be called according to the file type
when the user calls
> >   load_sample(filename);
>
> yes, it looks like storing the function pointer in a
map with the filetype
> as key.
>
> But what is the difference to "Callback.register
name fun" ?
> Callback.register can be called with *several*
different callbacks too.

Ok, but if I'm here, it's because I don't see how to do, so
could you give a ml/C code solution to show how you would
bind
for example this funciton register_sample_file_type() given
in example?

> > As said previously a hack have to be found to bind
this kind of
> > functions, since the method given in the ocaml
manual will not work here.
>
> not sure.

Yes it's sure ! you have seen it in the .tar.gz I've made !

>           Can't you give the c-code you want to have a
binding to?

Yes, sure, here for exemple the function
register_sample_file_type :

  SAMPLE *load_mp3(const char *filename) {
       ...
  }
  SAMPLE *load_ogg(const char *filename) {
       ...
  }

  register_sample_file_type("mp3", load_mp3,
NULL);
  register_sample_file_type("ogg", load_ogg,
NULL);

-- 
Regards


Archives up to November 11, 2006 are also downloadable at http://www.connettivo.net/cntprojects/ocaml_beginners/

The archives of the very official ocaml list (the seniors'
one) can be found at http://caml.inria.fr
Attachments are banned and you're asked to be polite, avoid
flames etc. 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http:/
/groups.yahoo.com/group/ocaml_beginners/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    ht
tp://groups.yahoo.com/group/ocaml_beginners/join
    (Yahoo! ID required)

<*> To change settings via email:
    mailto:ocaml_beginners-digest@yahoogroups.com 
    mailto:ocaml_beginners-fullfeatured@yahoogroups.com

<*> To unsubscribe from this group, send an email to:
    ocaml_beginners-unsubscribe@yahoogroups.com

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.c
om/info/terms/
 

[1-2]

about | contact  Other archives ( Real Estate discussion Medical topics )