ENOSIG Discussie (threads)
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: LDAP in OCaml
On Sun, May 04, 2003 at 10:49:48PM +0200, Lionel Elie Mamane wrote:
> On Sun, May 04, 2003 at 05:41:06PM +0200, Jama Poulsen wrote:
> > On Sun, May 04, 2003 at 09:59:45AM +0200, Lionel Elie Mamane wrote:
> What do you mean by "callback"?
This is a general programming concept where an API function accepts a
reference to a funtion which the coder has supplied.
> Is this some LDAP thing that happens
> to have a name collision with what C libraries call "callback"? Please
> provide example code (in a human-readable pseudo-language) using
> callbacks. I have the hunch that the library doesn't need to do
> anything special, the language gives it to you.
No, this is an API issue, you only need function reference support
in the language. If a can't pass a callback reference in the OCaml
module then it won't ever end up in the OpenLDAP function.
Doing 'man 3 ldap_search' reveals that the openldap client API
itself does not support callbacks, so the OCaml module can't either.
Perl-ldap, as another native LDAP client implementation does support
callbacks.
Callback snippet from perldoc Net::LDAP
Most of the above commands accept a callback option.
This option should be a reference to a subroutine.
This subroutine will be called for each packet
received from the server as a response to the request sent.
When the subroutine is called the first argument will be the
Net::LDAP::Message object which was returned from the method.
If the request is a search then multiple packets can be received
from the server. Each entry is received as a separate packet.
For each of these the subroutine will be called with a
Net::LDAP::Entry object as the second argument.
During a search the server may also send a list of references.
When such a list is received then the subroutine will be called
with a Net::LDAP::Reference object as the second argument.
GUI toolkits often use callback registers which allow the coder
to request a procedure after to 'event' has happened, e.g. a mouse
click.
> > Did you have a look at http://pleac.sourceforge.net?
>
> Not yet. 5 minutes later: Ugh. To contribute, I have to read and
> understand the Perl code first, thus teach myself Perl? Ugh. Big entry
> barrier. Would you be willing to translate from Perl to English for
> me?
You should ask this on the Pleac mailinglist, indeed a programming
language neutral 'specification' of the cookbook would be a nice
thing. However, the Pleac headers above each section are quite
clear on what the problem domain is, IMO.
Hmm, I just saw this last line in the 'file access' section:
END { &genocide }
Appropriate function names should probably also be included in the
cookbook.
> Just glancing quickly at the headings: The Perl heritage shows a lot:
> E.g. the whole "Subroutines" section would look stupid in
> OCaml. It is a functional language, potsverdomme. You don't want to
> use subroutines.
Then just skip that or show why you don't have/need these programming
concepts.
> "Creating Persistent Private Variables" maybe would be a valid
> trick. But the title should be "if you iterative programmer want to do
> a persistent private variable, then the effect you want can be
> achieved by ... in OCaml". It isn't a persistent private variable
> (because there are no variables), but it achieves the effect you
> want.
Serialization/de-serialization is also needed for more complex data
structures. The perl stuff shows this for hash structures, but the
storable module can do this for many kinds of other structures.
"The Storable package brings persistency to your perl data structures
containing SCALAR, ARRAY, HASH or REF objects, i.e. anything that can be
convenientely stored to disk and retrieved at a later time."
The OCaml assignment :) would then be "How to store my complex data
structures to disk and retrieve them at a later time".
I use this storable stuff for my web cookie session management.
> > PS: No need to CC me, I'm subscribed to this list.
>
> What about setting a Mail-Followup-To, then? Oh, and the first msg
> wasn't to the list CC to you, it was to YOU, CC the list. Difference.
I know, this was advise to anybody replying to my message not to CC me.
Jama Poulsen
http://debianlinux.net
http://vemail.org
Follow-ups:
Gerelateerd:
[
Date Index]
[
Thread Index]