Saw this once in some crufty old VBScript code:
Variant vntBlah = DoSomething ()
For why this is even worse than usual, the punchline is here.
Saw this once in some crufty old VBScript code:
Variant vntBlah = DoSomething ()
For why this is even worse than usual, the punchline is here.
Good old Variants.. you never know what they really are. Delphi had those too (along with the more standard data types) but they are just confusing to use.
Good old Variants.. you never know what they really are. Delphi had those too (along with the more standard data types) but they are just confusing to use.
I guess a question can be asked here:
is a language with both static types and variants:
A, a statically typed language with variants as a sub-type;
B, a dynamically typed language with optional explicit type-specialization.
or, does it depend more on what magic goes on within the implementation?... (more values as tagged or untagged?...)
or, on the declaration syntax?... ("var x; var y:int;" vs "var x; int y;").
or, edge-case behavior (say, "long" only able to directly encode +-(2^61) and having to sometimes escape-code values outside this range, or very large/small doubles sometimes losing several bits of precision?... as a result of internal conversions to/from variant).
(in my case, this is one of those unanswered questions regarding whether to classify my script-language as statically or dynamically typed... then again, compared with other similar languages, it would probably be classified as statically typed, despite the frequent use of dynamic types in many places...).
I guess this sort of fits in with whether one indicates the type of a variant in a variable name:
is a variant the absence of type, or instead its own type within a collection of other types?...
(well, along with the whole matter of whether objects or variants are the conceptual root-type for the type-system, ...).
Considering you're normally supposed to use non-Variant types, I'd say it falls under A.
Also ugh, I completely hate Hungarian notation, and that it's misused doesn't help. If you're going to use it then at least use it properly! (it's supposed to indicate what kind of data is stored (e.g. pxWidth would mean width in pixels), not what type of variable is it).
Considering you're normally supposed to use non-Variant types, I'd say it falls under A.
Also ugh, I completely hate Hungarian notation, and that it's misused doesn't help. If you're going to use it then at least use it properly! (it's supposed to indicate what kind of data is stored (e.g. pxWidth would mean width in pixels), not what type of variable is it).
yeah, makes sense.
at least in my case (with my scripting language) using explicitly declared types can help significantly WRT things like performance, and also makes the compiler/interpreter better able to give useful errors and warnings, so this itself may be reason to use it, and likely puts things more in the statically-typed camp.
this is even if internally, tagged references are still often used, knowing the types often allows much cheaper logic to be used (allowing doing things directly, without all the type-checking and dynamic-dispatch and similar getting in the way).
...
so, you saying you don't like things like "LPCSTR szaStr;" or "DWORD dwSz;"?...
Yes, that's not actually Hungarian notation. That's some perversion created by someone at Microsoft who misunderstood the original idea. Within Microsoft they call this incorrect version "systems Hungarian" and the correct usage "apps Hungarian".so, you saying you don't like things like "LPCSTR szaStr;" or "DWORD dwSz;"?...
Also ugh, I completely hate Hungarian notation, and that it's misused doesn't help. If you're going to use it then at least use it properly! (it's supposed to indicate what kind of data is stored (e.g. pxWidth would mean width in pixels), not what type of variable is it).
Yep, pretty much. Generally I'd prefer if the name of the variable and the context by itself would be enough (if it isn't then you may want to rethink the design to make things clear enough). I guess Hungarian notation makes sense with complex projects handling all sorts of data (though in those cases I'd opt for more explicit variable names instead), but fake Hungarian notation is just a complete annoyance (if you can't tell the type by what the variable is supposed to do you have more serious issues), especially now that IDEs can help you look up the types of variables (so you don't need to do it in the source code at all).