[RndTbl] PHP undefined vars / array indices

Trevor Cordes trevor at tecnopolis.ca
Wed Jan 19 04:49:08 CST 2022


On 2022-01-13 Adam Thompson wrote:
> I don’t really have a horse in this race, but I think John make one
> factual error.  It’s minor and doesn’t change his point, but:
> if(!i++) { ... } is perfectly valid in C, where 0==false.  It’s
> equivalent to (I think…): if(i==0) { i++; ... } else { i++; ... };
> IIRC, C has the comma operator, albeit thankfully rarely used, so if
> you really wanted to do this, I think it could be slightly better
> written: if(i==0, i++) { ... } I could be wrong, I haven’t attempted
> to write C code in 25+ years.  It’s not something you would want to
> see, but you certainly could.

Hey, I use comma all the time! :-)  Well, when it makes sense.  Usually
in super long perl-oneliners or to get a lot accomplished in one
expression in a perl regex using /e.

Perl allows your if(i==0,i++) so I'm nearly positive C would too (Brad,
paging Brad...).

> But at the same time, this is a
> seemingly-gratuitous language change that reminds me VERY strongly of
> system all of a sudden being shoved down everyone’s throats, even
> though systemd introduces some good features that were previously

Funny, in my discussions with people, systemd came up a lot.  But
rejigging my systems to "speak systemd" took a few hours for my own box
and a few more for all my customers.  My main beef with the PHP change
is it will literally take me weeks to change, a tough sell to my
clients (and myself for my own projects)!  And your systemd example is
even better because systemd promised (and delivered) on many fine
improvements (faster boot, standardized declarative unit files).  The
pain bought us quite a bit.  (Though I still hate systemd and wish it
never had been made, but maybe more so because of Lennart at this point
than the actual product; oh and the whole "everything creep" thing.)
:-)

> Perhaps this is like Perl 6, where it’s nearly a completely different
> language from the previous version, sharing the name and basic
> syntax?  But at least there’s still a team patching security holes in
> Perl 5.  I have no confidence that would happen with PHP. -Adam

Perl 5 is still actively developed.  In fact, I do believe it gets more
dev attention than 6 ever will.  I have never seen 6 code in use in the
wild.  Ever.  As a 30 year perl fan, while I like to read about 6, I
have no plans whatsoever to use it in the near or distant future.

It's funny, had this discussion with someone too: We all thought Perl
botched it with 6.  What a disaster was 6!  Splitting perl.  Changing
the language too much, yada yada.  But you know what, I think what
happened with 6 was the best thing that could have happened!  Think
about it, had they instead slowly morphed 5 into 6 over the years,
making the ton of backwards incompatible changes that would be
required, no one would be using 5 *or* 6 right now.  Instead they did
the best thing possible: have a hard split and make a new language and
maintain both.  The only mistake they made (IMO) is naming it Perl 6.
They should have just come up with a whole new name -- maybe some play
on the word Perl.

At the rate PHP is moving with the cray cray changes, they'll make a
mistake worse than Perl made, and maybe suffer its same loss of
popularity.  Remember, perl once held the admin/glue title that python
now owns.

The more I seethe about the PHP change, the more I seriously ponder
making my own fork, or my own "unfixed"-version repo, or trying to get
a granular logging feature introduced into master project (h/t
Richard).  The real tell would be if I made a great granular log
settings patch (like Node, again h/t Richard) and PHP rejected it
because their real goal is to force their style choices on the world
(I'd peg that at 50/50 at the moment... or worse).



More information about the Roundtable mailing list