Delphi analog to C# ?? null-coalescing operator and Light Table like debugger evaluation
Posted by jpluimers on 2017/09/05
Interesting stuff:
- https://gist.github.com/lynatan/673e574faa8343fa01d7a91e75065c54 OpOverloadWithGenerics.pas which is very similar to the C# ?? null coalescing operator [WayBack]
- DLight in-line debugger evaluation which is very similar to parts from the Light Table IDE concept [WayBack] which reminds me and others of the smalltalk days [WayBack] (https://github.com/lynatan/DLight)
- RSS feed: http://feedly.com/i/subscription/feed/http://d.hatena.ne.jp/tales/rss
- Github: https://github.com/lynatan
- Gists: https://gist.github.com/lynatan
via:
- Hatena Tales 2016-10-15 [WayBack] – DLight
- Hatena Tales 2016-09-13 [WayBack] – OpOverloadWithGenerics.pas
- Wow! Very cool! An IDE Expert that displays values of watch expressions when debugging, right inside your code editor, and it’s live! – Edwin Yip – Google+ [WayBack]
- lynatan/May-the-bevel-be-with-you: Set BevelOuter property to bvLowered in compiler progress window panels.
- Restore bevels back in compiler progress dialoghttps://github.com/lynatan/May-the-bevel-be-with-you – David Berneda – Google+ [WayBack]
In more detail:
Source: 2016-10-15 – Zenryokuwawa
And:
type TObjectHelper = class helper for TObject public class function &&op_LogicalOr(A, B: T): T; static; end; class function TObjectHelper.&&op_LogicalOr(A, B: T): T; begin if A <> nil then Result := A else Result := B; end; procedure Test; var sl1, sl2, sl3: TStringList; begin sl1 := nil; sl2 := TStringList.Create; sl3 := sl1 or sl2; // -> sl3 = sl2 end;
–jeroen
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type | |
TObjectHelper = class helper for TObject | |
public | |
class function &&op_LogicalOr<T: class>(A, B: T): T; static; | |
end; | |
class function TObjectHelper.&&op_LogicalOr<T>(A, B: T): T; | |
begin | |
if A <> nil then | |
Result := A | |
else | |
Result := B; | |
end; | |
procedure Test; | |
var | |
sl1, sl2, sl3: TStringList; | |
begin | |
sl1 := nil; | |
sl2 := TStringList.Create; | |
sl3 := sl1 or sl2; // -> sl3 = sl2 | |
end; |
rvelthuis said
The TObjectHelper thing is amazing. It also works on classes, and I already managed to do addition, or to write a helper that gives TStrings an
in
operator. It is simply a cool find.jpluimers said
It’s indeed one of the language additions I like a lot.
sglienke said
It’s a feature by accident – I hope they will add it as an official feature. Some operators are harmless to introduce for classes also on non ARC. Also introducing operator overloads per helper is a good thing and should be supported officially rather than having to use some compiler glitch.