-
-
Notifications
You must be signed in to change notification settings - Fork 270
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
Constants #42
Comments
I can't see why this should be useful. Are there any real-world scenarios which justify the overhead caused by such "constants"? In fact, context variables are already constant and nothing could change their value (in your original context). Only the names can be overwritten by something else (by using the internal Private map from the ExecutionContext); the values in the Public context remain unchanged. |
Lets say that we have the next context context := pongo2.Context{
"STATUS_ENABLED": 1,
"STATUS_DISABLED": 2,
} and then some where in templates i wan to compare some thing like Now we have a problem! Everything in pongo2.Context are variables, not constants |
I still don't see a reason to introduce a name protection (which is what you're proposing). It rather looks like an organizational problem than a technical one. I would suggest introducing some variable prefixes in your case so there will be no name clutter in templates and accidental name overrides. Such a runtime name protection would cause some relevant runtime overhead (because on any variable access there is at least one more check to a map which means hashing, looking up, etc.); in addition to that, this feature would only be used very rarely by users. I don't think it's worth introducing it. |
Hello
How do you think, do pongo2 needs to have constants?
For me it looks like in templates
and in go code
And of course nothing can't change it.
The text was updated successfully, but these errors were encountered: