Download the PHP package md/lambda-preprocessor without Composer

On this page you can find all versions of the php package md/lambda-preprocessor. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package lambda-preprocessor

A hack-like lambda syntax for PHP

In Hacklang, a lambda expression is denoted by using the lambda arrow ==>. Left of the arrow are arguments to the anonymous function and on the right hand side is either an expression or a list of statements.

This pre-processor is meant to make that syntax available in native PHP applications. This does not happen at runtime, so there is no hit on perfomance. The pre-processor works on top of the pre plugin and the yay macro library.

Syntax wise, and due to the fact that Yay does not have an expresison parser yet, even though Hack supports a single expression to be written without the need of curly brakets, this pre-processor will always require the curly brakets to be written. Hopefully this will change once Yay develops further.

Oneliner anonymous function

The simplest example is an anonymous function that returns the argument it was given in the first place. In PHP it could be written as:

Which can be written, using this pre-processor, much simpler:

Should we need to declare typehints or pass more than one argument, we will need to use parenthesis. We could also use parenthesis in the example above, but it is optional for single arguments with no type hinting.

Which is translated to:

Or with type hints:

Which is translated to:

Multiple lines anonymous functions

The same rules for arguments, typehints and return types still apply for anonymous functions with multiple lines. The only difference is that you will need to write the return keyword in the last statement of the block, and you must now end every statement with a semicolon.

This is translated into:

Closures

PHP provides the keyword use to capture variables from the enclosing scope. Hack's lambdas make this even easier. You can use variables implicitly inside of a lambda. This is available when you use this pre-processor.

Note that to use $lastname with the official syntax you would have to use the use keyword, as shown below:

Recursive calls and precedence

The pre-processor will translate the inner block and then the outer. The precedence with this syntax is a bit more obvious than the hack one. In hack you can ommit the brakets {, }. Here, it should be straightforward that the expression:

will be translated into:

Final Notes


All versions of lambda-preprocessor with dependencies

PHP Build Version
Package Version
Requires yay/yay Version ^0.2
pre/plugin Version ^0.7.3
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package md/lambda-preprocessor contains the following files

Loading the files please wait ....