Question about calling rules from within a generator

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Question about calling rules from within a generator

Boost - Build mailing list
I was trying to use the assert module to check various assumptions
within my custom generator class when I found it is not possible to
call those rules.  This is also true of other user-defined rules
within the same file as the generator.  Is this expected?

See the attached file for a minimal example that shows the issue.  The
project will run correctly after commenting out the call to
`assert.true` in `g.jam`.

Best,
Tom

_______________________________________________
Unsubscribe & other changes: https://lists.boost.org/mailman/listinfo.cgi/boost-build

tmp.fff (12 bytes) Download Attachment
Jamroot (40 bytes) Download Attachment
g.jam (1K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Question about calling rules from within a generator

Boost - Build mailing list
AMDG

On 4/1/19 2:31 PM, Thomas Brown via Boost-build wrote:
> I was trying to use the assert module to check various assumptions
> within my custom generator class when I found it is not possible to
> call those rules.  This is also true of other user-defined rules
> within the same file as the generator.  Is this expected?
>

  You need to import them inside the class.
Rules from the outer module are not automatically
visible within the class.  A class is an independent
module that has no semantic relationship to the
context in which it is defined.

> See the attached file for a minimal example that shows the issue.  The
> project will run correctly after commenting out the call to
> `assert.true` in `g.jam`.
>

In Christ,
Steven Watanabe
_______________________________________________
Unsubscribe & other changes: https://lists.boost.org/mailman/listinfo.cgi/boost-build
Reply | Threaded
Open this post in threaded view
|

Re: Question about calling rules from within a generator

Boost - Build mailing list
On 4/1/19 4:44 PM, Steven Watanabe via Boost-build wrote:

> AMDG
>
> On 4/1/19 2:31 PM, Thomas Brown via Boost-build wrote:
>> I was trying to use the assert module to check various assumptions
>> within my custom generator class when I found it is not possible to
>> call those rules.  This is also true of other user-defined rules
>> within the same file as the generator.  Is this expected?
>>
>
>    You need to import them inside the class.
> Rules from the outer module are not automatically
> visible within the class.  A class is an independent
> module that has no semantic relationship to the
> context in which it is defined.

Thanks for your help!  This worked for `errors` in my example, but not
for `assert`.  It looks like `errors` only imports `sequence` within a
single rule, while `assert` actually imports `errors` and does a lot of
funky-looking stuff.  Might `assert` actually not work in this case?

Thanks,
Tom


_______________________________________________
Unsubscribe & other changes: https://lists.boost.org/mailman/listinfo.cgi/boost-build
Reply | Threaded
Open this post in threaded view
|

Re: Question about calling rules from within a generator

Boost - Build mailing list
AMDG

On 4/1/19 3:11 PM, Tom Brown via Boost-build wrote:

> On 4/1/19 4:44 PM, Steven Watanabe via Boost-build wrote:
>>
>> On 4/1/19 2:31 PM, Thomas Brown via Boost-build wrote:
>>> I was trying to use the assert module to check various assumptions
>>> within my custom generator class when I found it is not possible to
>>> call those rules.  This is also true of other user-defined rules
>>> within the same file as the generator.  Is this expected?
>>>
>>
>>    You need to import them inside the class.
>> Rules from the outer module are not automatically
>> visible within the class.  A class is an independent
>> module that has no semantic relationship to the
>> context in which it is defined.
>
> Thanks for your help!  This worked for `errors` in my example, but not
> for `assert`.

I don't see `errors` anywhere in the code you posted?

>  It looks like `errors` only imports `sequence` within a
> single rule,

How is that relevant?

> while `assert` actually imports `errors` and does a lot of
> funky-looking stuff.  Might `assert` actually not work in this case?
>

You're not using assert correctly in g.jam.
It takes a rule to call, not just a list.

In Christ,
Steven Watanabe
_______________________________________________
Unsubscribe & other changes: https://lists.boost.org/mailman/listinfo.cgi/boost-build
Reply | Threaded
Open this post in threaded view
|

Re: Question about calling rules from within a generator

Boost - Build mailing list
On 4/1/19 5:39 PM, Steven Watanabe via Boost-build wrote:

> AMDG
>
> On 4/1/19 3:11 PM, Tom Brown via Boost-build wrote:
>> On 4/1/19 4:44 PM, Steven Watanabe via Boost-build wrote:
>>>
>>> On 4/1/19 2:31 PM, Thomas Brown via Boost-build wrote:
>>>> I was trying to use the assert module to check various assumptions
>>>> within my custom generator class when I found it is not possible to
>>>> call those rules.  This is also true of other user-defined rules
>>>> within the same file as the generator.  Is this expected?
>>>>
>>>
>>>     You need to import them inside the class.
>>> Rules from the outer module are not automatically
>>> visible within the class.  A class is an independent
>>> module that has no semantic relationship to the
>>> context in which it is defined.

I now understand what you meant by this.  The import has to happen
within the class, not within the rule within the class.  That was my
error.

>> Thanks for your help!  This worked for `errors` in my example, but not
>> for `assert`.
>
> I don't see `errors` anywhere in the code you posted?

I tried that after your first reply (incorrectly, it happens).

>>    It looks like `errors` only imports `sequence` within a
>> single rule,
>
> How is that relevant?

It's not, I was trying to understand why assert and error might work
differently when imported (but they don't work differently, they work
exactly the same).

> You're not using assert correctly in g.jam.
> It takes a rule to call, not just a list.

This is true, but the real mistake I made was that I was importing
assert either at the beginning of the file or within a rule within a
class, not within the class.

You've helped me understand better what's going on.  I'm still not very
sure where an import can be done and what its scope is, but I can at
least continue what I was trying to.

Thanks,
Tom

_______________________________________________
Unsubscribe & other changes: https://lists.boost.org/mailman/listinfo.cgi/boost-build