I cry whenever I see code with @ in it...
I don't like @ either. The whole point of this proposal though is to offer a safe alternative, a way to suppress only those notices which are being accounted for by the programmer and no more, without messing around making a custom error handler that ignores one type of error, which is the current way to do it 'safely'.
What we're wanting are existential assignment and ternary operators. Simply put, a painless way to set or use a default value based on the existence of a variable without needing a bunch of extra code to avoid notices/errors. Sorry Ben, but I think extending the @ operator to prevent errors from being generated in the first place is a terrible idea. I would prefer to see @ removed from PHP if possible.
I never meant to extend @, I meant simply to reuse that symbol--i.e. the @ character--as part of the syntax of a new safer feature, since it performed a similar function. The actual @ operator is not changed in any way. Rather, a new @[...] array indexing mechanism is added which suppresses the Undefined Index notice, and only that notice, by not generating it.
I would also want this to work with objects and scalars. It would be particularly useful within view scripts where the values are passed in via extract, or as object properties, and you can't instantiate them first because that would clear them.
I guess that's a vaguely valid use case, though I still somewhat think it is the responsibility of the caller of the view script to ensure all variables are instantiated (to null if appropriate). I guess an unambiguous syntax for this could be $@variable. I guess object properties are another case. I wonder how common. I guess $object@->property would be the way to deal with that. I still lean towards just offering it for arrays, though. That seems to be the area of greatest need by a significant margin. Ben. -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php