Boost logo

Boost-Build :

From: Vladimir Prus (ghost_at_[hidden])
Date: 2007-10-17 03:14:33


On Wednesday 17 October 2007 05:01:53 김영현 wrote:
> Hello.
>
> Please, look at that code below.
>
> # Jamroot
>
> import xxx ;
>
> # in xxx.jam file
>
> SOME_DIR_PATH1 = /home/user/test ;
>
> rule path-constants ( name )
> {
> SOME_DIR_PATH2 = /home/user/test ;
>
> return $($(name)) ;
> }
>
> class Test
> {

You need

        import xxx ;

here.

> rule __init__ ( )
> {
> echo "[" $(SOME_DIR_PATH1) "]" ;

I don't think you can get at variable line this. [ modules.peek xxx : SOME_DIR_PATH1 ]
might work.

> echo "[" [ path-constants SOME_DIR_PATH2 ] "]" ;

and here, with import in place, xxx.path-constants should work.

> import "class" : new ;
>
> t = [ new Test ] ;
>
>
> # outputs
> $> bjam
> [ ] *"echo $(SOME_DIR_PATH1) - value is empty"
> */home/user/test/test.jam:16: in object(Test)@15.__init__
> rule *path-constants unknown* in module object(Test)@15.
> ...
> ...
>
>
> I can't access variables and rules that are in different scope, I mean not
> in class scope. why?

Because there's no scoping in jam. There are modules, and each module has
its own namespace. class, actually, is a module in disguise. Inside
module, you can access variables of that module, only. The fact that
class is defined inside some other module does not help.

- Volodya


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