|
Boost : |
From: Joel de Guzman (djowel_at_[hidden])
Date: 2003-04-12 20:13:27
Paul Mensonides wrote:
> Joel de Guzman wrote:
>
>> Hmmm.... how about namespaces (or modules) ? :o)...
>>
>> #< BOOST_PP // boost PP namespace
>> // blah blah blah....
>> #>
>>
>> #< MY_MODULE // my module namespace
>> #using BOOST_PP // using boost PP namespace
>> // blah blah blah....
>> #>
>
> Hi Joel, I'm already in the process of writing a paper with an
> alternative version of the above. Problem #1: the operator
> directives are evil. They are not visible, and with serve to make
> code that includes them hard to read. We need a named alternative at
> least. Problem #2: No true scoping is achieved:
>
> #<
> #define DETAIL 123
> #define INTERFACE DETAIL
> #export INTERFACE
> #>
>
> INTERFACE // ?
Well, I can't speak for the evolution group of WG21 & J16 so you should
probably ask them.
> This is what I'm going to propose:
>
> # region // unnamed
> # import ABC
> # define XYZ
> # define INTERFACE 123
> # export INTERFACE
> # endreg
>
> XYZ // XYZ
> INTERFACE // 123
>
> # region BOOST
> # region DETAIL
> # define ABC 123
> # endreg
> # define INTERFACE BOOST::DETAIL::ABC
> # define OTHER 123
> # export OTHER
> # region A
> # define MACRO 123
> # endref
> # region B
> # define MACRO 123
> # endif
> # export A
> # endreg
>
> ABC // ABC
> DETAIL::ABC // DETAIL::ABC
> BOOST::INTERFACE // 123
> OTHER // 123
>
> A::MACRO // 123
> B::MACRO // B::MACRO
>
> What do you think?
Looks good. But why not overload the name "namespace" in as much
as the CPP overloads #if #else ? I think the syntax should give a nice
feeling since it is already looks like something C++ programmers are
already accustomed to:
# namespace // unnamed
// blah blah blah....
# endnamespace
# namespace BOOST
// blah blah blah....
# endnamespace
Either way, any syntax will do as long as it works :) If you really want to go
the import/export route, consider a modula-2-ish syntax:
# module BOOST
# import ABC
# define INTERFACE 123
# export INTERFACE
# endmodule
-- Joel de Guzman joel at boost-consulting.com http://www.boost-consulting.com http://spirit.sf.net
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk