Subject: Re: foreign_library implementation question

From: "Sommer, EJ (ICT)" <[email-masked]>
Date: Fri, 4 Feb 2000 14:56:01 +0100

Jan, 
thanks for your direct response,

>>A burning question:
>>
>>From my foreign_library C file, I want to register/map several prolog
>>predicates to the same C function. Within this C function I want to
>>determine the (name of the) actual calling predicate. Can this be done?
>>
>>Background: I want to be able to generate predicates dynamically, and
handle
>>them using a generic handler.
>
>Odd plan :-)  Basically you can do it using a call-back to Prolog, get
>a reference to the current stack and walk up until you find the
>call-back.  The predicates are prolog_frame_attribute/3 and friends.
>
>This however is not really what you want, I guess.

Stack walking is most certainly not the thing I want to do (right now).

>An alternative is to generate your calls with an additional argument
>telling what you want the foreign function to do.  This seems the
>most portable and logical solution to me.

I like this one. I thought of this before, but didn't want to bother
the caller with an extra parameter. But as I come to think of it, this can 
probably be obscured by having an extra "wrapper" predicate. 

>Alternative, the foreign interface has to be augmented.  This very
>easy, but in principle their might be a day where optimisation makes
>it hard to extract this information.
>Of course you can do yourself whatever you like with the source, but
>I will only add it to the interface if you can explain why passing
>an extra argument doesn't solve your problem.

No, please! Do not alter the foreign interface code. It works OK, and I
have to play a little with all the options first. Currently I am working on
an alternative ODBC-interface, which allows for several open connections at
a time. Besides this, it should allow a user to query a database table 
exactly the same way as he/she would query a normal predicate. Thus, queries
like: customer(1000,Name,_,_) on an existing database should be possible. 
Currently, the ODBC-interface by Stefano De Giorgi doesn't allow this 
currently (as far as I can see).

Thanks,
Eelco.