Re: RE: Optional scalar type hinting
| From: | Sam Barrow | Date: | Thu, 03 Jan 2008 19:52:28 +0000 |
| Subject: | Re: RE: Optional scalar type hinting | ||
| References: | 1 2 3 4 5 6 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-34340@lists.php.net to get a copy of this message | ||
Just so anyone who wants it has it, I have attached the last version of
my patch.
Note that it still issues a fatal error but this can be changed very
easily, would take me about 2 minutes.
Full specs:
Type hinting patch allows for 8 new type hints, in addition to array and
class type hinting.
- Integers (specified by "int", "integer", or "long")
- Floats (specified by "float", "double", or "real")
- Numbers (matches integers and floats, specified by "num" or "number")
- Strings (specified by "string")
- Booleans (specified by "bool" or "boolean")
- Scalars (matches strings, booleans, and numbers; specified by
"scalar")
- Resources (specified by "resource")
- Objects (matches any object, specified by "object")
The patch specifies a constant, PATCH_SCALAR_TYPE_HINTING, just there to
indicate that the patch is installed.
On Thu, 2008-01-03 at 20:23 +0100, Derick Rethans wrote:
> On Thu, 3 Jan 2008, Stanislav Malyshev wrote:
>
> > > When the type hint says I want an integer, then only integer should be
> > > accepted; no casting should be done. It may give predictable results
> >
> > Why people that want Java just don't use Java I wonder? PHP never was a strict
> > static typed language.
>
> Broken record perhaps? I am getting a bit tired of this "just use Java
> argument", it's perhaps even a bit arrogant. From what I read there is
> plenty of people that want type hints for static types - there's a few
> patches out there, it doesn't slow down the general case. So why should
> we *not* add it? (And yes, I changed my mind)
>
> regards,
> Derick
>
> --
> Derick Rethans
> http://derickrethans.nl |
> http://ezcomponents.org |
> http://xdebug.org
>
Attachment: [text/x-patch] scalartypehinting.patch
Attachment: [text/x-patch] scalartypehinting.patch