One thing that has bothered me about once methods is that you can't optimize depending on whether the method has been run yet.
One example would be if we changed each EventListeners in FWT classesbe once methods instead of fields with private set. If the method hasn't been called yet (e.g. to add a listener) then there's no point instantiating the object to fire an event that goes nowhere.
I'm proposing we allow access to the underlying cache variable using the field syntax:
@Transient once EventListeners onAction() { EventListeners() }
Void click() {
&onAction?.fire(Event { id = EventId.action; })
}
This syntax would only be supported for getting the implicit field, but not setting it.
brianSun 5 Jun 2011
Cool idea, definitely something to think about. Although at the immediate moment, I am not sure I want to enhance once functionality until more thought is given to if/how once should work with const classes.
qualidafialWed 8 Jun 2011
For purposes of serialization, once methods are excluded, correct? I'm working on a patch to replace the EventListeners fields in FWT with once methods, and need to know if I can get rid of @Transient facets.
brianWed 8 Jun 2011
Yes once methods are treated as methods, not fields
qualidafial Fri 3 Jun 2011
One thing that has bothered me about
once
methods is that you can't optimize depending on whether the method has been run yet.One example would be if we changed each
EventListeners
in FWT classesbeonce
methods instead of fields with private set. If the method hasn't been called yet (e.g. to add a listener) then there's no point instantiating the object to fire an event that goes nowhere.I'm proposing we allow access to the underlying cache variable using the field syntax:
This syntax would only be supported for getting the implicit field, but not setting it.
brian Sun 5 Jun 2011
Cool idea, definitely something to think about. Although at the immediate moment, I am not sure I want to enhance once functionality until more thought is given to if/how once should work with const classes.
qualidafial Wed 8 Jun 2011
For purposes of serialization,
once
methods are excluded, correct? I'm working on a patch to replace theEventListeners
fields in FWT withonce
methods, and need to know if I can get rid of@Transient
facets.brian Wed 8 Jun 2011
Yes once methods are treated as methods, not fields