preprocess / pre-short-closures Goto Github PK
View Code? Open in Web Editor NEWLicense: MIT License
License: MIT License
I noticed that in your most recent macro, you are using ~> as the symbol for short closures. I am interested in the reason behind this choice. Is it for technically reasons, as it may be difficult or impossible to just use => as symbol? Or could it be that you are anticipating that PHP will be using ~> for its own short closure implementation in future, so it is an attempt to be consistent with the language itself? Just curious.
Is it possible to edit/add a macro that parses a arrow function that omit's the accolades?
ie.
($t, $k, $v) => { return str_replace("{" . $k . "}", $v, $t ); }
would become
($t, $k, $v) => str_replace("{" . $k . "}", $v, $t )
and when there is only one parameter the (
and )
can be omited, i.e.
$key => str_replace(' ', '', $key)
It seems that short closure without braces aint working for me. This code cannot be compiled into the correct syntax in PHP:
$result = array_map($x ~> $x * 2 * ++$y, range(1, 10));
Instead it has parse error: 'syntax error, unexpected '~', expecting ',' or ')''. Apparently the issue is with expression() identifier which doesnt seem to work, its a bug with Yay library. I wonder if you have a workaround for this issue, or we may have to wait a response from marcioAlmada to fix Yay. Or if you dont have the same problem as I do, lemme know too.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.