Hi Stas,

On Tue, May 12, 2015 at 2:19 PM, Stanislav Malyshev <smalys...@gmail.com>
wrote:

> >  - is_digits() and digits type for digits only inputs(integer like
> string)
> >  - is_numeric() and numeric type for float like string
>
> This is not what types are in PHP, and not what they should be, IMO. If
> you want to assign arbitrary checks to a variable, I would suggest using
> a class with a suitable constructor. If you think it's too slow (meaning
> you are doing very heavy in-memory data processing and nothing else),
> make an extension - it would be roughly the same speed as native PHP
> types. If you want it to be extensible - then you may be looking for
> something like pre/post conditions and DbC, but this is another story
> for which we need proper RFCs, etc.
>

I agree that validation and DbC is far better than resolution I proposed
here.
I guess DbC will not prevent users from abusing type hints, though.



> However, calling random combination of native types, objects and string
> constraints "type" because somewhere there's use case for it does not
> look like a good design for a language. It's too random and ad-hoc.


If we aren't going to change any, we need large warning in the manual,
explain nature of external data, compatibility issues between 32 bit and
64 bit CPU, what kind of data is appropriate for native type hints, etc.
It's not a difficult job to do.

How about have functions check if value fits to certain data types,
32 bit int, 64 bit int and IEEE double?

We may add/extend is_digits()/is_numeric() for this. It would be handy
for DbC also.

Regards,

--
Yasuo Ohgaki
yohg...@ohgaki.net

Reply via email to