Darian Miller 366 Posted August 10, 2021 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
Stefan Glienke 2019 Posted August 11, 2021 Here are some more: Wrong codegen: https://quality.embarcadero.com/browse/RSP-34539 Bogus error: https://quality.embarcadero.com/browse/RSP-34540 Bogus operator calls: https://quality.embarcadero.com/browse/RSP-34541 1 Share this post Link to post
dummzeuch 1517 Posted August 11, 2021 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. 1 Share this post Link to post
Rollo62 539 Posted August 12, 2021 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
David Heffernan 2353 Posted August 12, 2021 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. 1 Share this post Link to post
dummzeuch 1517 Posted August 13, 2021 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
David Heffernan 2353 Posted August 13, 2021 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. 1 Share this post Link to post
Dalija Prasnikar 1404 Posted August 13, 2021 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 3 Share this post Link to post
dummzeuch 1517 Posted August 13, 2021 (edited) 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 August 13, 2021 by dummzeuch 1 Share this post Link to post
Stefan Glienke 2019 Posted August 13, 2021 If you are a seasoned Delphi developer you know that new features are not usable for like half a decade or so... 4 3 4 Share this post Link to post
David Heffernan 2353 Posted August 13, 2021 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. 2 Share this post Link to post
Dalija Prasnikar 1404 Posted August 13, 2021 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. 6 Share this post Link to post
Lars Fosdal 1793 Posted August 16, 2021 I am still waiting for nullable types so that I can rewrite more code 😛 1 Share this post Link to post
Stefan Glienke 2019 Posted August 18, 2021 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
Der schöne Günther 316 Posted August 18, 2021 Also known as Elvis operator - Wikipedia 😉 Share this post Link to post
Lars Fosdal 1793 Posted August 18, 2021 31 minutes ago, Stefan Glienke said: You are most likely referring to the null propagation operator because there are plenty of nullable type implementations around. Yup. Share this post Link to post
Stefan Glienke 2019 Posted August 18, 2021 (edited) 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 August 18, 2021 by Stefan Glienke 1 Share this post Link to post
David Heffernan 2353 Posted August 18, 2021 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
Dalija Prasnikar 1404 Posted August 18, 2021 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
David Heffernan 2353 Posted August 18, 2021 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. 1 Share this post Link to post
Dalija Prasnikar 1404 Posted August 18, 2021 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... 1 Share this post Link to post
Fr0sT.Brutal 900 Posted August 18, 2021 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 1 Share this post Link to post
Stefan Glienke 2019 Posted August 18, 2021 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
dummzeuch 1517 Posted August 19, 2021 (edited) 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 August 19, 2021 by dummzeuch Share this post Link to post
Alexander Elagin 143 Posted August 19, 2021 (edited) 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 August 19, 2021 by Alexander Elagin Share this post Link to post