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

Support for closures #202

Merged
merged 23 commits into from
Jun 8, 2024
Merged

Support for closures #202

merged 23 commits into from
Jun 8, 2024

Conversation

divarvel
Copy link
Collaborator

@divarvel divarvel commented Dec 29, 2023

The goal of this branch is to explore how to add support for closures in the stack machine

  • closures are represented as a list of ops and a list of parameter names

  • closure parameters can be used like variables

  • variable names must be unique, so shadowing is forbidden

  • boolean operators use laziness and push the rhs closure on the ops list only if needed (without recursion)

  • .any() and .all() use recursion to compute results

  • closure support in datalog::expression::Op

  • closure support in format::schema

  • closure support in parser

  • closures for lazy boolean operators

  • closures for .any() and .all()

  • prevent shadowing in closure arguments

  • print And and Or with &&! and ||!, without parsing them.

  • v5 block detection depends on Add HeterogeneousEqual and HeterogeneousNotEqual to binary operation #220

divarvel and others added 4 commits December 29, 2023 11:01
- recursive closure evaluation
- no support for serialization nor parsing
instead of calling `Expression.evaluate` recursively, push the closure to the ops vector
no support for nested closures and proper parameter substitution yet
It also includes a list of parameter names for proper parameter evaluation
@Geal Geal changed the base branch from main to v5 May 22, 2024 11:35
Copy link

codspeed-hq bot commented May 26, 2024

CodSpeed Performance Report

Merging #202 will not alter performance

Comparing closures (6fe9bfd) with v5 (3e3f071)

Summary

✅ 12 untouched benchmarks

Copy link

codecov bot commented May 26, 2024

Codecov Report

Attention: Patch coverage is 88.65546% with 27 lines in your changes are missing coverage. Please review.

Project coverage is 68.57%. Comparing base (3e3f071) to head (6fe9bfd).

Files Patch % Lines
biscuit-auth/src/format/convert.rs 85.55% 13 Missing ⚠️
biscuit-auth/src/datalog/expression.rs 92.75% 5 Missing ⚠️
biscuit-parser/src/builder.rs 0.00% 5 Missing ⚠️
biscuit-auth/src/token/builder.rs 80.00% 3 Missing ⚠️
biscuit-auth/src/datalog/mod.rs 75.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##               v5     #202      +/-   ##
==========================================
+ Coverage   67.91%   68.57%   +0.66%     
==========================================
  Files          25       25              
  Lines        5507     5681     +174     
==========================================
+ Hits         3740     3896     +156     
- Misses       1767     1785      +18     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@divarvel divarvel marked this pull request as ready for review May 26, 2024 17:23
@divarvel divarvel requested a review from Geal May 31, 2024 09:03
Copy link
Contributor

@Geal Geal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

great job!

@Geal Geal merged commit 525c278 into v5 Jun 8, 2024
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

2 participants