I have some doubts about the propositions, it looks for me inconsistent.
What will hapen if I define code like that inside my method:
void initListeners() throws SomeException {
void addListener(ItemSelectable is) { is.addItemListener( { ItemEvent e => if (...) throw new SomeException(); } ) } }
The problem is, that closure may be executed after the end of execution of the enclosing method.
If the closure will be executed after the method initListeners() will be finished, what will happen to the SomeException thrown from inside the closure?
It can not be just thrown to the Swing's API, because it didn't expect the checked exception of this type after calling itemStateChanged method from ItemEventListener interface.
Is there any planned way to inform compiler that a specific closure can not throw Exception (or return a value), because it might be executed after the end of execution of enclosing method? I do not see a clear way to enforce that rules by the compiler.
Flat View: This topic has 19 replies
on 20 pages
[
«
|
1617181920
|
»
]