Closed
Description
Within the same file and module, modules should be able to be split up and combined at compile-time. This would allow putting non-native functions in a native module, in turn allowing convenient use of opaque forms. For example:
mod objc {
// Opaque type for objc objects. This might more realistically be a resource type to handle ObjC reference counting.
tag id { _id(unsafe::id) }
// safe version
fn get_class(name: str) -> id {
_id(str::as_buf(name, {|name_buf| unsafe::objc_getClass(name_buf)}))
}
mod unsafe {
// non-opaque type for objc objects
type void = int;
type cls = *void;
type id = *{isa: cls};
}
native mod unsafe {
fn objc_getClass(name: str::sbuf) -> id;
}
}