These are asynchronous functions (like TTask, but returning a value) … that can be composed into further work to be performed, using that thread, without paying the cost of winding up a thread only to launch a new one to do the next step of the process.
These are Promises - the fetch() call returns a promise.
I tried to implement something like this in Delphi, but the lack of Lambdas (arrow functions in JS) just made everything too verbose. The closest I got to this is my VSoft.Awaitable library (which is a wrapper over OmniThreadLibrary).
Do you know how many complex language features embarcadero have implemented in the last 10 years? The last ones were in 10.3 Rio.
I have advocated for language enhancements for many years - but always gets pushed to the back of the queue while they try to keep up with the constantly changing mobile dev tool chains. The reality is embarcadero simply do not have the resources to do this.
My original post was almost 6 years ago - you would think that a lot could be achieved in 6 years, but that isn’t what happened.
The changes in C++20 and C++23 are pretty huge.
Gcc and Clang are seen as the major worldwide compilers, with Microsoft seen as a bit less in general.
Except Microsoft have already included all? many? of the newest features in their compiler.
C++Builder implements C++17. Dinkumware provided the standard template library … but has wound down its business now, I think. So they (Embarcadero) have a real issue there too.
I’m assuming things may come to a head at some stage … open-sourcing the Delphi and CB compilers ??
Or some step in that direction??
Surely it can’t just coast down to a stand-still …
From @Glen_Kleidon2Melbourne talk this month, he was talking about a missing WriteAsync function in delphi. The actual IO could be handled by a IO Completion Port or using Overlapped IO. Once the Write call has been scheduled… the WriteAsync call would switch to/or create another fibre that is waiting on the IO port… which would then use SwitchToFiber to load back to code to continue the function that called WriteAsync. Sleep calls could be handled in a similar fashion - Using CreateWaitableTimer.
Each LINQ expression maps to an (extension) method on the Sequence type, under the hood.
Implementations for these methods are provided by the framework, on .NET, and by the Elements libraries (libToffee, Cooper.jar and Island RTL) on the other platforms.
– maps to .Distinct()
group X by Y / group by Y select x
– maps to .GroupBy()
from X in Y (inner from)
– maps to .SelectMany() with optional Cast<T> if the type is specified;
the result is turned into a special anonymous class where both original and new are available.
join on X equals Y
– maps to .Join()
order by X
– maps to .OrderBy, secondary order to .ThenBy()
order by X descending
– maps to .OrderByDescending, secondary order to .ThenByDescending()
– maps to .Reverse()
– maps to .Where()
– maps to .Select()
– maps to .Skip()
skip while X
– maps to .SkipWhile()
– maps to .Take()
take while X
– maps to .TakeWhile()
with (Oxygene) and let (C#)
– maps to .Select() with a special anonymous that makes both the original and the new variable available.