Jump to content
Darian Miller

10.4.1+ Custom Managed Records usable?

Recommended Posts

If you are using 10.4.1 or 10.4.2 are you migrating code to utilize custom managed records or are there some blockers preventing common usage?  I know the initial release with 10.4 had some major issues with their usage but 10.4.1 had addressed a number of errors.

 

After some searching on the Quality Portal, this related issue is still open:

https://quality.embarcadero.com/browse/RSP-34165  Managed records are sometimes not initialized to 0

 

 

 

Share this post


Link to post
16 hours ago, Darian Miller said:

If you are using 10.4.1 or 10.4.2 are you migrating code to utilize custom managed records ?

Why should I? Existing code just works as it is and unless there is a good reason to change it, I won't touch it.

  • Like 1

Share this post


Link to post

I would consider that only for where it may have a reasonable purpose.

A SmartPointer like record would make sense, from my point of view.

Or record as SmartGuard for system resources, to ensure try/finally encapsulation.

 

Of course anything after careful testing under various situations.

I haven't checked all that QC entries, but I assume there should be no random-like errors popping up.

 

Share this post


Link to post
On 8/11/2021 at 12:34 PM, dummzeuch said:

Why should I? Existing code just works as it is and unless there is a good reason to change it, I won't touch it.

You'd use this functionality to be able to write more concise and cleaner code, in situations where it provided benefit.

 

So the answer to "why should I?" is when there are good reasons to. 

  • Like 1

Share this post


Link to post
11 hours ago, David Heffernan said:

You'd use this functionality to be able to write more concise and cleaner code, in situations where it provided benefit.

Exactly. Changing working code just because it can now be written differently, is not a good reason in itself.

 

I wouldn't refactor code only to now use inline variable declarations either. But if I have to refactor it for other reasons, I might consider it (same for custom managed records, but I'm not yet sure I trust the implementation).

Share this post


Link to post
12 minutes ago, dummzeuch said:

Changing working code just because it can now be written differently, is not a good reason in itself.

Nobody is suggesting that. The question is for people that are wanting to use the new feature to take advantage of its benefits. 

  • Like 1

Share this post


Link to post
4 minutes ago, David Heffernan said:

Nobody is suggesting that. The question is for people that are wanting to use the new feature to take advantage of its benefits. 

I have seen plenty of developers (not only Delphi) jumping on new features and rewriting code for no good reason. It never hurts explicitly stating even the obvious things :classic_biggrin:

  • Like 3

Share this post


Link to post
1 hour ago, David Heffernan said:

Nobody is suggesting that. The question is for people that are wanting to use the new feature to take advantage of its benefits. 

Actually that was how I understood the original question:

On 8/10/2021 at 8:55 PM, Darian Miller said:

are you migrating code to utilize custom managed records

But maybe I was wrong, happened before.

Edited by dummzeuch
  • Sad 1

Share this post


Link to post

If you are a seasoned Delphi developer you know that new features are not usable for like half a decade or so...

  • Like 4
  • Haha 3
  • Sad 4

Share this post


Link to post
35 minutes ago, dummzeuch said:

Actually that was how I understood the original question:

OK, I see where you are coming from. I just assumed that implicit in the Q was that any migration was done for the right reasons, rather than for its own sake. 

  • Like 2

Share this post


Link to post
1 hour ago, Stefan Glienke said:

If you are a seasoned Delphi developer you know that new features are not usable for like half a decade or so...

I always had high hopes that by 10.7 everything will work as intended. Now we will have to wait until Delphi 17.

  • Haha 6

Share this post


Link to post
On 8/16/2021 at 4:10 PM, Lars Fosdal said:

I am still waiting for nullable types so that I can rewrite more code 😛

You are most likely referring to the null propagation operator because there are plenty of nullable type implementations around.

Share this post


Link to post
8 hours ago, Der schöne Günther said:

Also known as Elvis operator - Wikipedia 😉

Not quite - this is the null coalescing operator ?: is a special version of the conditional operator - it is short for "if <expr> is not null then give <expr> else give <something_else>"

Null propagation operator ?. is a special member access operator - short for "if <expr> is not null then access <expr>.<some_member> else do nothing or return null"

 

Given that Delphi does not have a conditional operator I would assume that even though we might get language support for nullable types (reference types fall into that category) we don't get the null coalescing operator but chances are that we get a null propagation operator - but that is just me assuming things.

Edited by Stefan Glienke
  • Like 1

Share this post


Link to post

We should stop referring to the conditional operator as "the" ternary operator. A ternary operator is one with three operands. Just as a binary operator is one with two operands.

Share this post


Link to post
30 minutes ago, David Heffernan said:

We should stop referring to the conditional operator as "the" ternary operator. A ternary operator is one with three operands. Just as a binary operator is one with two operands.

I think it is called ternary because there are three expressions in play.

Share this post


Link to post
1 minute ago, Dalija Prasnikar said:

I think it is called ternary because there are three expressions in play.

Correct. But there are many possible ternary operators. It's the conditional operator, which is an example of a ternary operator. 

  • Like 1

Share this post


Link to post
15 minutes ago, David Heffernan said:

Correct. But there are many possible ternary operators. It's the conditional operator, which is an example of a ternary operator. 

Right... I completely misinterpreted what you were saying. I guess it is "I am reading words, but their meaning is not arriving in my brain" day...

  • Like 1

Share this post


Link to post
1 hour ago, David Heffernan said:

We should stop referring to the conditional operator as "the" ternary operator. A ternary operator is one with three operands. Just as a binary operator is one with two operands.

Of course you're right but this naming is too common because conditional seems to be the only existing ternary operator 🙂 at least I don't know any others

  • Like 1

Share this post


Link to post
6 hours ago, David Heffernan said:

We should stop referring to the conditional operator as "the" ternary operator. A ternary operator is one with three operands. Just as a binary operator is one with two operands.

I don't know what you mean 😇

Share this post


Link to post
12 hours ago, Stefan Glienke said:

I don't know what you mean 😇

a := muldiv(b,c,d);

Of course, this is a function, not a ternary operator, but ...

a := b * c  div d;

... is not really *one* operator tut two, but neither is ...

a = b?c:d;

... so does it qualify?

Edited by dummzeuch

Share this post


Link to post

It is probably a semantic question. A ternary operator, by definition, is any operator that takes three arguments. The conditional operator ?: is just one of the set of such possible operators. It is easy to imagine, say, operator AAAND which takes three logical arguments and produces TRUE only if all of them are true, but the usefullness of such operator is not high. As for the textual representation of a ternary operator, it is a problem. While a binary operator naturally is placed between its arguments, it is worse in case of the ?: operator which in fact is written as two lexems divided by one of arguments. Were it written as a = ?: b, c, d it would be more strict. Maybe. Or maybe not.

Edited by Alexander Elagin

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×