DSEL syntax, or opening the can of worms.
Rene Rivera <[email protected]>
| Newsgroups | gmane.comp.lib.boost.langbinding |
|---|---|
| Organization | Redshift Software, Inc. |
| Message-ID | <[email protected]> |
First I think we all agree that the Luabind DSEL syntax is "nicer" than
the BPL syntax. Last night, something kept bothering me. The syntax
dealing with namespaces/modules vs. the syntax for dealing with classes
and inner classes are inconsistent with each other. Yet to me both deal
with defining scopes, and members within those scopes. To take a simple
example:
namespace a
{
int f();
struct A
{
void do();
struct B
{
void again();
};
};
}
In Luabind the binding declaration would look like:
module(L)
[
namespace_(L,"a")
[
def("f",&a::f),
class<a::A>("A")
.def("do",&a::A::do)
.scope
[
class_<a::A::B>("B")
.def("again",&a::A::B::again)
]
]
]
That shows that 'module' and 'namespace_' use [] to bound the scope they
define. But 'class' uses ".method" to chain the scope out as needed. And
introduces the rather unintuitive, IMO, '.scope' to allow one "access"
to the class scope. So I though, why not be consistent and use [] to
define all scopes. Which leads to (removing the module/namespace
destinction):
namespace_(L,"a")
[
def("f",&a::f),
class_<a::A>("A")
[
def("do",&a::A::do),
class_<a::A::B>("B")
[
def("again",&a::A::B::again)
]
]
]
Which has a one-to-one correspondence with the C++ code. So... Was this
ever considered? If it was, why was it not used? Is there a discussion
in the list I haven't read about this?
--
-- Grafik - Don't Assume Anything
-- Redshift Software, Inc. - http://redshift-software.com
-- rrivera/acm.org - grafik/redshift-software.com
-- 102708583/icq - grafikrobot/aim - grafikrobot/yahoo
-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems? Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/