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

Add values to features to ribbit #74

Open
leo-ard opened this issue Oct 24, 2024 · 0 comments
Open

Add values to features to ribbit #74

leo-ard opened this issue Oct 24, 2024 · 0 comments

Comments

@leo-ard
Copy link
Collaborator

leo-ard commented Oct 24, 2024

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.

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

1 participant