#34543 [Opn->Bgs]: Improving usability by redefining use of semicolon as statement separator

From: Date: Sun, 18 Sep 2005 17:58:17 +0000
Subject: #34543 [Opn->Bgs]: Improving usability by redefining use of semicolon as statement separator
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-85209@lists.php.net to get a copy of this message
ID: 34543 Updated by: helly@php.net Reported By: douglas dot s dot green at gmail dot com -Status: Open +Status: Bogus Bug Type: Feature/Change Request -Operating System: Any +Operating System: * -PHP Version: 5.0.5 +PHP Version: * New Comment: Thank you for taking the time to write to us, but this is not a bug. Please double-check the documentation available at http://www.php.net/manual/ and the instructions on how to report a bug at http://bugs.php.net/how-to-report.php If you look at c/c++ you'll find out why c-like language keep with the ;. For one there are things that need the ; to distinguish where an expression is ending (and there is no other way) and second these languages allow multi line statments so the ; is the best way to increase readability and bring clearification to both programmers and compilers. Previous Comments: ------------------------------------------------------------------------ [2005-09-18 19:48:46] douglas dot s dot green at gmail dot com 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 this bug report at http://bugs.php.net/?id=34543&edit=1

« previous php.bugs (#85209) next »