Can anyone help me with this issue please?
Can anyone help me with this issue please?
This project can not be compiled (Delphi XE8 Update 1): http://www49.zippyshare.com/v/Ws9cdzJY/file.html
[dcc32 Fatal Error] uMapParallel.pas(94): F2084 Internal Error: C27720
Pastebin: http://pastebin.com/RwZCq4Z4
http://www49.zippyshare.com/v/Ws9cdzJY/file.html
This project can not be compiled (Delphi XE8 Update 1): http://www49.zippyshare.com/v/Ws9cdzJY/file.html
[dcc32 Fatal Error] uMapParallel.pas(94): F2084 Internal Error: C27720
Pastebin: http://pastebin.com/RwZCq4Z4
http://www49.zippyshare.com/v/Ws9cdzJY/file.html
Maybe it works in XE7?
ReplyDeleteXE: Doesn't compile.
ReplyDeleteXE7: [dcc32 Fatal Error] uMapParallel.pas(95): F2084 Internal Error: C26701
XE8: [dcc32 Fatal Error] uMapParallel.pas(95): F2084 Internal Error: C27720
Maybe my reply is off topic but this is not real map operation. Map should be able to return a new type.
ReplyDeleteLast time I checked, proper map or flatMap for generic types cannot be done in Delphi. Due to this shortcoming, it is impossible to use some basic FP concepts in Delphi.
Linas Naginionis
ReplyDeleteI take a leaf out of PHP array_map: http://php.net/manual/en/function.array-map.php where in/out types are the same. And what do you mean? Please show me an example.
I don't use php, but real map operation should be as follows (e.g. for IEnumerable):
ReplyDeletefunction IEnumerable.Map(const mapper: TFunc): IEnumerable;
flatMap:
function IEnumerable.FlatMap(const mapper: TFunc>): IEnumerable;
Linas Naginionis Of course it is possible (lets not argue about the the syntax and how verbose the code looks compared to doing that in an FPL). You just need to specify the input and output type and the transformation delegate:
ReplyDeletefunction Map(const input: TArray; const f: TFunc): TArray;
So Map([1,2,3,4,5], Power) returns [1,4,9,16,25]
Nonamed Pravdin Move the record type out of TMapParallel and make it TIndexedRecord. You can still define a nested alias TIndexedRecord = TIndexedRecord inside of TMapParallel so the rest of the code stays as it is. Also please report this to quality.embarcadero.com
Stefan Glienke Are you sure it works since XE4? This is your own post: https://plus.google.com/+StefanGlienke/posts/K1WNrCTdayN
ReplyDeleteYes, of course it does (see Spring.Collections.TCollections.Select). The issue I described in this post was something different (returning X> from a method of type X)
ReplyDeleteStefan Glienke No, it's the same issue. Just try to implement the methods I described previously. And I'm not talking about static class functions. I got the same compiler error recently trying to do so.
ReplyDeleteLinas Naginionis There you go: http://pastebin.com/UXtDtQtL (after this example from Java8: http://www.adam-bien.com/roller/abien/entry/java_8_flatmap_example)
ReplyDeleteStefan Glienke Where are flatMap and map methods which should be defined in IEnumerable in your example? You can't even compare this to Java 8 , your example looks so funny and weird :) Your approach is not composable. The whole point of map and flatMap (and monads in general) is composition and following the happy path. You don't need to fight against the language if it does not allow to do some things properly, IMO.
ReplyDeleteFlatMap and Map require a returntype different from the input type which is why these methods cannot be part of an interface which cannot have parameterized methods - you should know that. I already told you that we don't need to argue over the verbosity of the Delphi syntax. It does not need map, flatmap and collect since that is what SelectMany does (see https://msdn.microsoft.com/en-us/library/system.linq.enumerable.selectmany(v=vs.110).aspx)
ReplyDeleteStefan Glienke
ReplyDeleteThank you very much. Now it compiles fine. But if I change "Source: TArray" to "Source: array of T" in TMapParallel.Map, I get (inside TParallel.For() lambda): [dcc32 Error] uMapParallel.pas(70): E2555 Cannot capture symbol 'Source'. Is it a bug, or not?
Nonamed Pravdin More of a limitation that is by design. Some things cannot be captured into an anonymous method.
ReplyDelete/sub
ReplyDeleteStefan Glienke
ReplyDeleteVote please: https://quality.embarcadero.com/browse/RSP-11659