Skip to content

Split Module Definitions #1241

Closed
Closed
@DylanLukes

Description

@DylanLukes

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

No one assigned

    Labels

    A-frontendArea: Compiler frontend (errors, parsing and HIR)C-enhancementCategory: 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.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions