The Wiert Corner – irregular stream of stuff

Jeroen W. Pluimers on .NET, C#, Delphi, databases, and personal interests

  • My badges

  • Twitter Updates

  • My Flickr Stream

  • Pages

  • All categories

  • Enter your email address to subscribe to this blog and receive notifications of new posts by email.

    Join 1,860 other subscribers

Archive for October, 2016

Real nullable types will probably never make it to the language, but wel can still dream

Posted by jpluimers on 2016/10/06

Allen Bauer (ex Delphi R&D team) wrote the brilliant piece about a year and a half ago. We can still dream, right?

Allen Bauer, May 25, 2015

Current working theory of Nullable<T>.

Nullable<T> = record

property Value: T read FValue; default;

end;

Using the default directive to “hoist” the operators of “T“. Currently the default directive only works for array properties by “hoisting” the ‘[]‘ operator. Marking a non-array property with default will make the containing type behave as that type.

This, coupled with some intrinsic compiler knowledge of the Nullable<T> type will make Nullable<T> work without any addition of keywords or other standard functions or procedures.

Using the “default” directive on a non-array property will work for any type, except for having the null-propagation semantics.

When considering language features, I try and not only make it work for the intended purpose, but also broaden reach of any supporting feature. In the above scenario, even user-defined operators on “T” will be properly hoisted and used.

This was part of a very interesting G+discussion at Delphi’s New Feature Desired: Nullable Types and Null Propagation….

It covered topics like these:

–jeroen

Posted in Delphi, Development, Software Development | 5 Comments »

Offline Installer :: JetBrains Developer Community

Posted by jpluimers on 2016/10/06

DotPeek offline installers are available:

They are loacated on this page, as ‘Other distribution options’: http://www.jetbrains.com/decompiler/download/

–jeroen

via Offline Installer :: JetBrains Developer Community.

Posted in .NET, C#, Development, Reflection, Software Development | Leave a Comment »

In `System.SysUtils`, `class function TCardinalHelper.Parse` throws errors for valid Cardinal values

Posted by jpluimers on 2016/10/05

Oh nice System.SysUtils.TCardinalHelper.Parse:

class function TCardinalHelper.Parse(const S: string): Cardinal;
begin
  Result := StrToInt(S);
end;

Which means you get this nice EConvertError with message ''4294967295' is not a valid integer value'. with this simple test (which doesn’t even reach the Assert):

uses
  System.SysUtils;

procedure Cardinal_Parse_High_Cardinal_Succeeds();
var
  Expected: Cardinal;
  Value: string;
  Actual: Cardinal;
begin
  Expected := High(Cardinal);
  Value := Expected.ToString();
  Actual := Cardinal.Parse(Value);
  Assert(Expected = Actual);
end;

So I write some unit tests (see below) of which helpers for these types fail in one way or the other:

  • Cardinal
  • NativeUInt
  • Single
  • Double
  • Extended

These work for the boundary cases:

  • SmallInt
  • ShortInt
  • Integer
  • Int64
  • NativeInt
  • Byte
  • Word
  • UInt64
  • Boolean
  • ByteBool
  • WordBool
  • LongBool

 

–jeroen

via: Oh nice, in System.SysUtils: “` class function TCardinalHelper.Parse(const…

Read the rest of this entry »

Posted in Delphi, Delphi 10 Seattle, Delphi 10.1 Berlin (BigBen), Delphi XE4, Delphi XE5, Delphi XE6, Delphi XE7, Delphi XE8, Development, Software Development | 5 Comments »

Happy 25th birthday Linux!

Posted by jpluimers on 2016/10/05

Linux turns 25 today: Linux – Wikipedia, the free encyclopedia

Happy birthday!

–jeroen

Posted in *nix, Linux, Power User | Leave a Comment »

TMemIniFile have non-virtual SetStrings procedure. To add support processing of…

Posted by jpluimers on 2016/10/05

TMemIniFile have non-virtual SetStrings procedure.

One of the classic Delphi RTL examples of Delphi team members  not reading Delphi Component Design by +Danny Thorpe 

You can still get it for a few dollars, used: http://www.amazon.com/Delphi-Component-Design-Danny-Thorpe/dp/0201461366

–jeroen

via: TMemIniFile have non-virtual SetStrings procedure. To add support processing of….

Posted in Delphi, Development, Software Development | 1 Comment »

Delphi XE8 [dcc32 Fatal Error] dcc32_F2084_C2359.dpr(30): F2084 Internal Error: C2359

Posted by jpluimers on 2016/10/05

Fails in Delphi XE8 with a nice [dcc32 Fatal Error] dcc32_F2084_C2359.dpr(27): F2084 Internal Error: C2359

It is fixed in Delphi 10.0 Berlin, but of course a C2359 search does not reveal that as Quality Portal is behind a wall. So for future reference the bug: [RSP-13471] Int64 for loops can generate Internal Compiler Error – Embarcadero Technologies. Thanks +Stefan Glienke for mentioning the issue.

program dcc32_F2084_C2359;

type
  TNumber = Int64; // UInt64; // fails too; other numeric types do not fail. Fails in a unit as well.
  TNumbers = TArray;
  TNumberRange = record
  strict private
    function GetLowerBound: TNumber;
  public
    function Numbers: TNumbers;
    property LowerBound: TNumber read GetLowerBound;
  end;

{ TNumberRange }

function TNumberRange.GetLowerBound: TNumber;
begin
  Result := Default(TNumber);
end;

function TNumberRange.Numbers: TNumbers;
var
  lValue: TNumber;
begin
  for lValue := LowerBound to LowerBound do
  ;
end;

begin
end.

–jeroen

Read the rest of this entry »

Posted in Delphi, Delphi XE8, Development, F2084, Software Development | 1 Comment »

If you thought you could do multi-threading, then play “The Deadlock Empire” games

Posted by jpluimers on 2016/10/04

Slay dragons, learn concurrency! Play the cunning Scheduler, exploit flawed programs and defeat the armies of the Parallel Wizard.

Source: The Deadlock Empire

Via: Face the dragon. Learn the ropes of concurrent programming. – Lars Fosdal – Google+

Source code is available and focuses on C#; maybe one day I’ll make a Delphi version: deadlockempire/deadlockempire.github.io: The Deadlock Empire: Slay dragons, learn concurrency!

BTW: a great book (with nice illustrations at both github and kernel.org) is Source: Is Parallel Programming Hard, And, If So, What Can You Do About It? [WayBack]

–jeroen

Posted in .NET, C#, Delphi, Development, Multi-Threading / Concurrency, Software Development | Leave a Comment »

Encoding is hard… so how did the single quote become a circumflexed a followed by Euro sign and trade mark?

Posted by jpluimers on 2016/10/04

A while ago (in fact more than a year), I posted Encoding is hard…  go G+ with the below picture.

[Wayback] ftfy (“fixes text for you”, a parody on “fixed that for you”) [Wayback] fixes it, but:

How did the single quote become “’“?

Actually, because of a a common “beautification” of many Office suites (Microsoft and Open alike), the single quote was a special one: a Unicode Character ‘RIGHT SINGLE QUOTATION MARK’ (U+2019) which in UTF-8 is encoded as 0xE2 0x80 0x99.

Read the rest of this entry »

Posted in Development, Encoding, ftfy, ISO-8859, ISO8859, Mojibake, Software Development, Unicode, UTF-8, UTF8, Windows-1252 | Leave a Comment »

Fun deciphering thermometers

Posted by jpluimers on 2016/10/03

From a while ago: a Norwegian (left) and German (right) thermometer. In dialect. Because.

Anyone having more of these in other dialects?

Sources:

Read the rest of this entry »

Posted in Fun, LifeHacker, Power User | Leave a Comment »

Viewing an USB camera on Mac OS X without mirroring

Posted by jpluimers on 2016/10/03

Even though Photo Booth has an “Auto Flip New Items” option, but that only works for stills, not videos.

I needed it to see without mirroring the images from a DBPOWER 2 Million Pixels Cmos 7M/23FT USB Waterproof HD 6-led Borescope Endoscope Inspection Tube Visual Camera.

What does work are these:

I forget how I bumped into QCamera, but later I found out he posted on apple.stackexchange.com.

–jeroen

Posted in Uncategorized | Leave a Comment »