Blog post "What's New in Delphi XE8 for VCL developers" at http://blog.marcocantu.com/blog/2015-april-new-xe8-vcl-developers.html

Blog post "What's New in Delphi XE8 for VCL developers" at http://blog.marcocantu.com/blog/2015-april-new-xe8-vcl-developers.html
http://blog.marcocantu.com/blog/2015-april-new-xe8-vcl-developers.html

Comments

  1. A multiplatform socket unit is realy a good thing, I've made my own in an other way...instead of $IFDEF every call, I've redefinded only the APIs in a CrossAPI.Socket unit.

    this 
      function sendto(s: TSocket; const buf; len, flags: Cardinal; const [Ref] toaddr: TSockAddr; tolen: Cardinal): Integer; {$IFDEF MSWINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}

    instead of this
    {$IFDEF MSWINDOWS}
      Result := sendto(Socket, Buf, Count, Flags,@ToAddr.FEndPoint, ToLen);
    {$ENDIF}
    {$IFDEF POSIX}
      Result := sendto(Socket, Buf, Count, Flags, sockaddr(ToAddr.FEndpoint), ToLen);
    {$ENDIF}

    or this
      TSocket = Integer;

    instead of this
    {$IFDEF MSWINDOWS}
      TSocketHandle = Winapi.WinSock2.TSocket;
    {$ENDIF}
    {$IFDEF POSIX}
      TSocketHandle = Integer;
    {$ENDIF}

    Anyway a standard unit is welcome

    Now seriously, perhaps you remember what I think about removing AnsiChar from Delphi, but what the hell is that TStaticDynArray; used ONLY by gethostname ? 100 lines of code for a single API call ?

    and to be clear, I really like Delphi, that's why I'm exigent ;)

    ReplyDelete
  2. Paul TOTH No comment...
    TStaticDynArray;

    ReplyDelete
  3. No code analysis for C++? Project Time statistics pie chart needs a key ?

    ReplyDelete
  4. Dalija Prasnikar Have you seen the rest of it? TStaticDynArray is yet another custom AnsiString implementation, only this time making assumptions about the implementation details of dynamic arrays. I do find it quite bizarre - it's not like the person(s) who make the compiler decisions have to look far for Delphi developers wedded to the utility of AnsiString and AnsiChar, since the people who work on new RTL functionality are clearly amongst them...

    { code used - cut nearly 100 lines of TStaticDynArray's declaration and implementation }
    function TSocket.GetLocalHost: string;
    var
      LocalName: TStaticDynArray;
    begin
      Result := '';
      if FSocket = InvalidSocket then Exit;
      LocalName.Init(256);
      if gethostname(LocalName, LocalName.Length) = 0 then
        Result := TEncoding.Default.GetString(LocalName, 0, LocalName.IndexOfNull);
    end;

    { 'old gen' equivalent, which is slightly shorter even ignoring the fact a built-in type is used }
    function TSocket.GetLocalHost: string;
    var
      LocalName: array[0..255] of AnsiChar;
    begin
      Result := '';
      if FSocket = InvalidSocket then Exit;
      if gethostname(LocalName, Length(LocalName)) = 0 then
        Result := string(LocalName);
    end;

    ReplyDelete
  5. Chris Rolliston No, I haven't seen it. I didn't have opportunity to try XE8.

    ReplyDelete
  6. Dalija Prasnikar and of course it's a private declaration that no own else can use...but should we ?

    ReplyDelete
  7. Paul TOTH Chris Rolliston Inevitably everyone will be rolling their own incompatible variations of 8-bit string functionality.

    Even if they want to stick to the notion that removing 8-bit strings was good design choice, they also have top voted QC report requesting their return.

    They can use that as excuse to bring 8-bit strings to the mobile without need to blame anyone from the team for making "bad" choice. I don't care if anyone will call me bad developer because I am sticking with 8-bit strings, just give them to me and let's be done with it.

    ReplyDelete
  8. Dalija Prasnikar  I'd call you a good developer if you used 8 bit string that were UTF-8 encoded.

    ReplyDelete
  9. David Heffernan That is what I do. My library and most of the code (non-GUI) is based on UTF8String type.

    ReplyDelete
  10. TStaticDynArray

    And God killed a bunch of kittens. This is turning oh-so-wrong is oh-so-many ways...

    ReplyDelete
  11. Dalija Prasnikar  UTF8String is not a "safe" string type in Unicode Delphi btw, using it is the #1 surefire way to end up with non-UTF8 content in an utf-8 string.

    ReplyDelete
  12. Eric Grange I know it is not safe. You have to take care of data you feed to it, and how you process it. I have been using it in my code since Delphi 7 and it was definitively not safe back then. 

    I could easily use RawByteString instead, but I prefer UTF8String because it clearly describes that data it holds is (should be) UTF8 encoded.

    ReplyDelete

Post a Comment