scala-subscript / subscript

9 stars 2 forks source link

Create result values for Swing scripts #21

Closed AndreVanDelft closed 8 years ago

AndreVanDelft commented 8 years ago

Current swing scripts have an output parameter, e.g.,

mouseMove(comp: Component, ?p : java.awt.Point) = ....

IMO we better replace these by result values:

mouseMove(comp: Component): java.awt.Point = ....

Then the callers should apply dataflow operators.

AndreVanDelft commented 8 years ago

I am not happy yet. mouseMove has now result value Any, instead of java.awt.Point, or better the MouseMoved event.

anatoliykmetyuk commented 8 years ago

So far, SubScript is untyped. We can of course make ScriptResultHolder covariant by removing var $ (contravatiant position) and describing it through private var _$: R, def $: R and def $_(v: Any) {_$ = v.asInstanceOf[R]}. But this will still register type errors only on runtime - during assignment. So far, these errors are registered in pattern matches in the dataflows - not much difference.

Making SubScript typed implies teaching the compiler to typecheck scripts - to register the errors in compile time. This will require moving the parser and the typer-level preprocessing back to the compiler (perhaps via plugins) and doing major changes to the typecheck system to support SubScript.

So far, it's not a big issue that Swing events are untyped, since this is compensated by the dataflows, like here.

AndreVanDelft commented 8 years ago

So we can live with it for the time being. The type checking would be easier in the forthcoming Dotty+ScalaParse based version of the SubScript compiler.

anatoliykmetyuk commented 8 years ago

Can we then close this issue? Since typecheck for SubScript is a wider issue then this one, it makes sense to make a separate one for it.

AndreVanDelft commented 8 years ago

Ok.