Closed andymcn closed 10 years ago
Conclusion of long discussion:
class Platform fun tag linux(): Bool => compiler_intrinsic
Currently defined functions are linux, windows, osx and debug.This is in the code generator now. It works with if expressions and anything the compiler can determine to be a constant expression, so you can combine Platform booleans with other booleans, and if that results in a branch that can never execute, that branch won't be generated.
This isn't implemented for while loops.
Andy, that leaves the "use lib" conditional guard implementation to you.
The "lib:" handler for use commands isn't in yet, but the conditional guards are.
I've actually made it so that all use commands can have a condition, including using packages. The condition is evaluated in the scope pass (ie where we already handled use commands). If the condition fails we pretend that use command doesn't exist.
This allows entire packages to be platform specific if you want to.
We need to allow conditional code, both platform / hardware specific and for debug vs release.
We could switch at the expression, method, type or file level. We need to provide system / build info (OS, CPU capabilities, debug / release). Should we also allow programmer configurable info? This could be to allow the aardvark build to be different to the wombat build. It could also be used to make complex decisions based on OS, CPU, etc jsut once, rather than in every file, function, etc.