Delphi Prism new language features

Friday, November 21st, 2008 | Dennis D. Spreen | Delphi Prism, Delphi Programming

Andreano Lanusse wrote about the new Delphi Prism language features compared to Delphi Win32.

Some of them I really would like to see in Delphi Win32 and some I don’t like and disallowed it in our internal code creation rules. The most important I dislike is

“Variable everywhere and create a instance at the same time you declare.”

Looks awkful to me (like VB). This is the code written by our long term code creation rules:

I like the separation from var declaration and code.

Tags: , , , , ,

4 Comments to Delphi Prism new language features

Martin Diehl
November 24, 2008

Yes, variable everywhere and create an instance at the same time you declare is really something I dislike too.
It mess up the code in a awfully way.

Sebastian P.R. Gingter
November 24, 2008

I disagree in some degree 😉
Of course it’s very clean to have everytging you work on declared in front.

But if you need some variables for loops (like the allmighty ‘for i := 0 to…’), or only in scope of a loop, then it’s a lot cleaner to not declare it oustide of that scope.

Being able to access a variable that was valid in a loop and might or might not be available for access later is generally a bad idea. Declaring a variable that is used only in a loop directly in that loop makes the code cleaner and more maintainable.

November 24, 2008

If you need variables for loops, maybe try to avoid them using the “for each” construct…

The Prism feature with the for loop variables:

var x := -1;
var list := new List([1, 2, 3]);

for x in list do




At the end, x will still be -1, because it is a different variable than the x inside the loop.

(Taken from the prism wiki)

Is this good readable code? I don’t think so. You’ll use the “x” variable but inside the “for” loop it’s a different “x” – same name, different behavior/content? The only thing I see is to use special variables only intended for use within for loops (like I,J,K,L) – which we do anyway.

Or why not using special prefixes (like in PHP, Perl, etc.) for those cases?

for $x in list do

November 24, 2008

btw, what about nested for loops? Does this work with prism?

for i: Integer := 0 to 10 do
for i: Integer := 0 to 20 do

Leave a comment

About Dennis D. Spreen

I'm an avid programmer working on a variety of platforms in a variety of languages with a wide technical interest.


QR Code