Subject: Re: foreign_library implementation question

From: Jan Wielemaker <[email-masked]>
Date: Thu, 3 Feb 2000 12:44:38 +0100

On Wed, 02 Feb 2000, Eelco J. Sommer wrote:
>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.

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.

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.

	Regards --- Jan