5 ms·
I have an addition to writing unmaintainable code. Only have one struct with a member of every type. That one struct will be the type of every variable you hav
by bausshf 8y ago
I have an addition to writing unmaintainable code.
Only have one struct with a member of every type. That one struct will be the type of every variable you have.
If the language you use support implicit operator overload abuse them to make sure all types can be implicitly converted to each other.
Ex.
struct Variable
{
byte a;
short c;
int d;
long e;
...
}
This will make it impossible to know what type a variable is until you find its assignment, which of course isn't on the same line as the declaration and even better reuse the same variable for multiple values.
- evozer 8y agoIf you want to be more efficient, you can also use a union for this. typedef union { int i; float f; double d; long l; char c; void *p; ... } var; Now you might also get some nice float-interpreted-as-int bugs if you forget the type! You can also kind of pretend that you have C#-style type inference: var x = { .i = 10 }; var y = { .f = 2.0f };
- bausshf 8y agoBut you don't want to be efficient lmfao
- scarface74 8y agoYou’ve just describe the variant type in COM....