prolog_load_context(?Key, ?Value) -- can it hook into *every* read_term during compile

Hello,

If I want to introduce a conditional compile at the clause level, then I would need (simple) access to the compilers processing of read_term.

Is there is a hook defined to allow some processing immediately after read_term but before something is done with the read term – including the option to cause compiler processing to skip further processing of that term

Edit:

The plan would then be to check if the Value of a read term is in a list of items that should be expanded to true, and then cause it to happen.

Alternatively, to simply tell the compiler to skip that term – if that is possible.

Edit 2:

I guess, the next logical step would be to support aspectual modularization – it would enable conditional injecting of semantic test code – for example – in various places of the code base – before and after processing of goals.

thanks,

Dan

p.s. reminds me of point-cuts in aspectual programming – a before advise to read_term – to “decorate” or otherwise omit processing.

I think I found a way:

I still need to replicate term_expansion clauses across modules, but i can then wrap these into a conditional compilations – switching them and and off based on some asserted flag.

need to test if this will work – i.e. conditional compile occurs before term expansion in a module

Since those term expansions will likely not change much – its probably a good “compromise” to a more dynamic approach I suggested earlier.

Edit:

Yes, this works.

One small drawback – its not enough to change a flag to change the condition for conditional expansion – i need to restart / recompile all modules for it to work.

Dan