Re: Call for Votes: JSON location
| From: | Justin Patrin | Date: | Sat, 08 Apr 2006 03:49:21 +0000 |
| Subject: | Re: Call for Votes: JSON location | ||
| References: | 1 2 3 4 5 6 7 8 9 | Groups: | php.pear.dev |
| Request: | Send a blank email to pear-dev+get-42156@lists.php.net to get a copy of this message | ||
On 4/7/06, Greg Beaver <cellog@php.net> wrote:
> Pierre wrote:
> > On 4/8/06, Daniel Convissor <danielc@analysisandsolutions.com> wrote:
> >
> >>Hi Pierre!
> >>
> >>On Fri, Apr 07, 2006 at 11:57:43PM +0200, Pierre wrote:
> >>
> >>>What's about a one to one mapping to pecl/json?
> >>
> >>I can interpret this to mean a few different things. Can you explain
> >>exactly what you're thinking, please?
> >
> >
> > In short:
> >
> > if (!extension_loaded('json')) include 'JSON.php';
> >
> > --Pierre
>
> From an extensibility standpoint, this seems to me a bad idea.
>
> If the json extension were to change the way the code works or introduce
> a bug (heaven forbid), there would be no easy way to fall back to
> JSON.php if the json extension were loaded, as they would directly
> conflict. Of course, one could go through JSON.php and rename
> everything - and do the same in all of the code that uses it, but this
> gets tedious fast.
>
I agree. The solution is to have JSON.php be a class, like normal PEAR
code, and have a further include which can be used to set the json
extension functions if people want this.
Going even further, JSON.php could be a parent class which loads a
backend which is either a PHP implementation (this package) or the
extension. This would allow both types of usage.
Developer 1 starts with json extension but wants to support people who
don't/can't have it. They use the include which sets the functions
json extension style.
Developer 2 uses PEAR from the start but wants to use the json
extension, if loaded, as it's faster.
--
Justin Patrin