On Fri, 2024-08-23 at 07:39 +0100, Rowan Tommins [IMSoP] wrote: > > > On 23 August 2024 00:15:19 BST, Mike Schinkel <m...@newclarity.net> > wrote: > > Having to prefix with a name like Foo, e.g. Foo\strlen() is FAR > > PREFERABLE to _\strlen() because at least it provides satiating > > information rather than the empty calories of a cryptic shorthand. > > #jmtcw, anyway. > > I knew I'd regret keeping the example short. Realistically, it's not > a substitute for "\Foo\strlen", it's a substitute for > "\AcmeComponents\SplineReticulator\Utilities\Text\strlen". > > Having a syntax for "relative to current" is incredibly common in > other path-like syntaxes. The most common marker is ".", and ".\foo" > is literally how you'd refer to something in the current directory > under DOS/Windows. But unfortunately, we don't have "." available, so > I wondered if "_" would feel similar enough. > > Another option would be to find a shorter keyword than "namespace" to > put it in front. "ns\strlen(...)" is an obvious step from what we > have currently, but it's not very obvious what it means, so maybe > there's a different word we could use. > > Rowan Tommins > [IMSoP]
Could be mistaken, but I think the way PHP handles namespaces internally is sort of the same as a long string, rather than as a tree/hierarchy. ie. \AcmeComponents\SplineReticulator\Utilities\Text\strlen is really like: class AcmeComponentsSplineReticulatorUtilitiesTextstrlen { public function __construct(){ } } And the "AcmeComponentsSplineReticulatorUtilitiesText" just kind of gets appended to the front when the class name is registered. I haven't done work on the namespace code, but I recall reading this somewhere recently.