php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #29111 Exceptions unusually
Submitted: 2004-07-12 23:41 UTC Modified: 2004-07-14 09:41 UTC
From: trosos at atlas dot cz Assigned:
Status: Wont fix Package: Feature/Change Request
PHP Version: Irrelevant OS:
Private report: No CVE-ID: None
 [2004-07-12 23:41 UTC] trosos at atlas dot cz
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.


Patches

Pull Requests

 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Dec 26 10:01:29 2024 UTC