3 ms·
The comparison to Java isn't quite right, as D has structs which are like classes can be on the stack and classes which must always be a reference. So there's a
by jordigh 11y ago
The comparison to Java isn't quite right, as D has structs which are like classes can be on the stack and classes which must always be a reference. So there's a bit of a syntactic inconsistency, where you might think that "SomeClass object;" would declare an object on the stack like "SomeStruct inst;" would, whereas instead it only declares a null reference.
If classes can only be references, the syntax should enforce that more clearly. In Java, everything is a reference, so there is less inconsistency there.
- Mister_Snuggles 11y agoYeah, it's not a perfect comparison. I only chose it because I'm familiar with it and understand how that style of code would behave. I do agree that reading a line like "Blah varName;" is confusing when you don't know what 'Blah' is.