-
Notifications
You must be signed in to change notification settings - Fork 151
Open
Labels
feature requestNew feature or requestNew feature or request
Description
When designing callback-based APIs, end-users have to reify the type information of the callback, even if that information is already defined in the interface. This is particularly cumbersome when working with generics.
emitter:observe(events.Greeting, function(e: event.Greeting)
print("Hello " .. e.name)
end)Ideally, we could just use:
emitter:observe(events.Greeting, function(e)
print("Hello " .. e.name)
end)This feature is sometimes called contextual typing or target type inference. It allows the type checker to infer the types of lambda/closure parameters from the expected type at the call site, rather than requiring explicit annotation.
For example, in Java:
list.forEach(item -> System.out.println(item));Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
feature requestNew feature or requestNew feature or request