The idea is to have a way to write syntax which is new for a given version of CFEngine, and still have that file parse correctly on older versions. Today's situation is that such syntax will cause a parse error on older versions and prevent execution.
The current proposal:
<pre>
bundle agent main
{
files:
"/tmp/file"
create => "true";
@if version_after(3.7)
awesome_new_promise_type:
"promiser"
attribute => "value";
@endif
}
</pre>
The only tweakable text in that example is "3.7", which can be any "x.x" number.
There are several reasons for using the "version_after" construct:
- Language syntax should always be backwards compatible, so there is never a need to specify "@version_before(3.7)@".
- It limits the syntax in scope, so that we don't run into problems where the future proof syntax itself is incompatible between versions.
- It allows a safe deprecation path in the future: If we decide that we want to deprecate and eventually remove this syntax it will be safe to do so after enough feature releases, because:
- If we stop providing versions after a certain point, say 3.10, then no policy will ever have a higher number than "@version_before(3.10)@". If they tried to, it would be a parse error (I assume that future proofing the syntax is accomplished by a different feature at this point, for example free form syntax).
- Removing such sections are guaranteed to be a no-op for all versions including and following 3.10, since the block was always active in those versions.
- If we remove the "if/endif" support in 3.13, we guarantee that all versions since 3.10 will work.
- The only work required for the customer is to actually remove the "if/endif" parts, but this will be easy because of point 1, and side effect free.
- is duplicated by
-
CFE-1591 Future-compatible syntax parsing
-
- Done
-