5 ms·
Note that "var" is a typedef'd "void *". This essentially bypasses C's typechecker for libCello code. The author admits as such, and maybe that's just fine fo
by breckinloggins 13y ago
Note that "var" is a typedef'd "void *". This essentially bypasses C's typechecker for libCello code. The author admits as such, and maybe that's just fine for what you need to do, but you should be aware of it.
- eblume 13y agoI wrote a similarly-themed (although much less complete and much less useful) package for Go called 'Proto' which essentially sidesteps the static typechecker by mapping the 'base useful type' to `interface{}`, which is philosophically similar to `void *`. I personally have no problem with it (other than the syntax needed to unbox/rebox values). I find that having the freedom to use a type system or not a very compelling feature in a language. That being said, I understand why it might sit very poorly with some.
- bjeanes 13y agoThough in Go, you can always use reflection to get back the concrete type in an `interface{}` type. In C, `void *` is pretty much all you get. This causes far more subtle bugs, IMO. Source: someone who hasn't done much C and only a little bit of Go. So take it with a grain of salt.
- tomp 13y agoIn Cello, however, all types are supposed to start with a type declaration, so that you can get the type back at runtime.
- optymizer 13y agorandom question: doesn't ObjC define 'nil' (or self?) as 'void*'? I did some ObjC coding 2 years ago and I remember seeing something like this and thinking: oh boy.
- rdouble 13y agoNil is (void *)0.
- geon 13y agoThe ’id’ type is a void *. It is used extensively, whenever there are multiple possible return types. Even where inheritence could have been used to make it more speciffic. For example, ’alloc’ and all ’init’ returns it.
- 0x09 13y ago> The ’id’ type is a void . non typedef struct objc_class *Class; typedef struct objc_object { Class isa; } *id; with struct objc_class { Class isa; /* objc v1 members omitted */ };