You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@ggoraa thanks for the suggestion -- this looks equivalent to type variables in interfaces, which are another way of declaring type parameters. Using type variables, as in local interface View<Props>, would make it more similar to the way we handle type variables in records today.
Just for fun, the following approximation works today, albeit with bad ergonomics (and a warning) because that local type Button doesn't work like a type alias, but rather as a new unrelated nominal type.
localrecordView<Props>metamethod__call: function(self: View<Props>, props: Props): View<Props>props: Propsbody: function(self: View<Props>)
endlocalrecordButtonPropslabel: stringaction: function()
endlocaltypeButton=View<ButtonProps>functionButton.body(self: View<ButtonProps>)
localmyLabel=self.props.label-- totally valid-- do somethingprint(myLabel)
end-- this is also totally validlocalb=Button {
label="My label",
action=function()
-- do somethingend
}
b.body(basView<ButtonProps>)
When adding interfaces, my plan is to fix those ergonomics/aliasing issues by handling self in a special way (not unlike e.g. Rust).
Yeah, currently it doesn't look great, but I think the addition of interfaces will definitely elevate Teal to be an actually production-ready language that can be used in real projects
Also, I think that the associatedtype syntax (or similar) is better in terms of code reading imo
(Btw, Teal is currently thought about (well mostly by me, I actually pitched the idea to the devs) as an official language for EdgeTX to be used alongside Lua, so if there is any room for cooperation between the two projects it will be great!)
As a suggestion for a future interface implementation in Teal, I can suggest a system of associated types. It's easier to just show an example:
(daym dat issue number is fire)
The text was updated successfully, but these errors were encountered: