Comments (3)
Conclusion of long discussion:
- In builtin we define functions of the form:
class Platform fun tag linux(): Bool => compiler_intrinsic
Currently defined functions are linux, windows, osx and debug. - We add a condition clause to "use" commands, which is currently only legal for the lib: scheme. This allows the use of the Platform functions to specify whether to the use command should be included in each build.
- The code generator / llvm branch optimisor completely removes any branches in the code whose condition only depends on the Platform functions. Note that we still fully type check all code paths.
- We explicitly do not provide any mechanism for conditional code based on CPU capabilities (eg SSE), endianness or other factor that can only be determined at runtime. Standard if expressions can of course be used, with the associated overhead.
from ponyc.
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.
from ponyc.
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.
from ponyc.
Related Issues (20)
- Possible infinite loop in ponyint_formattime
- dtrace support is missing from the Makefile HOT 3
- Trait default method segfault HOT 4
- Dependent default types HOT 4
- x86 Mac OS Sonoma Compile Error with XCode 15 and HOT 21
- Backend null in epoll during CI run HOT 3
- Non-sendable data seen as sendable
- Release 0.57.1 HOT 2
- Generic parameter when copying a trait method into an object that has a generic parameter of the same name HOT 2
- return usage in disposing block's is flawed and we need to revist. HOT 5
- Slow compare to elixir in `ring benchmark` HOT 2
- Clean up MacOS platform version setting HOT 1
- Release 0.58.0 HOT 1
- Release 0.58.1
- Invalid LLVM generated HOT 1
- Segmentation fault when ponyc compiles this code HOT 2
- Compile fails verification "GEP base pointer is not a vector or a vector of pointers" HOT 13
- LLVM mangling error with `powi` HOT 4
- Release 0.58.2
- Constrained Types RFC
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ponyc.