1. ifdef changes, 4.0 code may break.

I just committed (rev 1426) a change to the way ifdef statements are handled. They are greatly expanded but also contains a change that may break existing 4.0 code.

In euphoria, we use the not keyword, not ! to negate a statement. An example of the previous syntax:

ifdef !DOS32 then 
  -- do things that are for non-DOS platforms 
end ifdef 

This syntax has been changed to be more Euphorian.

ifdef not DOS32 then 
  -- do things that are for non-DOS platforms 
end ifdef 

Important: Current 4.0 still handles "!DOS32" syntax, however, this will be removed after the next alpha has been released. You must update your code to use the "not DOS32" syntax.

Now, we have got some further changes on the ifdef system with this commit as well. It now supports simple conjunctions:

  1. and
  2. or

Example:

ifdef DOS32 or WIN32 then 
  -- DOS or Windows code 
end ifdef 
 
ifdef DOS32 and not DEBUG then 
  -- non debug DOS code 
end ifdef 
 
ifdef DOS32 or WIN32 or LINUX then 
  -- DOS or Windows or Linux 
end ifdef 

The examples could go on. I committed a test case for many different combinations that you may wish to look at.

Jeremy

new topic     » topic index » view message » categorize

2. Re: ifdef changes, 4.0 code may break.

jeremy said...

Now, we have got some further changes on the ifdef system with this commit as well. It now supports simple conjunctions:

  1. and
  2. or

I wanted to mention (and I'll do this in the docs as well) that this is simple conjunctions. The ifdef system runs before the interpreter ever starts executing on the code, thus, we do not have at our disposal the entire expression system. The biggest limitation is no logical grouping. For instance, the following will NOT work:

ifdef (WIN32 or DOS32) and DEBUG then 
    -- debug code Windows or DOS 
end ifdef 

You can, however, nest ifdef's to achieve the same type of functionality, but not as eloquent.

ifdef WIN32 or DOS32 then 
    ifdef DEBUG then 
        -- debug code for Windows or DOS 
    end ifdef 
end ifdef 

We have all the syntax changes done necessary to support the ifdef system. I expect that in post 4.0, the ifdef system will see further enhancements such as logical grouping and comparison operators.

Jeremy

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu