Open Danack opened 4 years ago
Hi Dan,
thanks for thinking about/working on this whole topic. I think the main problem we have here is that Classes, Functions and Constants are in separate symbol tables. If they where in one unified symbol table, you could just reference classes and functions by name:
<?php
$callable = strlen;
echo $callable("abc"); // 3
Maybe PHP 8 is the right place for doing this? There may be conflicts with constants, but I really don't think using a constant named strlen
when there is a strlen
function is a good idea in the first place.
Any solution for referencing callables, would need to cover all of the types, so maybe something like this.
But I'm really unsure.
I saw this before. The need for the extra syntax $()
seems to be the problem to decide whether you reference a constant or a "type". IMHO if both where in the same symbol table, the extra syntax would not be needed. But I do not have sufficient knowledge of PHP internals to make this a statement, it is just a guess.
So what happens?
Needs thinking about.