ID:               40296
 Comment by:       michael at chunkycow dot com dot au
 Reported By:      mail at tobyinkster dot co dot uk
 Status:           Open
 Bug Type:         Feature/Change Request
 Operating System: All
 PHP Version:      5.2.0
 New Comment:

G'day

Perl has lots of 'features' in it, although I cannot see how an 
'unless' control structure adds to anything but confusion for
existing/new developers.


Previous Comments:
------------------------------------------------------------------------

[2007-01-31 12:26:42] mail at tobyinkster dot co dot uk

Description:
------------
It would be nice if PHP had an "unless" control structure so that:

    unless (...) { ... }

would be equivalent to:

    if (!(...)) { ... }

Although the "unless" control structure is actually slightly more
verbose (in bytes) than "if", it is arguably a lot more readable in the
following examples:

    unless ($a==0 || $b==0)
        divide_by($a*$b);

versus:

    if (!($a==0 || $b==0))
        divide_by($a*$b);

or, equivalently using De Morgan's Law (Google for it):

    if ($a!=0 && $b!=0)
        divide_by($a*$b);

The "unless" structure uses less punctuation, and more human syntax. I
can't imagine how this extra syntax would break any existing scripts.

For what it's worth, Perl already has an "unless" control structure.



------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=40296&edit=1

Reply via email to