lambda syntax became more strict
Declaring something like this:
TSomeCallback = function (const aElement: JElement; const aFieldName: String; var aData: Variant): Boolean;
procedure SomeMethod(const aXElement: JElement; const aXFieldName: String; var aXData: Variant; const OnSucess: TSomeCallback);
i could previously (on the commit from the 6th of january) do
SomeMethod(lElement, lString, lVariant, lambda => false);
I pulled the latest committ (16th of january 2017). (I had to change scope to protected at @378 in dwsUtils to compile, just FYI.)
Now i get a syntax error stating that "Argument 3 expects type function "TSomeCallback(const aElement: JElement; const aFieldName: String; var aData: Variant): Boolean" instead of "lambda(JElement,String,Variant):Boolean" [line...
Maybe this is intended. Maybe i should remove the "const"s. In any case the "lambda => false" is very neat IMHO.
Comments (6)
-
repo owner -
reporter When i compile my little project (most dws units implicitly included) i get:
[dcc32 Error] dwsSymbolDictionary.pas(526): E2003 Undeclared identifier: 'FCount' [dcc32 Error] dwsSymbolDictionary.pas(528): E2003 Undeclared identifier: 'FCapacity' [dcc32 Error] dwsSymbolDictionary.pas(531): E2003 Undeclared identifier: 'FBuckets' [dcc32 Error] dwsSymbolDictionary.pas(531): E2029 'THEN' expected but identifier 'HashCode' found [dcc32 Error] dwsSymbolDictionary.pas(534): E2066 Missing operator or semicolon [dcc32 Fatal Error] dwsExprs.pas(118): F2063 Could not compile used unit 'dwsSymbolDictionary.pas'
so i changed from "private" to "protected" in dwsUtils.pas. The members of TSimpleHash<T>. Just to be able to test with the latest commit. Thought i'd mention it. Thought it might be helpful.
-
repo owner Interesting, I am not getting any error in Delphi XE, while the compiler should indeed have complained.
Pushed a commit with the scope change for now (FWIW the generic will be replaced by a non-generic at some point, both for performance and FreePascal compatibility)
-
reporter I am experimenting using Berlin Upd 2.
-
repo owner - changed status to resolved
Fixed Issue
#87+ added test→ <<cset 6771db139730>>
-
reporter Works! 1000 thanks.
- Log in to comment
Looks like a side-effect from a recent change in const parameters to allow passing the by value rather than by reference for small structures (like a function pointer), the lambda semantic/type inferring needs to be updated.
What was the change for ?