|
Re: Primitive Types ... In a Library?!
|
Posted: Oct 27, 2004 2:13 AM
|
|
It's nothing to be excited about. If you dare to look outside C++/Java/C#, usually "primitives" are not different from other types with respect to the type system, argument passing, semantics of assignment, implicit conversions etc. Look at Haskell, OCaml, Python, Ruby, Smalltalk.
They are special only in that their physical storage layout is unusual (e.g. they don't consist of references to other objects as most objects do), and that there is a syntax of literals which produces values of these types. Same as in Heron wrt. the types with underscores.
It doesn't matter in practice. As long as it behaves consistently, it doesn't matter how it's implemented. I don't care whether Float is a primitive, or a wrapper for a primitive - the net effect is the same.
It matters though how a programmer can add "primitive" types implemented in another language, similar to your types with underscores but as an open set. For example let's say we are interfacing to the bzip2 compression library, and want to wrap the C struct of type bz_stream as an object in our language, call bzip2-specific methods implemented in C on it, and the library wrapping should ensure that it's closed automatically when we finish with the wrapper object. The C struct is not copyable in a meaningful way, it must have a constant address (this is easy to ensure if you malloc a storage for the struct and pass the pointer - you only need to know when to free it). How to wrap such type in Heron?
|
|