-
-
Notifications
You must be signed in to change notification settings - Fork 130
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature request: Allow const in enamldefs that uses the ReadOnly
member
#545
Comments
I will have to check how const is currently used. I am on my phone and could not remember/find what we do with it. |
“const” is part of the templating system.
…On Wed, Mar 6, 2024 at 12:38 Matthieu Dartiailh ***@***.***> wrote:
I will have to check how const is currently used. I am on my phone and
could not remember/find what we do with it.
—
Reply to this email directly, view it on GitHub
<#545 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AABBQSJRX3LAZOSAQXEUNG3YW5PCBAVCNFSM6AAAAABEJJXQPCVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSOBRGU2DKMRUGQ>
.
You are receiving this because you are subscribed to this thread.Message
ID: ***@***.***>
|
I know it has been a long time but could you explain a bit the reasoning behind const in template. Looking at the advanced example it get it serves to generate temporary bindings within the template body but is it all there is to it ? Personally, I would not be against allowing const in enamldef with a different meaning from the one it takes in templates. And I should try to document templates because even to me there are obscure. |
Yes, it has a purpose.
IIRC it is used to indicate expressions that are only evaluated once on the
first invocation of the template, and they cannot be changed later. Those
const values can then be used as parameters to specialize templates via
template overrides/specialization, very similar to C++.
You cannot pass a non-type, or non-const parameter to a template.
…On Mon, Mar 18, 2024 at 12:13 Matthieu Dartiailh ***@***.***> wrote:
I know it has been a long time but could you explain a bit the reasoning
behind const in template. Looking at the advanced example it get it serves
to generate temporary bindings within the template body but is it all there
is to it ?
Personally, I would not be against allowing const in enamldef with a
different meaning from the one it takes in templates. And I should try to
document templates because even to me there are obscure.
—
Reply to this email directly, view it on GitHub
<#545 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AABBQSJBPPBSOINAKIMDBRTYY4OEJAVCNFSM6AAAAABEJJXQPCVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDAMBUGQ4TEOBTGY>
.
You are receiving this because you commented.Message ID:
***@***.***>
|
***first *unique* invocation of the template.
Template results are/should be cached based on their unique argument hash.
…On Fri, Mar 22, 2024 at 18:25 Chris Colbert ***@***.***> wrote:
Yes, it has a purpose.
IIRC it is used to indicate expressions that are only evaluated once on
the first invocation of the template, and they cannot be changed later.
Those const values can then be used as parameters to specialize templates
via template overrides/specialization, very similar to C++.
You cannot pass a non-type, or non-const parameter to a template.
On Mon, Mar 18, 2024 at 12:13 Matthieu Dartiailh ***@***.***>
wrote:
> I know it has been a long time but could you explain a bit the reasoning
> behind const in template. Looking at the advanced example it get it serves
> to generate temporary bindings within the template body but is it all there
> is to it ?
>
> Personally, I would not be against allowing const in enamldef with a
> different meaning from the one it takes in templates. And I should try to
> document templates because even to me there are obscure.
>
> —
> Reply to this email directly, view it on GitHub
> <#545 (comment)>,
> or unsubscribe
> <https://github.com/notifications/unsubscribe-auth/AABBQSJBPPBSOINAKIMDBRTYY4OEJAVCNFSM6AAAAABEJJXQPCVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDAMBUGQ4TEOBTGY>
> .
> You are receiving this because you commented.Message ID:
> ***@***.***>
>
|
Constant
memberReadOnly
member
It would be nice to be able use
const
instead of a normalattr
that uses aConstant
member so the value can't be changed from the initial value.If you think this would be ok, I'd be willing to submit a PR.
The text was updated successfully, but these errors were encountered: