Re: Re: syntax suggestion

Daniel Wallin <[email protected]>
Newsgroups gmane.comp.lib.boost.langbinding
Message-ID <[email protected]>
David Abrahams wrote:

> Alexander Nasonov <[email protected]> writes:
> 
> 
>>Daniel Wallin wrote:
>>>When in doubt I tend to go for the less verbose and less complicated
>>>alternative, so I guess I like the original version is better:
>>>
>>>     class_<C, bases<A, B> >("C")
>>>       .def(..)
>>>       .def(..)
>>>       ;
>>>
>>>Here are some other possibilities:
>>>
>>>     // Cool, but not very portable
>>>     class_<C(A, B)>("C")
> 
> 
> I like the syntax; I guess we need to decide whether we care about
> older compilers or not.

Yeah, it mirrors both the python and luabind syntax. But I really
dislike dropping older compilers. Maybe supporting both ala
Boost.Function?

>>>       .def(..)
>>>       .def(..)
>>>       ;
>>>
>>>     // Just add more parameters to class_<>, complicates
>>>     // the metaprogramming
> 
> 
> Definitely problematic, especially if you want to be able to pass
> other parameters.

Why? It's not like it's hard to discriminate the params. We do that in
both luabind and BPL already.

    template<class T> void add_base(type<T>, mpl::false_) {}
    template<class T> void add_base(type<T>, mpl::true_)
    {
       ...
    }

    template<class T, class A0, ..., class AN>
    struct class_
    {
        class_(char const*)
        {
            add_base(
                type<A0>(), typename is_base_and_derived<A0, T>::type());
            add_base(
                type<A0>(), typename is_base_and_derived<A1, T>::type());
            ...
            add_base(
                type<AN>(), typename is_base_and_derived<AN, T>::type());
        }
    };

> 
> 
>>>     class_<C, A, B)>("C")
>>>       .def(..)
>>>       .def(..)
>>>       ;
>>>
>>>I'm not sure if either one has any significant benefits from the
>>>original though.
>>>
>>>I think we need more opinions, anyone?
> 
> 
> The only advantage I can see to using the []s is that it becomes a
> bit cleaner to define nested classes.

FWIW, this is what it this currently looks like in luabind:

    module(L)
    [
        class_<X>("X")
            .static_
            [
                class_<Y>("Y")
                   ...
            ]
    ];

-- 
Daniel Wallin


-------------------------------------------------------
This SF.Net email is sponsored by: IBM Linux Tutorials
Free Linux tutorial presented by Daniel Robbins, President and CEO of
GenToo technologies. Learn everything from fundamentals to system
administration.http://ads.osdn.com/?ad_id=1470&alloc_id=3638&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.