Re: Proposal: namespace the SPL

From: Date: Thu, 18 Feb 2021 14:48:47 +0000
Subject: Re: Proposal: namespace the SPL
References: 1  Groups: php.internals 
Request: Send a blank email to internals+get-113207@lists.php.net to get a copy of this message
On Thu, Feb 11, 2021 at 9:39 AM Levi Morrison <levim@php.net> wrote: > > Hello, everyone, > > There has been a lot of disagreement about namespacing, and people > seem to have different viewpoints. I am not sure how to reconcile this > broader discussion. > > However, there are certain names in the global namespace which I am > hopeful we can revolve. For instance, SplObserver, > SplQueue, > SplFixedArray, etc all follow the > Spl prefix. There is already an > established "namespace" for these names. > > So here is my limited proposal: > 1. We create names in the Spl namespace that are aliases to > their > equivalent types with the Spl prefix: > Spl\FixedArray -> SplFixedArray > Spl\Queue -> SplQueue > a. The new names are the aliases so any code which uses > get_class($obj) will not have the name change on them in a > minor > release (8.1). > b. We may switch the direction of this alias in 9.0. > 2. Any new types going into ext/spl use the > Spl namespace. New > types added to ext/spl should be either related to data > structures > or iterators, which is the bulk of what the SPL is. > a. This rule is to help prevent the SPL from becoming the dumping > grounds for new types. > 3. We leave functions alone for now. > > Let me know what you think. I am hopeful this approach will work because: > 1. It is focused on a specific area which already has an established > "namespace", but in name-only (not technically). > 2. It does not try to solve the larger problem, which has a lot of > disagreement. > 3. I will be proposing new types for ext/spl soon > (ReverseIterator > and an array iterator that is more efficient than > \ArrayIterator), > and Tyson Andre has already proposed CachedIterable and company > which is in ext/spl, so this space has active development. > > Thank you for your time. > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: https://www.php.net/unsub.php > There's been a lull in feedback, so let me steer it towards a specific point that was brought up: how do you feel about adding aliases from \Spl\Thing to \SplThing? https://strawpoll.com/22pcxh69p

« previous php.internals (#113207) next »