Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose the pony version during compile time #104

Open
mfelsche opened this issue Oct 6, 2017 · 3 comments
Open

Expose the pony version during compile time #104

mfelsche opened this issue Oct 6, 2017 · 3 comments

Comments

@mfelsche
Copy link
Contributor

mfelsche commented Oct 6, 2017

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
Copy link
Contributor Author

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.

@SeanTAllen
Copy link
Member

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.

@ponylang-main ponylang-main added the discuss during sync Should be discussed during an upcoming sync label Feb 25, 2022
@SeanTAllen
Copy link
Member

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 SeanTAllen removed the discuss during sync Should be discussed during an upcoming sync label Mar 15, 2022
@ponylang-main ponylang-main added the discuss during sync Should be discussed during an upcoming sync label Mar 15, 2022
@SeanTAllen SeanTAllen removed the discuss during sync Should be discussed during an upcoming sync label Mar 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants