HomeForumResearchGuide
Sign in to reply to forum posts.
Importing a type without using 'requires'

hi, this is probably something super simple but if I have a component like this:

component provides App requires io.Output out {
   int App:main(AppParam params[]){
      return 0
   }
}

...how can I import/access types like String or DateTime which I can't put as a requires clause?

jess

Hi Jess,

In those cases, you have to use the keyword "uses" to access those data types. Here's an example:

uses data.String
component provides App requires io.Output out {
    int App:main(AppParam params[]){
        String a = new String("s")
        return 0
    }
}

You can use the keyword "uses" in both components and interfaces to import types. If you do that in an interface, all components that implement that particular interface can access the data type imported. If you use it in the component, only the component can use the type.

Roberto

I knew it would be simple :) thanks for the super detailed answer!

jess