Why does the Delphi compiler resolve the comma after the last parameter in a method call?

Say I had a function like

procedure TMyObject.DoSomething(text: string); begin // do something important with the text end; 

When I call a method this way

 DoSomething('some text', ); 

the code editor displays red squiggly with a comma after the last parameter, as I expected. The compiler, however, accepts this code, and everything works as if the comma were not there.

Why does this look like legal syntax? Is there some historical reason that is still supported today (I tried it in Delphi 2006 and others seem to have experienced it in 2007 too)?

+4
source share
1 answer

These codes lead to a compilation error (E2034 Too many actual parameters) in Delphi 6, 2010 and XE2. I assume this is a compiler error in your version, as this is not legal syntax.

+6
source

Source: https://habr.com/ru/post/1390686/


All Articles