|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull Requests |
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Nov 02 14:00:01 2025 UTC |
Description: ------------ In php, you can easily write functions, that consist of one, very large command (its parts are connected with ANDs and ORs). When use this style (it is sometimes more then suitable), it is very difficult to use commands, that have no return value (non-expression commands). You have written an object-oriented model of exceptions - I feel it very important, but in case of large-command-style it could not be used. php is the language for all situations - why not to make some alternatives, how to use exceptions, then? ---- What am I requesting to? -- I would like to have an alternative of using exceptions through expressions (without need of using non-expression commands). ----- How would I solve this? -- - new type: t_exception - when some function comes to work with an expression in t_exception, this function makes nothing another and ends with return value in t_exception - new unary operator: @@ (or something other) - new type: t_safeexception - the result of the @@ operator is value of its parameter; the difference can be felt when type of parametr is t_exception: in this case is returned value converted to t_safeexception (this type is "safe" - it means, that the work with it does not stop the function) Reproduce code: --------------- This is only an example code to show, how could seem the one-command-style. Function f() have not real purpose. <?php function f() { $Result=0; while ((( !is_numeric($foo = foo()) ) or ( ($Result += 2*$foo) or True ) ) and ( ##bar() !==exception ) ) {}; return($Result); } ?> There, we are not interested in, whether foo() returns a t_exception value (if it does so, function f() returns t_exception too); but if bar() returns a t_exception value, function f() regularly ends and returns $Result.