The usual “off-line” comment: Guys, we’re preparing FileSuite 2. Many interesting things inside – many bugs fixed, folder constraints more scripting commands and, of course, Shell Events. On of the main themes of this release are the usability issues so feel free to submit your feedback. We hope that we’ll have something to present in 7-10 days. Thanks a lot.
And now back in present: There’s a question on StackOverflow asking What’s your favourite programming language, and its killer feature?
Seeing there that Delphi’s choice is #1 among the answers it seems that Delphi’s killer ‘feature’ is becoming (again) its community.
…but we must not be too confident because we have a lot of work to do in this regard (…now I’m wondering how many team members upvoted there…) but definitely it is a very good sign that we’re unite outside and have a constructive dialog inside.
On the corresponding thread in the delphi.non-technical forum, there’s (once again) a discussion about the
var block and the need of a more flexible approach (having inline variables and local loop variables).
My (humble) personal opinion is that the best thing will be a compilation of the the main trends in the nowadays programming languages:
Give the possibility to reduce the variable life while discouraging/disallowing the scattering of variables through the code.
And this can be achieved by allowing the
var block to be placed anywhere in the procedure body but its scope to be limited to the next statement only. In fact, this is the standard Pascal behavior because any procedure can be seen as a single statement (ok, a composite one, enclosed between
end ). Hence the following structures will be valid:
procedure Foo; var nTimes: integer; begin WriteLn('Enter the upper limit:'); ReadLn(nTimes); var i: integer; for I := 1 to nTimes do WriteLn(i); //'i' invalid here WriteLn('Done'); end; procedure Bar; begin //....many lines of code here var nDOW: integer; begin if GetWeekDay('Please choose the day of the week', nDOW) then case nDOW of 1: //Mon 2: //Tue //... end; end; WriteLn('Here the temporary nDOW is invalid'); //...another lines of code end;
This will allow us to have a much greater power of expression without forcing us, in order to limit the life time of the variables, to write a dozen of local procedures. And all of this without forcing us to scan the code in order to find were are the variables declared. Also, perhaps this feature can be implemented by generating under the hood a local procedure. And if this is possible, then perhaps we can write a cleaner code also in the case of the anonymous procedures:
TThread.Synchronize(myThread, procedure ShowMessage('Boo!')); //a procedure is a *single* statement
… instead of more convoluted…
TThread.Synchronize(myThread, procedure begin ShowMessage('Boo!'); end);
…oh well, one can dream… …on the road to the lambdas.
Feel free to comment and vote. (Also, don’t forget the FileSuite – the ones who’re interested)