3 ms·
> "safety" means a bit more than "remember to use === yes, it means "type safety", i.e. strong typing. Including the compile-time safety net that c#, python,
by SideburnsOfDoom 13y ago
> "safety" means a bit more than "remember to use ===
yes, it means "type safety", i.e. strong typing.
Including the compile-time safety net that c#, python, Java et all have over c - you never pass a value typed as "void * *"; and that they have over over JavaScript - your code never gets an untyped object that you just have to hope has the expected methods or properties.
- mercurial 13y agoI don't think you mean "python" in this list. Anyway, you're right most of the time, though you can end up in the same situation with "optimistic downcasting" (eg, get an Object as parameter, and downcast it to whatever it is you hope the concrete object is an instance of).
- SideburnsOfDoom 13y agoYou may be right about python, I don't know it as well as the others. > though you can end up in the same situation with "optimistic downcasting" (eg, get an Object as parameter You can, though it doesn't happen much in practice. The complexity of the type systems (generics, interfaces, etc) are aimed in part at always allowing there to be a strong type.
- srj 13y agoUsing void* in C/C++ is to explicitly disable type checking for something like byte buffer i/o. Another circumstance is in a broad interface such as a callback method that will pass along an argument. In the latter case a top-level interface like 'object' is essentially the same thing and in both languages you can create APIs that don't have these catch-alls. What's the wisdom behind wanting to be protected from this construct?
- rbanffy 13y ago> have to hope If you need hope, you're doing dynamic languages wrong.