In C# nearly everything is an object, so when writing a unit test for a string property validator it lets me do this: "".PadRight(30);

In C# nearly everything is an object, so when writing a unit test for a string property validator it lets me do this:  "".PadRight(30);
But that HURTS my Delphi brain !! Does anyone else suffer from Delphi migraines when using other languages??

Comments

  1. Do you know that you can now do " 'foo'.Length" in Delphi now? That surely won't help your migraine ;)

    ReplyDelete
  2. Actually I didn't know that.. ! I know about the string helper class but I didn't know I could do that - very cool!! But you're right my migraine is now worse :-)

    ReplyDelete
  3. You can also do "100.ToString"...

    ReplyDelete
  4. Wow that is both interesting and cool and I didn't know it existed in Delphi. So that means the Delphi simple type helpers work with any literals?

    ReplyDelete
  5. Most literals, yes. As long as the appropriate unit is used and there is a helper for that type of literal. Most everything should be covered.

    ReplyDelete
  6. Ok well as the saying goes you learn something every day. Thanks for your insights :-D

    ReplyDelete
  7. Allen Bauer Not as cool as a generic extension method in C# ;)

    ReplyDelete
  8. Stefan Glienke I agree C# extensions are way more powerful than Delphi. I wish Delphi would even allow multiple class/record helpers to be used instead of just the last one referenced.

    ReplyDelete
  9. Stefan Glienke​ agreed... But for them to really work well, Delphi would need to have better type inferencing.

    ReplyDelete
  10. any new language has a learning curve, just push forward and youll be fine, in fact, youll find some really nice things in each language that youll want to copy back to delphi

    ReplyDelete
  11. Allen Bauer Anything besides elbow grease standing in the way of that? That is, any technical reasons it's so limited?

    ReplyDelete
  12. But then C# still lacks extension properties...

    ReplyDelete
  13. Jeroen Wiert Pluimers WPF has extension properties which is pretty much that plus a bit more.

    ReplyDelete
  14. Stefan Glienke those are implemented using Attached Properties which is quite a heavy mechanism: http://www.codeproject.com/Articles/399932/Extension-Properties-Revised

    ReplyDelete
  15. Could be worse, though.  In Ruby, this is a completely legal (and idiomatic!) way to do a for loop

    5.times {|i| print i, " "}

    ReplyDelete
  16. Mason Wheeler Oh I'm *so* stealing that, let the code rewrite begin!

    type
      TRubyMania = record helper for shortint
        procedure times(const IterBody: TProc);
      end;
    { TRubyMania }
    procedure TRubyMania.times(const IterBody: TProc);
    var
      i: integer;
    begin
      for i := 0 to Self-1 do
        IterBody(i);
    end;

    begin
      5.times(
        procedure(i: integer)
        begin
          WriteLn(i);
        end
      );
    end.


    :D

    ReplyDelete

Post a Comment