new round

Alexander Nasonov <[email protected]>
Newsgroups gmane.comp.lib.boost.langbinding
Message-ID <[email protected]>
On Thursday 26 February 2004 13:29, David Abrahams wrote:
> Alexander Nasonov writes:
> > Hi Dave,
> > If you saw my recent post on boost.langbinding you may know about my
> > interest in the library.
>
> Yes.
> > [skiped]
> > I already have some code. Currently, binding starts from *module* (I'll
> > implement a collection of modules later):
> >
> > module x_module("x"); // analog of namespace x
> >
> > The x_module object is a root of information about entities defined
> > there. They can be introduced like this:
> >
> > x_module
> > [
> >     def("free_function", free_function),
> >     class_<X>("X")
> >     [
> >         def("member_function", &X::member_function)
> >     ],
> > ];
>
> Sure!

I decided to minimize compile-time checks to reduce compilation time. For
example, there is no compile-time check for member_function to belong to X.
I'll implement it as a runtime function later.

>
> > Retrieving a definition from x_module is simple:
> >
> > definition free_function_def =
x_module.find_definition("free_function");
>
> OK...
>
> > Although I implemented only class 'definition' I'm going to add
> > function_def, class_def and so on.
>
> You lost me.

Well, generic 'definition' can call overloaded function properly or it can
be used to retrieve nested definitions. This comes at runtime cost, though.
Other possibility might be to find a best function at startup and then call
the function quickly. To archieve this, specialized classes are required.

>
> > Generic definition can be narrowed to more specialized case. This
> > can be useful to improve performance of repetitive calls, for
> > example.  A way how arguments are passed to a callable entity is an
> > array of raw pointers to full objects and an array of their type
> > information.
> >
> > int free_function(char);
> > // ...
> > int result;
> > char arg;
> > void* args[2] = { &result, &arg };
> > type_info* types[2] = { &typeid(int), &typeid(char) };
> > free_function_def(args, types, 2); // raw call
>
> Lovely!  But why does free_function_def require the list of typeids?...
Actually, this code currently doesn't work. This one works:
free_function_def(args);

> > This code works fine in my test version if free_function is not
> > overloaded.
>
> ...for overloading?
C++ rules are complicated and I don't want to start implementation until
concepts are clarified. Only simple skeleton at the beginnning.

> > To resolve ambiguity between free function calls and member function
> > calls I suggest adding scope to the raw call. Something like
inside_class
> > and outside_class might be useful (there are also qualified calls and
> > unqualified calls  but they are currently out of my consideration):
> >
> > definition member_function_def =
> >         x_module.find_definition("X::member_function");
>
> Not sure if that's the best approach.
Your idea?

> > // prepare arguments as in code above
> >
> > // Make member_function call if it were from inside derived
> > // class (useful to derive from C++ class in other language):
> > member_function_def(inside_class, args, types, 2);
> >
> > We can move technical discussion to boost.langbinding forum.
>
> Please do!  Daniel has more time than I do right now for langbinding.
>

Where should I put the code? I have cpp-experiment.sourceforge.net. Is it
fine?

-- 
Alexander Nasonov
Independent Developer and Consultant




-------------------------------------------------------
SF.Net is sponsored by: Speed Start Your Linux Apps Now.
Build and deploy apps & Web services for Linux with
a free DVD software kit from IBM. Click Now!
http://ads.osdn.com/?ad_id=1356&alloc_id=3438&op=click
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.