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

Leo ard/features with values #66

Open
wants to merge 20 commits into
base: main
Choose a base branch
from
Open

Conversation

leo-ard
Copy link
Collaborator

@leo-ard leo-ard commented Jun 21, 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.

@leo-ard leo-ard force-pushed the leo-ard/features-with-values branch 4 times, most recently from fc6f9bb to adbe458 Compare June 27, 2024 17:06
Base automatically changed from dev to main September 10, 2024 20:46
@leo-ard leo-ard force-pushed the leo-ard/features-with-values branch 2 times, most recently from 08bf3e1 to 9ef7c88 Compare September 10, 2024 21:43
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

Successfully merging this pull request may close these issues.

1 participant