| Catfish3 (275) | |||
Do you consider it ugly to put :: in front of global variables and functions?
| |||
|
|
|||
| chrisname (6181) | |
Yeah, I see :: as connecting two things so if you put ::ident it's like you're connecting it to the void. I don't like it.
| |
|
|
|
| L B (3806) | |
|
I would prefer it when it could potentially be ambiguous. @chrisname I see it as the scope resolution operator, not as connecting two things. I think of it as resolving the scope when it is ambiguous or not clear. | |
|
|
|
| chrisname (6181) | |
| No need to be passive aggressive. | |
|
|
|
| Framework (3237) | |
|
You've just made everything within the name-space static; you won't be able to access them outside of the TU. Was that intentional? I personally don't think it was or else you would've said. As for the actual question, yes, I only use the SRO prefix when my code is within the global name-space. However, 99% of the time my code resides within a user-defined name-space so I tend to omit the SRO prefix. And no, it's not ugly; it's explicit and I like that. +1 LB for mentioning ambiguity resolutions. Wazzak | |
|
Last edited on
|
|
| Oria (71) | |
I would of preffered a .
| |
|
Last edited on
|
|
| Framework (3237) | |
|
@Oria: Please explain why the member-access operator would be preferable. Wazzak | |
|
|
|
| chrisname (6181) | |
|
@Framework He knows C# so I'm guessing it's because C# uses the . operator for both member access and scope resolution. Like me, he probably prefers how it looks. | |
|
|
|
| Framework (3237) | |
|
Ah, right. Strange answer though, for a C++ question. Wazzak | |
|
|
|
| Oria (71) | |||
Exactly. I find that it looks cleaner.
Well he ask if we think its ugly... in short answer; I do. Edit: in reality C# is designed differently for that though. because everything has to be inside a namespace, so let say your namespace is Joe; your global variable would be Joe.global | |||
|
Last edited on
|
|||
| chrisname (6181) | |||
Nothing has to be inside a namespace. You can write a C# program without the word "namespace" appearing anywhere. You just can't put variables and methods outside of a class. | |||
|
|
|||
| L B (3806) | |
::Namespace::Class::StaticMember(OrFunction).InstanceFunction().InstanceMember.InstanceFunction();I like being able to tell the difference between instance and static. I hate that you can use the . operator to access static fields, I wish that would go away. | |
|
Last edited on
|
|
| chrisname (6181) | |
You mean like this?if (string.find(search) != string.npos)? Because I hate that too (using an instance to access a static member, that is). | |
|
Last edited on
|
|
| L B (3806) | |
I wouldn't mind InstanceVariable::StaticMember, but then you would get me fussed up about how static class functions should be polymorphic when called from an instance.
| |
|
|
|
| chrisname (6181) | |
IMO static members should only be referencable from a static context, i.e. Class::Member or Class.Member.
| |
|
|
|
| L B (3806) | |
| I would prefer a different syntax from accessing members so that an ugly naming convention wouldn't have to be used. | |
|
|
|
| maeriden (339) | |
| What would you use? | |
|
|
|
| L B (3806) | |
|
:: for static . for instance | |
|
|
|
| Oria (71) | ||
Right sorry, inside the class is what I meant, out side of the methods. However I didn't know you didn't need a namespace. I guess I've never tried to not use one, but I just tested it and yeah, no namespace needed... | ||
|
|
||
| chrisname (6181) | |
|
@L B What ugly naming convention? | |
|
|
|