RFR: 8264707: HotSpot Style Guide should permit use of lambda [v2]
Kim Barrett
kbarrett at openjdk.java.net
Sat Sep 25 00:18:04 UTC 2021
On Thu, 23 Sep 2021 22:39:29 GMT, Coleen Phillimore <coleenp at openjdk.org> wrote:
>> Kim Barrett has updated the pull request with a new target base due to a merge or a rebase. The incremental webrev excludes the unrelated changes brought in by the merge/rebase. The pull request contains five additional commits since the last revision:
>>
>> - Merge branch 'master' into permit_lambda
>> - terminology fix
>> - add scope guard and some example uses
>> - G1 SATB filter lambda
>> - new local functions section
>
> src/hotspot/share/compiler/compilerOracle.cpp line 787:
>
>> 785:
>> 786: char* original_line = os::strdup(line, mtInternal);
>> 787: auto g = make_guard([&] { os::free(original_line); });
>
> I have to admit that this usage is very mysterious. I know you're going to take it out but using lambdas for something that's really hard to parse doesn't seem like a win. Does save lines of code though.
I think a different approach may be possible, that would have usage like this:
char* original_line = os::strdup(line, mtInternal);
ScopeGuard guard([&] { os::free(original_line); });
This would use something like (or maybe directly use) a solution to the type-erased lambda capturing problem a la std::function.
-------------
PR: https://git.openjdk.java.net/jdk/pull/5144
More information about the hotspot-dev
mailing list