#34543 [NEW]: Improving usability by redefining use of semicolon as statement separator
| From: | douglas dot s dot green at gmail dot com | Date: | Sun, 18 Sep 2005 17:48:48 +0000 |
| Subject: | #34543 [NEW]: Improving usability by redefining use of semicolon as statement separator | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-85208@lists.php.net to get a copy of this message | ||
From: douglas dot s dot green at gmail dot com
Operating system: Any
PHP version: 5.0.5
PHP Bug Type: Feature/Change Request
Bug description: Improving usability by redefining use of semicolon as statement separator
Description:
------------
The semicolon as a statement separator has usability issues in general
(not just for PHP, for all languages that use this method). First of all,
it is 99% redundant. In almost all the code I have ever seen, there is a
one-statement-per-line norm. The rare exception is when multiple
statements are put on one line (almost no one ever does this and it is
discouraged) and when a single statement is continued to multiple lines
(this happens rather more often).
So if you have a 10,000 statement program (excluding blocks or whatever),
you must remember to place 10,000 semicolons. Lack of any one of those
10,000 semicolons can cause the program not to run because of a syntax
error. All this just so that in 1% of cases, a statement can be put on
multiple lines without the use of a continuation operator. So you are
spending 10,000 to save 100.
It seems to me that an alternate syntax could be developed that dispenses
with semicolons as separator, and uses a continuation operator instead to
signal the presence of multiple lines, something like >>.
Reproduce code:
---------------
// This example does not show a BUG, it merely demonstrates a proposed
FEATURE using code from this site
class Exception {
protected $message = 'Unknown exception' // exception message
protected $code = 0 // user defined exception
code
protected $file // source filename of
exception
protected $line // source line of exception
function __construct($message = null, >>
$code = 0);
final function getMessage() // message of exception
final function getCode() // code of exception
final function getFile() // source filename
final function getLine() // source line
final function getTrace() // an array of the
backtrace()
final function getTraceAsString() // formated string of trace
/* Overrideable */
function __toString() // formated string for
display
}
Expected result:
----------------
Beginning PHP programmers get happy because they do not have to look at
obscure error messages that really mean a semicolon is missing.
Actual result:
--------------
Beginning programmers waste 30 minutes staring at their code trying to
figure out where the semicolons should go. Repeat times infinity.
--
Edit bug report at http://bugs.php.net/?id=34543&edit=1
--
Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=34543&r=trysnapshot4
Try a CVS snapshot (php5.0): http://bugs.php.net/fix.php?id=34543&r=trysnapshot50
Try a CVS snapshot (php5.1): http://bugs.php.net/fix.php?id=34543&r=trysnapshot51
Fixed in CVS: http://bugs.php.net/fix.php?id=34543&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=34543&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=34543&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=34543&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=34543&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=34543&r=support
Expected behavior: http://bugs.php.net/fix.php?id=34543&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=34543&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=34543&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=34543&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=34543&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=34543&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=34543&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=34543&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=34543&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=34543&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=34543&r=mysqlcfg