Sooner or later someone will ask here, if we could make Pascal become "cAseSenSensiTIVE".
Quote from: Martin_fr on January 08, 2016, 02:12:45 pm2) "reserving" the identifier.Short answer: no big deal - the error will be at compile time.
2) "reserving" the identifier.
Quote from: Martin_fr on January 08, 2016, 02:12:45 pmCode: Pascal [Select] for a := 0 to 9 do write(a); for a := false to true do write(a);confusing, since "a" in the same procedure is at some time int, and then bool.Confusion is in the eye of the beholder. To be sure an Ada programmer is used to this notion and would not worry about it.
Code: Pascal [Select] for a := 0 to 9 do write(a); for a := false to true do write(a);confusing, since "a" in the same procedure is at some time int, and then bool.
Quote from: Martin_fr on January 08, 2016, 02:12:45 pm4)Code: Pascal [Select]for NameOfAGlobalVar :=Hides a global var.That's very true. OTOH, the usual variable names for such are quite short (i, j, k, m, n, p, q) and usually used over a short number of lines of code.Further, the use of simple loop control variables in a procedure should (generally) not use globally declared variable names; in turn global variable names should (generally) not be simple and undescriptive as simple loop variables typically (i,j, ..) are. Yes, that 's style to an extent.
4)Code: Pascal [Select]for NameOfAGlobalVar :=Hides a global var.
Quote from: Martin_fr on January 08, 2016, 02:12:45 pm5) There is no optional. Bwahahahahaahahahahahahah!!!!!
5) There is no optional.
"an Ada programmer is used", but what about pascal programmers?fpc is pascal, not Ada.
To be fair: Every feature brings good and bad. The only question is, if the good outweighs the bad. Saving one line in the declaration to me does not any good, so it does not outweigh the problems.If you are worried about reading the one line in declaration, use code folding.You could provide a patch to hide (entirely fold, no visible line left) "{$region}". And have it fold/hide on load. Then put anything you dislike seeing into such region.
well agree to disagree.You (appear) to believe, that optional exists for such a feature.I disagree. Based on my experience, optional does not exist (yes I am serious, no laughter this time please).
If (for argument sake) optional does not exist, then the above will cause harm (to some people).This is not about how you would use it, you would not be the only one using it.
Besides what are the benefits?- less typing (IIRC that was dismissed / should be taken care of, by codetool)
- less code to read (apparently not, since hiding/folding is dismissed as solution
That leaves automatically follow the type of the bounds if they change.Using a smaller (word instead of int) type for optimization? I am not sure that really will optimize a lot (maybe on embedded), well and 2 bytes on the stack, if it is not in a register.Besides, a variable that is declared as int, can be optimized the same way, if the compiler can detect that it never holds values that do not fit into word (and is not accessed via pointer or similar)In any case the rules for the optimization are the same in both cases.
So what are the benefits then?Maybe that the loop originally written for integer, can still compile if the bounds change to some enum? How likely is that? Both bounds would need to change in the same way. And if they do, any operation (compare, add, use as index,...) on the loop var, done in the loop must be supported on the new type. IMHO rather unlikely.What did I miss, what is the benefit?
--------------the "looser" comment was clearly marked as a joke. I never indented to make any statement with this.
At this point I don't even know what you're on about. You seem to be throwing objections for that sake alone.
Quote from: Martin_fr on January 09, 2016, 03:55:07 pmThis is not about how you would use it, you would not be the only one using it.at how it would be implemented would really find all that much issue.
This is not about how you would use it, you would not be the only one using it.
Quote from: Martin_fr on January 09, 2016, 03:55:07 pm- less typing (IIRC that was dismissed / should be taken care of, by codetool)a- you might dismiss it, I don't
- less typing (IIRC that was dismissed / should be taken care of, by codetool)
Quote from: Martin_fr on January 09, 2016, 03:55:07 pm- less code to read (apparently not, since hiding/folding is dismissed as solutionNot so much that it is "less code to read" as it is "less clutter in the VAR list"
Quote from: Martin_fr on January 09, 2016, 03:55:07 pmThat leaves automatically follow the type of the bounds if they change.Using a smaller (word instead of int) type for optimization? ...In any case the rules for the optimization are the same in both cases.So, no real issue given sober constraints. If the range is variable, then the variable define the range. ...
That leaves automatically follow the type of the bounds if they change.Using a smaller (word instead of int) type for optimization? ...In any case the rules for the optimization are the same in both cases.
You didn't miss making the simple into complex, that is for sure.
I dont understand. You still havent explained what the benefit is (well: less typing, is now on).
Code: Pascal [Select]{$region 'loop vars' /hide}var i: integer;{$endregion}
There are a lot of small benefits (like those you listed). They add up
You still see that, when you commit the files.And now you have 4 lines for what used to be one. This is way worse.
Also CodeTools do not remove the declaration, when you remove the loop. Then you have to search through the entire file to remove old loop vars to fix pointless hints
Code: Pascal [Select]procedure Test; procedure ShowA; begin writeln(a); end;begin for a:=0 to 10 do ShowA;end;�Is this a valid code?
And of course this should not be valid either:Code: Pascal [Select]procedure Test;begin for a:=0 to 10 do begin procedure ShowA; begin writeln(a); end; end; ShowA;end; but this one again would:Code: Pascal [Select]procedure Test;var p: TProcedure;begin for a:=0 to 10 do begin p := ( procedure ShowA; begin writeln(a); end) end; p();end; and print 10 and nothing elsewhile this should print 0 to 10 :Code: Pascal [Select]procedure Test;var p: array[0..10] of TProcedure;begin for a:=0 to 10 do begin p[a] := ( procedure ShowA; begin writeln(a); end) end; for q in p do q();end; Is this not awesome?