On Sun, Jul 5, 2026, at 3:33 PM, Michal Kral wrote:
> > take a cue from Kotlin and C#: Extension functions. Attach method-ish
> > behavior to any type.
>
> I like it, and it's a real answer to the mechanics question, not just
> the set one. Two honest things before I'd be sold:
>
> - Scoping of the common ops. If I have to write `use Php\Str\length for
> string;` in every file to call `$s->length()`, that's more ceremony than
> the plain function it replaces. Do the core ops come always-in-scope,
> with `use` reserved for userland extensions? The gist didn't pin that
> down, and it seems load-bearing for whether this is pleasant to use day
> to day.
> - Which points at a hybrid I'd actually be keen on: core provides the
> common scalar ops always-in-scope, extension functions handle
> userland/domain-specific additions with `use`. That keeps your
> extensibility and unbounded-ness without making the everyday case pay an
> import.
We hadn't thought about any special-casing. My assumption was that in most
cases the IDE will figure it out and inject the `use` statement for you, just
as it does for classes and functions now, so most of the time I don't think
about it.
One of the goals of extension functions would be to unblock new APIs for
scalars and iterables, built as extension functions. So yes, a String\length()
function, but also an iter\map() that works on any iterable, etc. None of
those would be in the initial implementation, but then it becomes a fairly
straightforward process to create and add them. But they would not have
exclusive access to that syntax.
> Also, the compile-time pre-resolution your writeup mentions ("if we can
> determine the type at compile time, pre-resolve, avoid runtime
> overhead") is basically what I've already built for the guaranteed-type
> cases, so there's working code for that half.
+1
> > would be happy to work on it if someone wants to partner on it
>
> Genuinely interested. I'd like to see where this mechanics discussion
> lands first, but I'm glad to talk — there's real overlap with what I
> already have working, and no illusions about the 8.6 timeline.
>
> Michal
I'm on vacation for the next week and a half, but let's discuss off list after
that. Email me or track me down in the PHPC Discord (Crell).
--Larry Garfield