What I would like to receive from Delphi on xmas :)
What I would like to receive from Delphi on xmas :)
I strongly believe those features would make Delphi a better language.
I'm not a C guru, but I've used those features in small C programs I've written and found them extremely useful.
Specially, when variable can be declared anywhere - that, in my opinion, makes program much more readable as I don't need to scroll up to see what type of variable it is.
Anyway, if anything of this is implemented, I would consider that my SA money is well spent.
program delphi_xmas;
// bitfields in records. Extremely useful when dealing with interfaces to C libraries
// yes, I know they can be "implemented" in Delphi, but those implementations are not nice
type
TBitRec = record
field1: integer:2;
field2: integer:1;
end;
// variable number of parameters
procedure foo(...);
begin
// possibility to identify function/procedure being executed (taken from C)
WriteLn(Format('%s(): start', [__func__]);
// ability to declare variables anywhere
for (var i: integer := 0 to ProcParamsCount - 1) do begin
var p: Variant := ProcParams[i];
var basicType : integer := VarType(varVar) and VarTypeMask;
var typeString: string;
case basicType of
varInteger : typeString := 'varInteger';
varString : typeString := 'varString';
end;
WriteLn(Format('Parameter %d has type of %s', [i, typeString]));
end;
WriteLn(Format('%s(): end', [__func__]);
end;
begin
// ability to declare variables anywhere
var arr: array of string := ['Hello', 'World'];
var i: integer := 0;
repeat
// ++ from C
WriteLn(arr[i++]);
// Conditional Operator taken from C
WriteLn(i=0 ? 'Zero': 'Other');
until i > High(arr);
foo(1, 'a', 2, 'b', 3, 'c');
end.
I strongly believe those features would make Delphi a better language.
I'm not a C guru, but I've used those features in small C programs I've written and found them extremely useful.
Specially, when variable can be declared anywhere - that, in my opinion, makes program much more readable as I don't need to scroll up to see what type of variable it is.
Anyway, if anything of this is implemented, I would consider that my SA money is well spent.
program delphi_xmas;
// bitfields in records. Extremely useful when dealing with interfaces to C libraries
// yes, I know they can be "implemented" in Delphi, but those implementations are not nice
type
TBitRec = record
field1: integer:2;
field2: integer:1;
end;
// variable number of parameters
procedure foo(...);
begin
// possibility to identify function/procedure being executed (taken from C)
WriteLn(Format('%s(): start', [__func__]);
// ability to declare variables anywhere
for (var i: integer := 0 to ProcParamsCount - 1) do begin
var p: Variant := ProcParams[i];
var basicType : integer := VarType(varVar) and VarTypeMask;
var typeString: string;
case basicType of
varInteger : typeString := 'varInteger';
varString : typeString := 'varString';
end;
WriteLn(Format('Parameter %d has type of %s', [i, typeString]));
end;
WriteLn(Format('%s(): end', [__func__]);
end;
begin
// ability to declare variables anywhere
var arr: array of string := ['Hello', 'World'];
var i: integer := 0;
repeat
// ++ from C
WriteLn(arr[i++]);
// Conditional Operator taken from C
WriteLn(i=0 ? 'Zero': 'Other');
until i > High(arr);
foo(1, 'a', 2, 'b', 3, 'c');
end.
Comments
Post a Comment