RE: [PHP-DEV] GMP object and is_scalar()

From: Date: Mon, 30 Dec 2013 21:55:53 +0000
Subject: RE: [PHP-DEV] GMP object and is_scalar()
References: 1 2 3 4 5 6 7 8  Groups: php.internals 
Request: Send a blank email to internals+get-70934@lists.php.net to get a copy of this message
> -----Original Message-----
> From: yohgaki@gmail.com [mailto:yohgaki@gmail.com] On Behalf Of Yasuo Ohgaki
> Sent: Monday, December 30, 2013 10:46 PM
> To: Stas Malyshev
> Cc: Nikita Popov; internals@lists.php.net
> Subject: Re: [PHP-DEV] GMP object and is_scalar()
> 
> Hi Stas,
> 
> On Tue, Dec 31, 2013 at 6:35 AM, Yasuo Ohgaki <yohgaki@ohgaki.net> wrote:
> 
> > On Tue, Dec 31, 2013 at 6:31 AM, Stas Malyshev <smalyshev@sugarcrm.com>wrote:
> >
> >> > Since this (GMP numbers work like normal numbers) is new feature, we
> >> > may choose better option.
> >>
> >> I think you're taking it way too far. GMP numbers may support some
> >> functions that scalars support, but that does not mean every function -
> >> especially functions with are *specifically designed* to distinguish
> >> scalars from objects - would do the same thing for them as for scalars.
> >> If you're interested in their "numeric" properties - i.e. adding them,
> >> multiplying them, etc. - fine, they work that way. But if you "pop the
> >> hood" and look inside - no, they should not be scalars inside, because
> >> they are not.
> >
> >
> > I agree with your opinion in general.
> >
> > How about introduce scalar object that is evaluated as scalar?
> > It would be useful in user land also.
> >
> 
> http://www.php.net/manual/en/language.oop5.magic.php
> 
> Something like __toScalar(), may be?
> 
> --
> Yasuo Ohgaki
> yohgaki@ohgaki.net

I think __toScalar is way to wage, what will __toScalar() return? a bool, an int, a float or a
string?



Thread (17 messages)

« previous php.internals (#70934) next »