[mercury-users] Simulating passed data with Mercury/C#

Jonathan Morgan jonmmorgan at gmail.com
Sat Mar 18 13:32:09 AEDT 2006


I have been looking at graphical bindings for Mercury/IL, and the
bindings from C to C# do not appear to support passing data to
callbacks very well.

The first binding I looked at was Ticklesharp, as it would seem fairly
simple to add IL support to mtcltk.  However, this relies on passing
the Mercury closure to call as data to Tcl_CreateCommand.  There is no
data passed by TickleSharp, so my "generic" handler  would need to
know both the name of the command that had been invoked and the
Mercury closure to call.

Next I looked at Gtk#.  It too does not take user data that is then
passed to the callback that has been registered.  The response I got
was that "The Gtk# paradigm for the user_data parameter is to create
your delegate from an instance method on a class and hold the data
member in an instance field."  I don't believe that Mercury can do
that, as Mercury foreign procedures in C# are all in static functions,
that cannot access instance variables.

So the question is, is there any way that we can simulate this user
data so that we can register the same callback with different pieces
of data associated, and then use that data?  Is it possible to create
our own class with the call-back method and instance variables, and
then register the callback from that class, but still call the static
Mercury-exported functions?

Jon

--------------------------------------------------------------------------
mercury-users mailing list
post:  mercury-users at cs.mu.oz.au
administrative address: owner-mercury-users at cs.mu.oz.au
unsubscribe: Address: mercury-users-request at cs.mu.oz.au Message: unsubscribe
subscribe:   Address: mercury-users-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------



More information about the users mailing list