From:             trosos at atlas dot cz
Operating system: 
PHP version:      Irrelevant
PHP Bug Type:     Feature/Change Request
Bug description:  Exceptions unusually

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.


-- 
Edit bug report at http://bugs.php.net/?id=29111&edit=1
-- 
Try a CVS snapshot (php4):  http://bugs.php.net/fix.php?id=29111&r=trysnapshot4
Try a CVS snapshot (php5):  http://bugs.php.net/fix.php?id=29111&r=trysnapshot5
Fixed in CVS:               http://bugs.php.net/fix.php?id=29111&r=fixedcvs
Fixed in release:           http://bugs.php.net/fix.php?id=29111&r=alreadyfixed
Need backtrace:             http://bugs.php.net/fix.php?id=29111&r=needtrace
Need Reproduce Script:      http://bugs.php.net/fix.php?id=29111&r=needscript
Try newer version:          http://bugs.php.net/fix.php?id=29111&r=oldversion
Not developer issue:        http://bugs.php.net/fix.php?id=29111&r=support
Expected behavior:          http://bugs.php.net/fix.php?id=29111&r=notwrong
Not enough info:            http://bugs.php.net/fix.php?id=29111&r=notenoughinfo
Submitted twice:            http://bugs.php.net/fix.php?id=29111&r=submittedtwice
register_globals:           http://bugs.php.net/fix.php?id=29111&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=29111&r=php3
Daylight Savings:           http://bugs.php.net/fix.php?id=29111&r=dst
IIS Stability:              http://bugs.php.net/fix.php?id=29111&r=isapi
Install GNU Sed:            http://bugs.php.net/fix.php?id=29111&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=29111&r=float

Reply via email to