Skip to content

Expr: user defined functions and lambdas#1153

Draft
dantleech wants to merge 7 commits into
masterfrom
lambdas
Draft

Expr: user defined functions and lambdas#1153
dantleech wants to merge 7 commits into
masterfrom
lambdas

Conversation

@dantleech

@dantleech dantleech commented Jun 14, 2026

Copy link
Copy Markdown
Member

This PR introduces a way to define lambdas in the expression language and allows the definition of user defined functions:

(((foo, bar) => foo + bar)(1, 2) = 3) = true

While there is are no "higher order" functions that accept lambdas, this syntax is useful for defining named functions:

{
  "expression.user_functions": {
     "add_one": "(number) => number + 1"
  }
}

This is particular useful in report generation to avoid excessive repitition.

TODO:

  • While users can register expressions, PHPBench itself can't currently and if it did it would contaminate the userspace. Perhaps the expression generator should be able to define it's own functions at "runtime" (?)

@dantleech dantleech changed the title Lambdas Expr: user defined functions and lambdas Jun 14, 2026
@dantleech
dantleech marked this pull request as draft June 14, 2026 10:11
), E_USER_DEPRECATED);
}

$baselineExpr = function (string $primaryExpr, string $baselineExpr) {

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

avoiding this would be the usecase here.

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