RFR: 8367531: Template Framework: use scopes and tokens instead of misbehaving immediate-return-queries [v29]
Emanuel Peter
epeter at openjdk.org
Fri Nov 14 14:58:36 UTC 2025
On Fri, 14 Nov 2025 14:40:49 GMT, Roberto Castañeda Lozano <rcastanedalo at openjdk.org> wrote:
> > So I suppose it is a choice, yes. But I don't think the alternatives would be better.
> >
> > * You could just throw an exception at the second definition. But then you would need a way to check for existence of hashtag names ... not great.
> > * You could just hide outer definitions... basically they would work like scoped values: you can bind and re-bind them. But that brings its own complexity that I don't want to push on the users if it's not absolutely necessary.
> >
> > If you really do need access to something from an outer template, you should just pass it via template argument. That makes the flow explicit. That's my opinion.
>
> Sounds OK to me, I think it would be worth capturing this rationale and advisory somewhere in the documentation.
Where do you think it should go? Some ideas:
- At the `let` definition, I could say that the hashtags won't go into a nested template, and if one wants to pass something to a nested template it should be done with template arguments. And in the turorial I could add a note somewhere. That's for the advice.
- About the rationale for the choice of having hashtags be local to a Template ... I don't know where to put that really. It does not belong into the API documentation, and also not really into the tutorial so much.
I'll make some code change suggestions, and then you can give me feedback on if that's sufficient for you.
-------------
PR Comment: https://git.openjdk.org/jdk/pull/27255#issuecomment-3533159147
More information about the hotspot-compiler-dev
mailing list