Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8705399
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T03:21:00+00:00 2026-06-13T03:21:00+00:00

I have a simple piece of code, that compiles in Delphi XE2 but not

  • 0

I have a simple piece of code, that compiles in Delphi XE2 but not in XE3, and I don’t know why. I have reduced the problematic code to a small bit and would like to know what’s wrong with it in Delphi’s opinion. Trying to compile a project containing this unit in Delphi XE 2 works fine, but in Delphi XE3 (trial), it gives “[dcc32 Error] AffineTransform.pas(26): E2382 Cannot call constructors using instance variables”. The only “eccentric” thing I know of here is the use of the old-school “object” type, where the constructor isn’t really exactly the same thing as in real objects (TObject-based class instances).

If I replace the words ‘constructor’ in this object with ‘procedure’, then it compiles ok, but why is this, and is this an ok change to do in my code, i.e. is it a change that will have no effect on the functionality?

unit AffineTransform;

interface

type
  { Rectangular area. }
  TCoordRect = object
  public
    Left, Top, Right, Bottom: Real;
    constructor CreatePos(ALeft, ATop, ARight, ABottom: Real);
    procedure   Include(AX, AY: Real);
  end;

implementation

constructor TCoordRect.CreatePos(ALeft, ATop, ARight, ABottom: Real);
begin
  Left := ALeft;
  Top := ATop;
  Right := ARight;
  Bottom := ABottom;
end;

procedure TCoordRect.Include(AX, AY: Real);
begin
  CreatePos(AX, AY, AX, AY)
end;

end.
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T03:21:01+00:00Added an answer on June 13, 2026 at 3:21 am

    For this legacy Turbo Pascal style object, there is really no meaning to the keyword constructor. Although an object constructor does have some special treatment, there’s absolutely no need for that here. What have here is nothing more than a record with some methods.

    The XE3 compiler was changed so that it no longer allows you to call a constructor on Self inside an instance method. That is the case for both class and object. I’ve not seen any documentation of why this change was made. No doubt in time it will seep out.

    Your immediate solution is to replace constructor with procedure. In the longer term, it would make sense to turn this into a record rather than an object.


    I would also council you to change the name of the method to Initialize. Some library designers seem to opt for using Create and Free methods on their records. This had led to immense amount of code being written like this:

    ctx := TRttiContext.Create;
    try
      ....
    finally
      ctx.Free;
    end;
    

    In fact all that code is spurious and can simply be removed! A TRttiContext variable will automatically initialize itself.

    That sort of design also sets a giant Heffalump Trap for that faction of Delphi coders that like to use FreeAndNil. Passing a record to FreeAndNil leads to some interesting fireworks!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a template class that's a simple vector, but this piece of code
Hello stackoverflow community, I have a rather simple piece of code that is getting
I have a simple piece of code that periodically writes data to a fd
I have a simple piece of code that outputs console text to a text
I have a simple piece of assembly code that works correctly on Mac OS
I have to write a simple piece of code that acts on a file;
I have a simple piece of code that extracts a float from a FORTRAN-generated
I have a simple piece of code that is giving me a compiler error.
I have a simple piece of code that i want to use in my
I have this simple piece of code that uses boost::bind: #include <boost/bind.hpp> #include <utility>

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.