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
TGenericStructList readonly record elements? #63
Comments
This is correct, and it's a good thing that the compiler warns about this. In some old compiler versions, this was allowed and resulted in nasty bugs. Why? The property that implements the [] access to the list is done by a getter/setter function. More precisely, the implementation of
What this means is that
is equivalent to
Now, the
Which means that
In contrast, It's the same in other programming languages. E.g. in C# they have "structs" (much like a "record" in Pascal) and something similar to Pascal properties, and they also disable doing So it's not something easily "fixable" at the language level, Pascal is not alone here. If you allow records/structs (that are automatically copied at assignment) then you have this problem. This is also why we have |
Thanks a lot! I should have checked that.... :) |
I'm getting a "The argument cannot be assigned to" error when trying to change TGenericStructList elements fields. Is this correct? Works fine with object lists... Didn't try it with simple lists (like integer lists).
The text was updated successfully, but these errors were encountered: