-
Notifications
You must be signed in to change notification settings - Fork 13.7k
Closed
Labels
A-frontendArea: Compiler frontend (errors, parsing and HIR)Area: Compiler frontend (errors, parsing and HIR)C-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.E-easyCall for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.
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;
}
}
Metadata
Metadata
Assignees
Labels
A-frontendArea: Compiler frontend (errors, parsing and HIR)Area: Compiler frontend (errors, parsing and HIR)C-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.E-easyCall for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.