Forum > Suggestions

Not allow “do;“

<< < (4/4)

Kraig:
Interesting, thanks I’ll look

Kays:

--- Quote from: Kraig on September 01, 2023, 05:25:13 pm ---I just spent a lot of time […] I’d like to suggest that putting a semicolon after do should generate a compile error […]
--- End quote ---
Yeah, PEBCAK. There are many code samples that may have limited usefulness, but are allowed and syntactically correct, examples:
--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---;;;;;;;;;;;;;;;;       { extraneous empty statements }++-+-+---+-+----+-+-42 { superfluous unary operators }@myPointerVariable^    { instead of _just_ `myPointerVariable` }Still I disapprove emission of warnings in such cases: It adds complexity to the compiler at minimal benefit. On top of that it’s difficult to formally codify the threshold that something deserves a warning.

Martin_fr:

--- Quote from: Kays on September 03, 2023, 09:42:14 pm ---There are many code samples that may have limited usefulness, but are allowed and syntactically correct, examples:
--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---;;;;;;;;;;;;;;;;       { extraneous empty statements }++-+-+---+-+----+-+-42 { superfluous unary operators }
--- End quote ---

And that means that this is valid code:

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---while ++i < c do ;
;) ;)

Navigation

[0] Message Index

[*] Previous page

Go to full version