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 6924249
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T10:38:21+00:00 2026-05-27T10:38:21+00:00

I need to know, first and foremost, if what I’m trying to do is

  • 0

I need to know, first and foremost, if what I’m trying to do is even possible. If it is possible, I then need to know how.

It’s far easier to demonstrate the problem rather than explain it so here goes:

I have an “Enhanced Record” (the purpose – though not important to this question – is to produce a “Smart String” type, to replace the normal String type):

TLKString = record
  Value: String;
  // Some methods here to operate on and build String values

  // Allows me to assign String values directly to "instances" 
  // of this record type! I have others (hence "overload") to 
  // handle other data types (such as Integer etc.)
  class operator Implicit(const AValue: String): TLKString; overload; 
end;

I can now use this TLKString type as follows:

var
  LSmartString: TLKString;
begin
  LSmartString := 'Hello World'; // The "Implicit" operator then 
                                 // assigns this to LSmartString.Value
end;

Okay, so far everything is great! Now we get to the problem…

I need to be able to assign the value of LSmartString (an “instance” of TLKString) to a normal String variable…

var
  LSmartString: TLKString;
  LNormalString: String;
begin
  LSmartString := 'Hello World';

  // The next line works fine, but is not what I want!
  LNormalString := LSmartString.Value; 
  LNormalString := LSmartString; // E2010 (Incompatible Types)
end;

This is where I come unstuck, as (I’m sure you’ll notice), the last line of the above snip results in E2010 Incompatible types: ‘string’ and ‘TLKString’. I, of course, knew this would be the case… what I don’t know if it’s possible to overcome by overloading an operator on my TLKString record type, and if so, what operator I need to overload to do it.

If this isn’t possible, then it strikes me as a little silly of CodeGear and Embarcadero to have Implicit and Explicit operators to handle assignment of values to an enhanced Record type, but no operator to handle the inverse.

  • 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-05-27T10:38:22+00:00Added an answer on May 27, 2026 at 10:38 am

    Okay, I’ve answered this myself… and it was what I would call “blindingly obvious”.

    Here’s the solution (for the benefit of others)

    TLKString = record
      Value: String;
      // Some methods here to operate on and build String values
      class operator Implicit(const AValue: String): TLKString; overload; // handles String to TLKString assignment
      class operator Implicit(const AValue: TLKString): String; overload; // handles TLKString to String assignment! THIS IS THE ANSWER!
    end;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to know is it possible to reserve or lock money with First
I know that I need to tell my UITextField to resign first responder when
First and foremost. I'm totally new to programming in Excel. I'm trying to make
I need to know how to get the first n words from text stored
I need to know the first day-of-week in a given time period. The day
First and foremost let me state that I know that accessing server side controls
I've got a collection of strings, and I need to know the first index
I'have the next array: [null,null,null,null,null,null,2,10,29,43,45,40,54,39,13,1,null,null,null,null,null] I need to know what is the first position
I have a question. I need to know, if it is possible to insert
First, you'll need to know the context. Browser: Chrome HTML: <ul> <li> <div>Hi!</div> </li>

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.