Skip to content

Add values to features to ribbit #74

Description

@leo-ard

Rationale

Ribbit's feature system is currently binary. Features can either be activated (#t) or disactivated (#f). The liveness analysis activates or deactivates them in order to only include what is needed in the final executable.

However, in some cases, we would want features to have other values than #t or #f. This is useful in multiple cases :

  • For the @@(replace ...)@@ annotation that can insert compile-time known values in the host RVM. This is useful for the specialized encoding, where the compiler has some information about shared encoding parameters that need to be inserted in the host
  • In the case of bignums, we want the hosts to be able to specify what is the maximum size for an "integer" that lives inside a rib. The library can then adapt to create bignums after this maximum value is reached.

Syntax

The only construct that need modification is the use construct. We can now specify values as s-exps pairs. Here are a few examples :

example 1 : (define-primitive (square x) (use (foobar 42)))
Here, if the primitive "square" is used, the foobar feature will have the value of 42

example 2 : (define-feature hey (use (baz 42)) ((decl "console.log('hey');")))
Here, if the hey feature is used, the baz feature will have the value 42

example 3 : (use-feature my-true-feature (my-other-value-feature 42))
Here, the feature my-true-feature will have a value of #t and my-other-value-feature will have a value of 42.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions