rokucommunity / brighterscript

A superset of Roku's BrightScript language
MIT License
162 stars 47 forks source link

support interface for aas #20

Open georgejecook opened 5 years ago

georgejecook commented 5 years ago

Similar to class, we should allow interface. this will allow us to get to a goal where the ide will have increasing information about types.

interface would produce nothing in the brs code - the benefit of the type declaration would be entirely for the ide's symbol and definition resolution and the compiler.

example

interface styleInfo
  selectedColor: string
  color: string
  fontSize : integer
end struct

public function someMethod(buttonStyle: StyleInfo)
  button.applyStyle(styleInfo)
end function

output is


public function someMethod(buttonStyle: StyleInfo)
  button.applyStyle(buttonStyle)
end function

the interface would simply vanish at runtime; merely providing the ide with more type info. This does of course require that we have more advanced typing, which i would dearly love to see, whereby we can have as default values (object|integer|dynamic) as well as new specific types for our classes and interface (StyleInfo|MyButton|UserInfo|FancyButton), whereby the types here are the class or node names.

TwitchBronBron commented 5 years ago

I probably wouldn't support the word "struct", but instead support an interface, the same way that TypeScript does. Just playing on semantics though, because I believe typescript-style interfaces are roughly what you're asking for anyway, right?

georgejecook commented 5 years ago

that's even better.

georgejecook commented 5 years ago

I updated the ticket. thanks