In C, which is something all developers are familiar with. The preprocessor has a very distinct syntax. It has a distinct symbol table. It doesn't enforce declarations before use. In EUPHORIA the preprocessor ought to use the same syntax and use the same symbol table.

Although ifdef is very useful it lacks some properties that we have come to expect from modern languages:

  • declare before use
  • values which are more than existential
  • operators < >.

In EUPHORIA without ifdefs we must declare everything before use. With ifdef, we have don't bother declaring at all. Whereas in regular EUPHORIA code, you are still protected from spelling errors. ifdef doesn't help you. Now, we are progressing from EU4_0 to EU4_1, we are quite comfortable deciding whether 4.0 or 4.1.

ifdef EU4_0 then 
end ifdef 

What happens in say 4.4?

ifdef EU4_0 or EU4_1 or EU4_2 then 
   -- use code that doesn't use lambda functions 
elsedef then 
end ifdef 

We can see this symbol exist without a value is limited here.

Suppose we allow constants, and a select set of functions to be evaluated by a preprocessor in if statements: platform(), version(), version_major() and friends and some constants we add for convenience. If in any if-block there are top level statements, we constant fold the expressions into booleans. If we cannot we return an error. If we can, we give the original parser the block it should see.

So, now we have things like

if version < EU4_3 then 
    -- no lambda functions here. 
end if 


Quick Links

User menu

Not signed in.

Misc Menu