In php.dev Markus Fischer <[EMAIL PROTECTED]> wrote:

> I was talking about telling the 'undefined behaviour' case; not
> what happens with the values exactly. I don't see a drawback in
> documenting an 'undefined behaviour'. It's good for people to
> have a torough documentation which even warns them before they're
> doing silly things. Note that the majority of users of PHP are
> non-programmers. Warning them before they shoot themselves a good
> thing [tm].

I think documenting this undefined behaviour is a good thing.

Maybe something like this on language.operators.assignment.php:

  Assigning to a variable more than once in the same expression leads to
  "undefined behaviour" - this means you _might_ get the result you want,
  but this can change with the PHP version or the machine your code is
  running on, or even with the phase of the moon. Just don't do it.

  Don't do something like this:

    $b = ($a += 1) + ($a += 2);

  Instead use:

    $b = $a += 1; 
    $b += ($a += 2);

  Between assignments to the same variable, always use a semicolon. If
  you're not sure about operator precedence, use parentheses.


And almost the same on language.operators.increment.php:

  Incrementing or decrementing a variable more than once in the same
  expression leads to "undefined behaviour" - this means you _might_ get
  the result you want, but this can change with the PHP version or the
  machine your code is running on, or even with the phase of the moon.
  Just don't do it.

  Don't do something like this:

    $b = ($a++) + ($a++);

  Instead use:

    $b = $a++; 
    $b += $a++;

  Between incrementing or decrementing the same variable, always use a
  semicolon.

Regards...
                Michael

-- 
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to