in reply to while () vs. while (1)

Besides saving a character is it preferable to while (1)?

Absolutely not

When did it get added to the language?

Seeing how it is not documented in the documentation anywhere, it could be argued it is not part of the language :)

#38254: Inconsistent behaviour of 'while ()' and 'until ()'

Replies are listed 'Best First'.
Re^2: while () vs. while (1)
by ikegami (Patriarch) on Jan 22, 2011 at 00:54 UTC

    Seeing how it is not documented

    You could even say it's documented to behave differently than it does. Empty lists* evaluate to false, but while () {} loops endlessly.

    $ perl -E'while (()) { say("foo"); last }' $ perl -E'say("foo"), last while ();' $ perl -E'while () { say("foo"); last }' foo

    Intentionally or otherwise, it's definitely related to for (;;).

    * — Parens don't create lists. Parens are sometimes required to indicate the presence of an empty list (e.g. "my $x = ;" and "= f();" are invalid), but not always (e.g. "print;" and "for () {}" are valid).