Why use semicolon? [duplicate]

Asked
Active3 hr before
Viewed126 times

4 Answers

90%

Because JavaScript does nasty things to you when it guesses where to put semicolons. It's better to be explicit and let the interpreter know exactly what you meant than it is to let the idiot box guess on your behalf.,http://aresemicolonsnecessaryinjavascript.com/ <- this is down now, use ,Are there any reasons, apart from subjective visual perception and cases where you have multiple statements on the same line, to use semicolon at the end of statements in JavaScript?,in JavaScript you should terminate the lines with a semicolon, but are allowed (PDF, page 26, point 7.9) to omit it, if it's unambiguous

load more v
88%

Are there any reasons, apart from subjective visual perception and cases where you have multiple statements on the same line, to use semicolon at the end of statements in JavaScript?,It looks like there are very few reasons, or, actually, edge cases, when one would want to use semicolons.,Because JavaScript does nasty things to you when it guesses where to put semicolons. It's better to be explicit and let the interpreter know exactly what you meant than it is to let the idiot box guess on your behalf.,It looks like that there's plenty of evidence suggesting that use of semicolons is highly optional and is required in only few of the specific cases.

72%

When building up a PL/SQL anonymous block, include the semicolon at the end of each PL/SQL statement and at the end of the anonymous block. For example:,Using the EXECUTE IMMEDIATE Statement in PL/SQL, Using the EXECUTE IMMEDIATE Statement in PL/SQL ,To process most dynamic SQL statements, you use the EXECUTE IMMEDIATE statement. To process a multi-row query (SELECT statement), you use the OPEN-FOR, FETCH, and CLOSE statements.

Example 7-1 Examples of Dynamic SQL

CREATE OR REPLACE PROCEDURE raise_emp_salary(column_value NUMBER,
   emp_column VARCHAR2, amount NUMBER) IS
v_column VARCHAR2(30);
sql_stmt VARCHAR2(200);
BEGIN
--determine
if a valid column name has been given as input
SELECT COLUMN_NAME INTO v_column FROM USER_TAB_COLS
WHERE TABLE_NAME = 'EMPLOYEES'
AND COLUMN_NAME = emp_column;
sql_stmt: = 'UPDATE employees SET salary = salary + :1 WHERE ' ||
   v_column || ' = :2';
EXECUTE IMMEDIATE sql_stmt USING amount, column_value;
IF SQL % ROWCOUNT > 0 THEN
DBMS_OUTPUT.PUT_LINE('Salaries have been updated for: ' || emp_column ||
   ' = ' || column_value);
END IF;
EXCEPTION
WHEN NO_DATA_FOUND THEN
DBMS_OUTPUT.PUT_LINE('Invalid Column: ' || emp_column);
END raise_emp_salary;
/

DECLARE
plsql_block VARCHAR2(500);
BEGIN
--note the semi - colons(;) inside the quotes '...'
plsql_block: = 'BEGIN raise_emp_salary(:cvalue, :cname, :amt); END;';
EXECUTE IMMEDIATE plsql_block USING 110, 'DEPARTMENT_ID', 10;
EXECUTE IMMEDIATE 'BEGIN raise_emp_salary(:cvalue, :cname, :amt); END;'
USING 112, 'EMPLOYEE_ID', 10;
END;
/

DECLARE
sql_stmt VARCHAR2(200);
v_column VARCHAR2(30): = 'DEPARTMENT_ID';
dept_id NUMBER(4): = 46;
dept_name VARCHAR2(30): = 'Special Projects';
mgr_id NUMBER(6): = 200;
loc_id NUMBER(4): = 1700;
BEGIN
--note that there is no semi - colon(;) inside the quotes '...'
EXECUTE IMMEDIATE 'CREATE TABLE bonus (id NUMBER, amt NUMBER)';
sql_stmt: = 'INSERT INTO departments VALUES (:1, :2, :3, :4)';
EXECUTE IMMEDIATE sql_stmt USING dept_id, dept_name, mgr_id, loc_id;
EXECUTE IMMEDIATE 'DELETE FROM departments WHERE ' || v_column || ' = :num'
USING dept_id;
EXECUTE IMMEDIATE 'ALTER SESSION SET SQL_TRACE TRUE';
EXECUTE IMMEDIATE 'DROP TABLE bonus';
END;
/
load more v
65%

The semicolon is commonly used as parts of emoticons, in order to indicate winking or crying, as in ;) and ;_;. ,The semicolon is one of the least understood of the standard marks, and so it is probably not used by many English speakers.[4] ,The plural of semicolon in English is semicola or semicolons. ,Applications of the semicolon in English include:

int main() {
   int x, y;
   x = 1;
   y = 2;
   printf("X + Y = %d", x + y);
   return 0;
}
load more v

Other "undefined-undefined" queries related to "Why use semicolon? [duplicate]"