inline posted
> I cry whenever I see code with @ in it... > > I always cry when somebody thinks that the @ cannot be used correctly. btw we have the scream extension and xdebug.scream also, and you could use an error handler to "scream" the errors suppressed by @, so I don't know why are you crying. > > 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. > > > there are cases where you can't write clean code without @. for example there is an instruction, which can generate an error and you can predict that it is "safe" to execute or not. for example: - http://php.net/manual/en/simplexmlelement.construct.php<http://hu2.php.net/manual/en/simplexmlelement.construct.php> - http://php.net/manual/en/function.simplexml-load-file.php which can be worked around with http://php.net/manual/en/function.libxml-use-internal-errors.php<http://hu2.php.net/manual/en/function.libxml-use-internal-errors.php> or another example would be serialize/unserialize: http://www.php.net/manual/en/function.unserialize.php it can be a perfectly valid to suppress the notice and check for the return value of the serialize/unserialize call to handle errors locally. another example: you have a script, which checks for a cache file, if present then you simply read it, if not, then you generate the result and write it to the cache file, which gets invalidated(deleted) if it's older than x. but you can't atomically check the existence of the file then read it. and it can happen (race condition) that you the file was present when you checked with file_exists, but it is deleted when you try to open it in the next line. I think that it could be a good idea to provide an operator to not just change the error reporting level, but to simply prevent the error generation. of course its a tricky question: should we discard the error if an error handler is registered? Tyrael