Opinion: What should I name the generic handle type?
"ref" is short and neat, I like it. Depending on how it works I'd otherwise suggest "ptr" which is very similar.
[size="1"]trassel (thread lib)
'ref' looks like a variable, 'any' is confusing..
'unknown' would be a bad name, since you're required to know the type beforehand.
Since HANDLE is used in win32 API, I think it should be called 'handle'.
As I understand it not having to know the type beforehand is the whole point of this. A "void*" which better syntax for assignments.
"ref" is short and neat, I like it. Depending on how it works I'd otherwise suggest "ptr" which is very similar.
[size="1"]trassel (thread lib)
As SiCrane pointed out, 'any' is not to be considered. This is already used as a generic container that can be used to store both value types and reference types.
AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game
Closest thing in C++ besides void would be the C++0x auto keyword, but the connotations are somewhat different. Maybe the name could be explicitly untyped or untypedRef for clarity?
I may be wrong but I don't think 'auto' serves the same purpose. Unless I'm mistaken, 'auto' is to declare a variable that will assume the type of the assigned value. Once a value is assigned to the variable, the type is known so no other types can be assigned to it. I believe this was introduced in C++0x specifically to make it easier to write templates.
AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game
[font=arial, verdana, tahoma, sans-serif][size=2]void@ would truly make sense. But since it would be problematic from the engine perspective, I put my vote for handle.[/font]
I may be wrong but I don't think 'auto' serves the same purpose. Unless I'm mistaken, 'auto' is to declare a variable that will assume the type of the assigned value. Once a value is assigned to the variable, the type is known so no other types can be assigned to it. I believe this was introduced in C++0x specifically to make it easier to write templates.
Yes, that is how it works. I just really meant it was the most similar thing besides void not that it was particularly close - really it is a compile-time construct where this is a runtime thing. It has uses outside of templates though - I like using it for STL iterators.
// Don't have to specify the type
for (auto iter = someSTLContainer.begin(); iter != someSTLContainer.end(); ++iter)
{
...
}
or handling the returned value from make_shared<>().
I would be perfectly happy with ref or handle.
Put me down for ref. You are just awesome for doing this WitchLord!!!
Also, I am always one for non-verbose code, and 'handle' to me just seems... wordy. Another option could be 'gen', for "generic".
Also, I am always one for non-verbose code, and 'handle' to me just seems... wordy. Another option could be 'gen', for "generic".
To me 'ref' and 'gen' looks like variables.
If you are so inclined, then a small typedef is all you need.
'ref' and 'gen' are two examples of a really bad naming scheme.
What does they stand for?
'referee', 'refill', 'refund', 'reflect' ?
'gender', 'general', 'genetic', 'genius' ?
Seeing that 'handle' is a smaller word than 'reference', I'd choose that one.
Just my two cents.
If you are so inclined, then a small typedef is all you need.
'ref' and 'gen' are two examples of a really bad naming scheme.
What does they stand for?
'referee', 'refill', 'refund', 'reflect' ?
'gender', 'general', 'genetic', 'genius' ?
Seeing that 'handle' is a smaller word than 'reference', I'd choose that one.
Just my two cents.
Too many projects; too much time
To me 'ref' and 'gen' looks like variables.
If you are so inclined, then a small typedef is all you need.
'ref' and 'gen' are two examples of a really bad naming scheme.
What does they stand for?
'referee', 'refill', 'refund', 'reflect' ?
'gender', 'general', 'genetic', 'genius' ?
Seeing that 'handle' is a smaller word than 'reference', I'd choose that one.
Just my two cents.
This is a valid point my good sir. If I may offer a rebuttal?
In the context of computer programming, the words 'referee', 'refund', and 'reflect' make about as much sense as "Hello Vader" or this. Or maybe they do depending of the context within the context. (A referee bot? A refund value? A reflection about an axis? Maybe Vader crashed on Kashyyyk and all he had was a Brita filter?) Regardless, is it really a problem? ref is a perfectly valid shortening of reference as any. In fact, C#, allows references with exactly this keyword with no real apparent downsides.
EDIT: Besides, handle already is covered with @. Good languages explain themselves. handle@ is simply a redundant statement that to some people might even seem confusing.
Actually, when it's put that way, ref even starts to seem redundant and confusing. 'gen' or 'generic' now seems like the most appropriate for this as it explains that any type of handle can be stored in it.
generic@[] m_Handles;
gen@[] m_Handles;
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement