-
Notifications
You must be signed in to change notification settings - Fork 47
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
Naming conventions for "private" struct members. #73
Comments
This is related to the discussions on whether to allow struct functions to use (struct) variables without the self. prefix. Just like C++ etc. I think this will make a lot of code more readable. C2 does (will) not have the public/private stuff, but it might be good to signal a member access. This does make the case var.member and (in structfunc) _member different... Hmm |
If it was a lang from scratch I would have suggested a sigil if you wanted to access a struct member in a struct function, but that is too much of a change I think. In JaI, ”using X” would give direct access to members in the function. I’m two minds about this. Because having to deal with access directly emphasises the fact that one must deal with the null-pointer scenario. |
I was looking at this: https://github.com/c2hub/c2vector/blob/master/c2vector/c2vector.c2
And realized that maybe C2 needs a convention (or a way) to name / signal "internal" (I wouldn't use 'private') fields.
There are a few options:
c = v.capacity
and maybea = v.$total
orc = (private v).total
orc = private v.total
(not beautiful solutions, just describing the options we have)$foo
" like intype Foo struct { int $foo; }
The text was updated successfully, but these errors were encountered: