DEV Community

Discussion on: PHP needs its own ES6

Collapse
 
hamatti profile image
Juha-Matti Santala • Edited

Sure. I took a quite literal ES6 way of thinking here in a way that it would require some compiling/transpiling back to original.

So maybe we could have

array(1,2,3,4,5,6)
  ->filter(function(num) { return num % 2 === 0; })
  ->map(function(num) { return num * 2 ;})

that would then transpile into

array_map(
   function(num) { return num * 2; },
   array_filter(
     [1,2,3,4,5,6],
     function(num) { return num % 2 === 0; }
   )
)

so that it would be compatible with real deal.

Like I mentioned, I'm not a language designer nor do I know much about how to make languages or compilers but this is the high-level thinking I have.