On 08/09/2008, at 11:42 PM, Jacques Carette wrote:

> Neat.
>
> The one obvious question is: how many of those 'Py' are actually  
> needed, and how many are your choice of naming?  In other words,  
> could you rewrite that piece of Felix code for us, keeping the  
> occurrences of 'py' [in any casing, appearing anywhere in the  
> program] to an absolute minimum?

My convention wrapping foreign libraries at the low level is to  
duplicate the interfaces
rather faithfully, so functions and types named Py_INCREF and PyObject  
etc retain their
original names to help remind the user that they're low level wrappers  
and behave
the same as documented in the foreign library docs. The one sop to  
faithfulness here
is that Felix PyObject actually represents a PyObject*.

Don't forget, Python isn't the only foreign library one might wrap..  
if we wrapped
Lua and Ruby as well, we might have rather an overload of "Object"  
types, for
example.

Having said that .. of course one can use modules/namespaces:

module Py {
   type Object = "PyObject*";
}

and now instead of

   val x : Py::Object = ...

one could write

   open Py;
   val x: Object = ...

The demo code is just that: a first demo that the whole thing works.

Python has a suite of functions to wrap, a model for making new types,
a reference-count/garbage collection system. Also, some attempt
at automatic wrapping is possible.

One downside: Python under Unix is typically built *incorrectly*: it  
expects
users to bind symbols against the executable, which is always bad  
practice
(Unix should never have supported this). Also, typically Python  
mainline is C,
whereas we really need C++.  I hope unix users won't have to build  
Python from
scratch to fix this (new Python build technology probably has a config  
option
to build the mainline as C++, however getting rid of the code in the  
executable
is another story).


--
john skaller
[EMAIL PROTECTED]





-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Felix-language mailing list
Felix-language@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/felix-language

Reply via email to