On Mon, Feb 27, 2012 at 8:15 PM, Kris Craig <kris.cr...@gmail.com> wrote:
> Now, to rewind a bit past the latest chunk of "I hate this idea" posts.... > > I'd like to suggest a new term: "strong". > I think it would be better if we could not introduce terms for new definition if that term is already used in the vocabulary for type systems: http://en.wikipedia.org/wiki/Strong_typing > > This term would be similar to "weak", except with a few key differences: > > - Weak would behave very much like Arvids suggested in his earlier > post; i.e. if the variable is an integer but you pass a string (like "aaa") > to it, a warning would be thrown and PHP would attempt to convert it (i.e. > it would become 1). > > why would "aaa" turn to 1? it would be 0 by the php type juggling rules. > > - Strong, on the other hand, would throw a fatal error if you > attempted to pass an incompatible value to an array. Or, to put it another > way, if the "converted" value does not match the original value. For > example, if we're assigning "aaa" to an integer, that would convert to 1; > and, since "1" != "aaa", a fatal error would be thrown. On the other hand, > if you were to pass the string "1" to that integer variable, it would > convert to 1; and, since "1" == 1, there wouldn't be a problem. > > same error here, it seems that it isn't the typo. putting that aside: so you say that the type checking would behave the same was as does currently the == and === operator. > > - In both instances, if the converted value matches the original (i.e. > "1" == 1), no warning error would be displayed. Should it perhaps display > a notice though? Or no error at all? I can think of reasonable arguments > on both sides of that question. > > I remember seeing that suggestion before, I think that it was proposed more than once, see http://marc.info/?l=php-internals&m=128159992610321&w=3 did you read that thread? -- Ferenc Kovács @Tyr43l - http://tyrael.hu