FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Expr: user defined functions and lambdas by dantleech · Pull Request #1153 · phpbench/phpbench · GitHub

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 commented Jun 14, 2026
edited
Loading

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 changed the title Lambdas Expr: user defined functions and lambdas Jun 14, 2026
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.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

avoiding this would be the usecase here.

This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
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


Back | FazBrowse Home | New Git URL