Recent

Author Topic: Feature request: writeln(ClassInstance)  (Read 1506 times)

n7800

  • Hero Member
  • *****
  • Posts: 553
  • Lazarus IDE contributor
    • GitLab profile
Re: Feature request: writeln(ClassInstance)
« Reply #15 on: October 10, 2025, 02:56:35 am »
Just use ClassInstance.ToString and it will be clear even much later what you intended. And advantage: it works right now.

I agree, it's more visual. This is immediately apparent when reading the code, without running or debugging. And you don't need to know about any operator overrides, virtual function overloads, or anything else...

I was just thinking that it would be great if I could just use ...

I once had many similar ideas for the language, but working with other people's code (and my own old code), I realized that clarity is also very important. At least in this topic, the gain is very small.

JdeHaan

  • Full Member
  • ***
  • Posts: 170
(Solved) Feature request: writeln(ClassInstance)
« Reply #16 on: October 10, 2025, 07:36:38 am »
Thanks all, for the feedbacks and the discussion!
I'll stick to calling toString explicitly.

Thaddy

  • Hero Member
  • *****
  • Posts: 18330
  • Here stood a man who saw the Elbe and jumped it.
Re: Feature request: writeln(ClassInstance)
« Reply #17 on: October 10, 2025, 08:24:39 am »
Yes, the way (one way) to do what you  want is too much involved, although possible. And I made a contrived example what needs to be done "under the hood" of the compiler. Contrived, not for use.
I hope you understand such a "feature" really needs a lot of effort inside the compiler and would completely destroy size and efficiency.
« Last Edit: October 10, 2025, 08:27:13 am by Thaddy »
Due to censorship, I changed this to "Nelly the Elephant". Keeps the message clear.

bytebites

  • Hero Member
  • *****
  • Posts: 756
Re: Feature request: writeln(ClassInstance)
« Reply #18 on: October 25, 2025, 09:52:38 am »
Writeln(classinstance) takes ~20 lines code and it took indeed a lot of effort.

 

TinyPortal © 2005-2018