rfcs icon indicating copy to clipboard operation
rfcs copied to clipboard

Expose the pony version during compile time

Open mfelsche opened this issue 6 years ago • 3 comments

This would make conditional compilation possible as we currently have for the platform (windows, darwin, linux, ...) but for different pony versions for which there might exist breaking changes in the stdlib or the comper itself.

This would make it possible to maintain compatibility between different pony versions within one codebase.

mfelsche avatar Oct 06 '17 20:10 mfelsche

There are at least two ways how to approach this problem:

Custom Defines

The first way would be using custom defined with the ponyc flag --define. Those defines don't have any value and we'd need a define for each ponyc version around. something like:

  • --define=pony_version_1
  • --define=pony_version_1.0
  • --define=pony_version_1.0.5

one for each level of the version number. Those defines need to be set by the build system, a Makefile e.g. The downside of this approach is that when using some pony code as a package the same defines need to be added again.

Defines with Values

The external defines would not needed to be added over and over again if ponyc would set those defines on its own. It would be even better if those defines had a value that could be used in some more involved statement for conditional compilation:

ifcond pony_version_major >= 4 and pony_version_minor >= 1
  // awesome new feature since pony 4.2.0
else
  // old boring stuff
end

Then those conditional statements could be used to maintain one codebase for multiple pony versions and make it easy to use it as a package.

mfelsche avatar Oct 18 '17 20:10 mfelsche

I'm wondering. @jemc @mfelsche, is there a reason that if we added compile time expressions that this wouldn't be possible? Something like if constexpr from C++.

I have worries about this as a general feature, but I am interested if compile time expressions could make this possible if we exposed the version values.

SeanTAllen avatar Feb 25 '22 01:02 SeanTAllen

During sync, I mentioned concerns about how we would support from a "typecheck everything". Do I need multiple ponyc compilation environments?

Joe mentioned "how do we support if there's a syntax change in the compiler".

I think the easiest thing would be a c preprocessor type functionality but that is a mess unto itself.

SeanTAllen avatar Mar 15 '22 18:03 SeanTAllen