Giter Club home page Giter Club logo

Comments (3)

andymcn avatar andymcn commented on May 14, 2024

Conclusion of long discussion:

  1. 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.
  2. 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.
  3. 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.
  4. 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.

sylvanc avatar sylvanc commented on May 14, 2024

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.

andymcn avatar andymcn commented on May 14, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.