On Sep 24, 2015 09:07, "Lester Caine" <les...@lsces.co.uk> wrote:
>
> On 24/09/15 07:39, Marco Pivetta wrote:
> >  - I'm still conflicted on automatically importing all of the scope into
> > the closure: while it is working for functional languages, that's where
> > most of the headaches come from in languages such as javascript.
>
> Isn't this the crux of some decisions? Once one adopts compiling as an
> essential step a number of the rules can be changed. So is PHP heading
> down the path of a compiled language even if that is hidden in some
> automatic cache or is it still mainly an interpreted script? Lots of
> things are easier if you apply optimization in the compile stage but
> that then blocks many of the dynamic actions which PHP *IS* so good at.
> The sort of thing that allows thousands of pages of content to be stored
> in a database without some of the straight jacket that some people seem
> to think is essential these days?
>
> If I'd wanted a fully compiled system I'd have stayed with C/C++ all
> those years ago ... as I keep harping on PHPs dynamic nature is it's
> strength?
>

I assume you mean strongly typed, because PHP has had a compiler for about
18 years ;)

The main restriction on PHP's compiler is really that it has to be
reasonably fast, it can't afford to do all the clever and very expensive
optimizations that for example gcc does. Maybe less so today when we can
expect everyone to have an op cache, but still.

Auto-importing variables would not be expensive, or even noticeable. But it
breaks completely from PHP's model of always being explicit about taking
symbols from another scope (globals). This is a property on which PHP
differs from other languages such as JS, Ruby or Groovy, which have similar
constructs. Is it OK to introduce an exception to that only for the sake of
having (an admittedly handy) short syntax for closures?

It's one of these "you want it, but it's not good for you" predicaments. My
vote will be no, unfortunately.

- Stig

Reply via email to