Re: RE: Optional scalar type hinting

From: Date: Fri, 04 Jan 2008 19:15:08 +0000
Subject: Re: RE: Optional scalar type hinting
References: 1 2 3 4 5  Groups: php.internals 
Request: Send a blank email to internals+get-34457@lists.php.net to get a copy of this message
I've stated my opinion on this, I'm going for standard hinting. Int means int, not "1" or "one" or "1one". Bool means boolean true or false,
I don't see any difference in substance between 1 and "1".
not "true", 1, 0, "0", etc.
Same for boolean - I don't see any substantial difference between (int)0, (float)0 and (boolean)false and see no reason ever to make a function that distinguishes between those. Now, statically-typed compiled languages do it for the very good reason - it is very hard to implement such versatile API manually. It is infeasible to make all C function declared as foo(int i) to take char* instead and use atoi() or whatever it needs to be - and do it for each and every function. That's exactly why scripting languages with loose typing were created - to allow programmers to get rid of these technicalities and work with substance of the values, not with bit representation of them. Now you come back and say - no, my function would accept (boolean)0 but would pretend it can not handle (int)0 because the bits in a type field of the variable are wrong. What could be the practical purpose of such dumbing-down? Getting all the stress of the programming in statically typed language without compile-time checking and safety as a compensation for the stress? Doesn't look as a good deal for me. -- Stanislav Malyshev, Zend Software Architect stas@zend.com http://www.zend.com/ (408)253-8829 MSN: stas@zend.com

« previous php.internals (#34457) next »