Boost logo

Boost-Build :

From: David Abrahams (gclbb-jamboost_at_[hidden])
Date: 2003-05-10 17:32:12


Rene Rivera <grafik666_at_[hidden]> writes:

> [2003-05-10] David Abrahams wrote:
>
>>Ali Azarbayejani <ali_at_[hidden]> writes:
>>
>>> Each class declaration requires a "rule" declaration followed by a
>>> "class" declaration, making it difficult to see at a glance whether
>>> a rule is a regular rule or a class definition. Short of a core jam
>>> modification to allow a more obvious declaration, it may be possible
>>> to reduce confusion by allowing the placing of the "class"
>>> declaration just before the "rule" declaration. David plans to
>>> explore this possibility. We're not sure there is an easy solution.
>>
>>An even easier solution:
>>
>> rule foo.__init__ ( args * )
>> {
>> base.__init__ ( ... ) ;
>> rule method ( arg ) { }
>> }
>> class foo : base1 base2 ;
>>
>>We can see that foo is a class by convention: its __init__ function
>>is declared.
>>
>>Requires no core changes at all and just a minor tweak to class.jam.
>
> I like it. It's simple, to understand, and to modify existing code.

I still don't like the fact that bases follow, but the __init__
function has to __init__ all of the bases anyway so maybe it's not so
bad.

> Question... Is there anything preventing declaring class method rules
> outside of the __init__ class rule? As such...
>
> rule foo.__init__ ( args * )
> {
> base.__init ( ... ) ;
> }
> class foo : base 1 base 2;
>
> rule foo.method ( arg ) { }
>
> I think that would make it easier to humanly parse the classes.

Sorry, it won't work. Part of the trick to classes is that calling
the __init__ function actually defines all of the class' methods
inside the instance.

-- 
Dave Abrahams
Boost Consulting
www.boost-consulting.com
 

Boost-Build list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk