What do you miss in the Delphi language? Which features ?
What do you miss in the Delphi language? Which features ?
I miss the "return" statement and good reference-counting memory management for objects (doing it through interfaces is a bit uncomfortably for me)
I miss the "return" statement and good reference-counting memory management for objects (doing it through interfaces is a bit uncomfortably for me)
Exit(5);
ReplyDeleteI miss the C-ish ? : which is very useful in some cases :-)
ReplyDeleteI miss i++ and i-- shortcuts, they are often very handy )
ReplyDelete1. String with vars in it: s := "This string contains local var with value:@localVar. Compiler expand this stuff."
ReplyDelete2. More type inferring for anonymous method: signature is known either from type of variable it assigned to or type of method arg it passed to. Remove "begin" & "end" keywords if anonymous method contains single statement.
I like the removal of begin/end for one liners
ReplyDeleteconst array of byte = (2,3,4,5);
ReplyDeleteKrom Stern I don't get the usefulness of that
ReplyDeleteFor example:
ReplyDeleteconst
Procs: array [0..1] of record
Names: string;
Typ: array of Byte;
Dir: array of TPSParameterMode;
end =
(
(Names: 'ONHOUSEDESTROYED'; Typ: (0, btS32, btS32, btEnum); Dir: (pmIn, pmIn, pmIn)),
(Names: 'ONHOUSELOST'; Typ: (0, btS32, btEnum); Dir: (pmIn, pmIn))
);
- Local variables inside begin/end bloc.
ReplyDeletevar
I : Integer;
begin
WriteLn('Start');
for I := 0 to 10 do begin
var Temp : Integer;
Temp := I + 1;
WriteLn(Temp);
end;
end;
- Local variable initialisation in their declaration
var Count : Integer = 5;
- Local variable declared ad hoc
procedure Foo;
begin
WriteLn('Start');
var Count : Integer;
Read(Count);
for var I : Integer = 0 to Count do
WriteLn(I);
end;
- Automatic counting of array element in typed constant:
const MyArray : Integer = array (1, 2, 3);
1) the "step" in "for loop"
ReplyDeletefor index := _start to/downto _end step _inc/_dec_value do
Eric added it to DWS and it's awesome
2) array slice, should be very easy to implement
type TMyByteArray = array of Byte;
TMyByteArray = slice of TMyByteArray; // the compiler takes care of the rest
TMyByteArrayLimit = slice[ 10 ] of TMyByteArray; // slice that references only 10 elements from start index
now, I should also be able to do in/decrement a "slice", if I happen to access an element out of bounds => AV
3) ability to include C and C++ headers in my project, I'm pretty sure that almost all of you had to do it at least once, well, EMB also has the CB compiler, that seems to be tightly integrated with some delphi features, this makes me think that we can have something like:
{$INCLUDE_HEADER 'my_cool_c_header.h'}
or the shorter form
{$IH 'my_cool_c_header.h'}
var SomeVar: struct_from_my_cool_c_header_t;
4) ability to define multiple record/class helpers for a type, without losing another one defined in a different unit
5) each procedure should return the reference, easily achievable
type TMyCoolClass = class...
var mcc: TMyCoolClass;
...
mcc
.DoThis
.DoThat
.AllGood;
//.Free; <- mwa-ha-ha!!
Love to have:
- since D7, the compiler is slower and slower, I'm thinking that the compiler is wasting time freeing memory rather than do it's job quickly and exit, maybe an option to say "compiler, don't free memory, compile like chuck norris on crack!"
- better warnings in compiler, there are many times when you go "wtf", the compiler(maybe added in XE3) should warn me that there are two units in uses that have a function with the same description and that I should use preferred_unit.function_name(args) explicitly
François Piette the "local" variable is a bad idea, cool for scripting languages, bad for big projects. There's a reason for the "variable declaration section".
ReplyDeletere the warning with multiple units with the same routine name: imho it should be a compiler error, meaning it should be made mandatory. A
ReplyDeleteDorin Duminica I disagree on all counts :-) I think it would make code more readable and compact. It would be great especially for prototyping. A
ReplyDeleteAndrea Raimondi if compact code is what you want, then OK.
ReplyDeleteI, for one, prefer easy to follow code, it's enough that many times we have to cut corners with the pocket knife, now, what you're saying is: replace the pocket knife with a handgun, so that when it hurts, it hurts really bad! ((:
Dorin Duminica I think that, sometimes, you just can't avoid big pieces of code. In those cases, having local var declarations would be easier and neater. When you're done, you can refactor and remove them. The bottom line is that this would allow really cool stuff like more precise refactorings. There are plenty of scenarios where this would be a good thing.
ReplyDeleteExisting language features are good enough for me.
ReplyDeleteI miss "Declared but never used" for global variables/types/classes/procedures across the project/project group :)
I miss cross-reference usage table.
I miss "Extract duplicate code" refactoring :)
I miss assembly language representation of Delphi code as option to the command-line compiler.
Andrea Raimondi agree that you can't avoid big pieces of code, but you still have to refactor -- if not done properly, surprises arise, and in 11/10 cases you'll have surprises (: anyhu', we went off topic, sorry.
ReplyDeleteI miss string for case of. Now it only work with numbers.
ReplyDeleteNo no no no no!!!!
ReplyDeleteNo Case on strings please!!!
Give me string as array indexes instead :)
Regards,
A
Thomas Mueller Exit(5); is already supported since Delphi 2009
ReplyDeleteThat's what I wanted to say with my comment: A "return statement" is already there, it's called exit. Uwe Schuster
ReplyDeleteI miss almost everyday fast property declaration , and less often a compact object querying syntax like Linq.... and a "declare variable" refactoring that works all the time ...
ReplyDeleteOlivier SCHWAB what do you mean by "fast property declaration", how would you envision it?
ReplyDeleteDorin Duminica in several languages , when you need to declare a classical property you can declare it in a single line
ReplyDeleteex in C# : property Name { get ; set ;}
or property Name { get ;}
for read only property;
OK one can say : but in delphi, it's one declaration line for property, and one for the field. Yes ! But I still prefer faster code to produce and to read.....
Type the property declaration and press Ctrl+Alt+c Olivier SCHWAB
ReplyDeleteWhat's wrong with that?
Olivier SCHWAB ah, but you can also "forget" about the "protected/private field" and declare it as "Name: string;" and voila, when you need specialized getter and setter, just update it. Anyhu', I wasn't able to wrap my head regarding the "fast declaration", thank you for making it clear.
ReplyDeleteIsn't that Shift+Ctrl+c ?
ReplyDeleteFor one, I'd like for the language to be case sensitive. Generic free functions would be nice. In general though, after 5 years coding C++, I've come to prefer most of the C++ syntax.
ReplyDeleteDaniela Osterhagen I always prefer a short syntax to handful of keyboard shortcuts ....
ReplyDeleteAsbjørn Heid Ahhh a case sensitive lover ! Can you explain why you love it ? I regulary shout after Linux for that, and for me , case sensitive languages is nonsense ; if you want to variable with same name to store different things, something is wrong, no ?
ReplyDeleteAsbjørn Heid if you where to frequently change between language syntax, it would be a different story, I get what you mean tho, if you write a lot in a language, it becomes second nature.
ReplyDeleteI wish
ReplyDeleteWith could be redefined to scope local variables
with Current: TMyType = SomeList.Param[ix],
Target: TMyType = OtherList.Item[jx]
do begin
if Current.Value = Target.Value
then ...
With could define local variables
with ix: Integer = 25
do while ix > 0
do begin
...
dec(ix);
end;
// ix is out of scope here
With could define local variables with implicit try/finally/destroy
with Obj: TMyBaseClass = TDerivativeClass.Create;
do while Obj.NotDone
do Obj.DoProcess
// Obj is out of scope and destroyed here
For loop index variables could be locally declared to ensure no reuse
for ix:Integer = 0 to Max
RTTI would move towards CTTI
I.e. the same conceptual use, but stuff like property validation via constant string literals done at run time, would be done at compile time instead. Yes, that would most likely require a two pass compiler. Alternatively, that there was a magic compiler function that emitted a property, method or type name as a string by calling %MemberName( TMyType.SomeProperty) or %QualifiedName(TMyType.SomeProperty).
Lars Fosdal I'm having trouble wrapping my head around the [with] part's value, can you elaborate on the gain?
ReplyDeleteThe first one is clarification. A With statement having multiple arguments today, leads to very obscure code. You really don't know if the calls made are to argument1, argument2, a local function, a type function or a global function.
ReplyDeleteThe other two are for limiting the scope of helper variables, eliminating accidental references to helper variables that may be stale.
basically, the compiler will add a local variable for you...
ReplyDeleteA local variable which has a limited scope, and which hopefully lends clarity.
ReplyDeletewell, [with] and I don't make a good team... (:
ReplyDeleteI also avoid the current with, unless it can be used to add clarity.
ReplyDeleteOlivier SCHWAB I prefer it when variables have the same case everywhere. I find it harder to parse when you have code like
ReplyDeletevar foo: integer; begin FOO := 42;
In addition, it allows you to get around the silly T prefixes. Never liked those. I much prefer
Array.Sort(...);
to
TArray.Sort(...);
Dorin Duminica True, however I wrote Pascal/Delphi for almost 15 years before that... so I don't think it's just that it's C++ I've worked most with recently. I really like the RAII concept for example, and I much prefer the inline variable declarations the way C++ does it.
ReplyDeleteAsbjørn Heid I'm pretty confident that it's because of getting used too, before writing any javascript, I couldn't think for a second that I would ever be able to like it, after about 1 year with it, I felt like home, basically it became second nature.
ReplyDelete(Note: this doesn't mean that I'm a js guru, not at all, but I got so used to it that enjoyed it)
Warning for unused units in uses statement.
ReplyDeleteAndrea Raimondi - The warning on multiple units with same overlapping method names would have to be optional. I use this to override f.x. OutputDebugString to add timestamp, threadid and overload it to have a string argument instead of pChar.
ReplyDeleteUnlike, Asbjørn Heid - I would like Delphi to remain case INsensitive, but I'd like hints (or autocorrects) for references that are in a different case than the declaration.
I would prefer redefining with to create local variables over François Piette's inline declarations - with one exception - the for loop.
Lars Fosdal I think it should be made mandatory simply because it's way too easy to misuse it unknowingly.
ReplyDeleteIt's a source of very difficult to find bugs and therefore I think it would be awesome to have the compiler kick and scream on it. That said, it could be an option(ON by default) called "Stop on ambigous overlapping routines" or something like that. The main problem I see with it is it should be "intelligent", i.e for example not kicking and screaming if one of the two is only defined in an implementation section as opposed to an interface one - because there's a huge difference.
Not easy to do, but would be awesome to have indeed :)
A
Asbjørn Heid THEORICALLY the code formatter should format every variable with the case it has at its declaration ...
ReplyDeleteDorin Duminica I get what you mean, but I think it's deeper than that, at least in my case. Oh well, I'm now primarily coding Delphi again, so we'll see in a year or so :)
ReplyDeleteOlivier SCHWAB Well yes, in theory ;) However I like that you can name your classes with uppercase and your variables with lowercase. It's one of the things I've never liked about Pascal, even tho it has been my first language and primary.
Marcin Banasik Have you tried Icarus from www.peganza.com ?
ReplyDeleteLars Fosdal I would like the with statement to be removed! Or at least a compiler option to generate a warning for any with statement.
ReplyDeleteIn it's current form, I agree - François Piette - I want to change it to something useful instead.
ReplyDeleteLars Fosdal , François Piette : In VB6 the With keyword has an interest because it was used by compiler for optimizations. In Delphi, I agree it just make debugging more difficult ...
ReplyDeleteOlivier SCHWAB In Delphi compiler may generate optimized code for with too.
ReplyDeleteWith statement has nothing to do with the optimization altough it is simpler for the optimizer to optimize the code with it.
ReplyDeleteMaxim Abramovich If unit has initialization, it can't be considered useless authomatically, though it's actually useless. Icarus provides more detailed information about units and it gives quite right advices to move units between interface and implemetation sections. I totally agree with you about compiler emulation, but it's better to use tools like Icarus than nothing :)
ReplyDelete