The Wiert Corner – irregular stream of stuff

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

  • My work

  • 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,311 other followers

Archive for the ‘Delphi’ Category

Let’s stop copying C / fuzzy notepad

Posted by jpluimers on 2017/12/07

Ah, C. The best lingua franca we have… because we have no other lingua francas. Linguae franca. Surgeons general? C is fairly old — 44 years, now! — and comes from a time when there were possibly more architectures than programming languages. It works well for what it is, and what it is is a relatively simple layer of indirection atop assembly. Alas, the popularity of C has led to a number of programming languages’ taking significant cues from its design, and parts of its design are… slightly questionable. I’ve gone through some common features that probably should’ve stayed in C and my justification for saying so. The features are listed in rough order from (I hope) least to most controversial. The idea is that C fans will give up when I call it “weakly typed” and not even get to the part where I rag on braces. Wait, crap, I gave it away.

Great re-read towards the end of the year: [WayBackLet’s stop copying C / fuzzy notepad

Via: [WayBack] Old and busted: emacs vs vi. New and hot: Language war, everybody against everybody else. – Kristian Köhntopp – Google+

–jeroen

Posted in .NET, APL, Awk, bash, BASIC, C, C#, C++, COBOL, CoffeeScript, CommandLine, D, Delphi, Development, F#, Fortran, Go, Java, Java Platform, JavaScript/ECMAScript, Pascal, Perl, PHP, PowerShell, PowerShell, Python, Ruby, Scala, Scripting, Software Development, TypeScript, VB.NET, VBScript | 3 Comments »

Oh nice. Feel free to QP. E2003WithConstsInDescendingClassesConsoleProject

Posted by jpluimers on 2017/12/06

Oh nice. Feel free to QP. Fails at least in Delphi XE8.

program E2003WithConstsInDescendingClassesConsoleProject;

{$APPTYPE CONSOLE}

uses
ParentUnit in 'ParentUnit.pas',
ChildUnit in 'ChildUnit.pas';

begin
end.
unit ParentUnit;

interface

type
  TParent = class
  // section can be strict protected, protected, public, published or nothing
  const
    InitialBooleanValue = False;
    InitialIntegerValue = -1;
  end;

implementation

end.
unit ChildUnit;

interface

uses
  ParentUnit;

type
  TChild = class(TParent)
  // section can be strict protected, protected, public, published or nothing
  const
//    Initial and final values need to be different to test the behaviour
    FinalBooleanValue = not InitialBooleanValue;
    FinalIntegerValue = InitialIntegerValue + 1;
//[dcc32 Error] ChildUnit.pas(13): E2003 Undeclared identifier: 'InitialBooleanValue'
//[dcc32 Error] ChildUnit.pas(14): E2003 Undeclared identifier: 'InitialIntegerValue'
//[dcc32 Error] ChildUnit.pas(14): E2026 Constant expression expected
  end;

implementation

end.

[WayBackOh nice. Feel free to QP. unit ParentUnit; interface type TParent = class …

Posted in Delphi, Delphi XE8, Development, Software Development | 3 Comments »

Delphi tip of the day: {$WARN UNSUPPORTED_CONSTRUCT ERROR}

Posted by jpluimers on 2017/12/04

Delphi tip of the day:

{$WARN UNSUPPORTED_CONSTRUCT ERROR}

It will throw a compiler error when you use an attribute that isn’t defined as the above [WayBackturns a warning into an error as normally [WayBackUNSUPPORTED_CONSTRUCT is only a warning.

Which means that this code now fails:

type
  TmyClass = class
    [djhgfskdhgks]
    procedure One;
  end;

Thanks [WayBack] +Agustin Ortu for posting this tip!

–jeroen

via:

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

Getting rid of [dcc32 Warning] W1029 Duplicate constructor ‘ClassName.ConstructorName’ with identical parameters will be inacessible from C++

Posted by jpluimers on 2017/11/30

Note that the below solution works for any project raising the W1029 warning (not just from projects using Delphi Mocks) like

[dcc32 Warning] W1029 Duplicate constructor 'ClassName.ConstructorName' with identical parameters will be inacessible from C++

From my original text at [WayBackGet rid of W1029 warning in Delphi compile mode · Issue #106 · VSoftTechnologies/Delphi-Mocks · GitHub:

By default the compiler will emit warnings like these for projects when using either of the Delphi.Mocks.Behavior or Delphi.Mocks.Expectation directly or indirectly:

[dcc32 Warning] W1029 Duplicate constructor ‘TExpectation.CreateOnceWhen’ with identical parameters will be inacessible from C++

They’re harmless as DUnitX doesn’t support C++. This particular warning type cannot be disabled on the unit or source line level which means you have to disable it on the project level by either:

  1. adding {$WARN DUPLICATE_CTOR_DTOR OFF} anywhere to your .dpr project file
  2. modifying the the Project Options for your project (easiest is in the All configurations - All platforms target):
    1. follow the path Delphi Compiler, Hints and Warnings in the treeview on the left
    2. expand the Output warnings node in the listview on the right
    3. set Duplicate constructor/destructor with identical parameters will be inacessible from C++ to Error

A screenshot of the second option is below.

Note that the spelling mistake in Duplicate constructor/destructor with identical parameters will be inacessible from C++ is how it is in the IDE, but that as Google search string it will give limited results, so here are some back-ground references:

 

Screenshot of the Project Options

Read the rest of this entry »

Posted in Delphi, Delphi 10 Seattle, Delphi 10.1 Berlin (BigBen), Delphi 2007, Delphi 2009, Delphi 2010, Delphi XE, Delphi XE2, Delphi XE3, Delphi XE4, Delphi XE5, Delphi XE6, Delphi XE7, Delphi XE8, Development, Software Development | Leave a Comment »

Canonical Delphi Singleton Pattern – Stack Overflow

Posted by jpluimers on 2017/11/29

Though I try to refrain from using the singleton pattern when possible (I prefer dependency injection over accessing “globals” that usually tend up to be not so global after all), sometimes I need to.

In C# there has been a canonical singleton pattern implementation by John Skeet for a very long time at [WayBackC# in Depth: Implementing the Singleton Pattern.

I just found out there has been similar implementations in Delphi both in this question (which like many useful questions is marked “closed”, oh the joy of StackOverflow): [WayBack] “Delphi Singleton Pattern – Stack Overflow:

I like both implmentation, but usually take the first as mostly locking has little overhead and sometimes two instances cannot co-exist (though that’s lessened when part of the singleton uses lazy initialisation, for instance from Spring4D).

–jeroen

via: [WayBack] May I please ask for your opinion on the following code:..singleton… – John Kouraklis – Google+

Posted in Delphi, Development, Software Development | Leave a Comment »

 
%d bloggers like this: