Skip to content
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

Readonly CachedExpressions #23

Closed
vzam opened this issue Feb 5, 2021 · 1 comment
Closed

Readonly CachedExpressions #23

vzam opened this issue Feb 5, 2021 · 1 comment
Labels

Comments

@vzam
Copy link

vzam commented Feb 5, 2021

Is there a reason for static readonly CachedExpressions not to work and instead allow status CachedExpression { get; } only? This doesn't make much sense to me because I typically never change the value of those and I would like to express that in my code.

@axelheer
Copy link
Owner

axelheer commented Feb 5, 2021

Using an auto-property without setter is basically the same as a read-only field, since the compiler generated getter function accessing the read-only field behind shouldn't generate any overhead / gets inlined anyway. But you can make changes in the future and (more important maybe) add a break point on any getter. Thus, it's generally considered a good practice not exposing any fields, but using properties / functions instead.

Howsoever, the functionality of NeinLinq is build on functions; property getters are functions (with limitations) too. I am not sure how extending this functionality for field access would bloat the processing underneath - if it's less efficient to support both ways, I wouldn't support it.

As of now I don't know what supporting both, functions and "raw" field access would "cost". There wasn't any demand until now.

@vzam vzam closed this as completed Feb 6, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants