Open AndreVanDelft opened 10 years ago
Output parameters (?p) and constrained parameters (??p) are not yet supported for script lambda's. A lambda expression such as
(?i:Int) => [expr]
should be parsed well and transformed into
(_i:FormalOutputParameter[Int]) => [expr (with i replaced by _i.value)]
etc., like scriptLocalDataTransformer does in https://github.com/AndreVanDelft/scala/blob/develop/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala (around line 1700).
A type
?Int => Script
should be parsed and rewritten into
FormalOutputParameter[Int] => Script
The hard part will be the parsing: accept the optional ? and ?? at the start of a parameter list, just after the '(' (or after "case" in a partial function), or maybe even harder: just before a type name.
It may be worthwile to support all these transformations as well for normal methods and for class parameters, rather than for scripts only. The Scala code in https://github.com/AndreVanDelft/scala/blob/develop/src/subscript/subscript/swing/Scripts.scala contains currently phrases such as
case class KeyTypedReactor[...](..., keyCode: FormalConstrainedParameter[Char]) ... { ... if (keyCode.matches(char)) { keyCode.value = char ... } ... }
Instead we should be able to write:
case class KeyTypedReactor[...](..., ??keyCode:Char) ... { ... if (_keyCode.matches(char)) { keyCode = char ... } ... }
Output parameters (?p) and constrained parameters (??p) are not yet supported for script lambda's. A lambda expression such as
should be parsed well and transformed into
etc., like scriptLocalDataTransformer does in https://github.com/AndreVanDelft/scala/blob/develop/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala (around line 1700).
A type
should be parsed and rewritten into
The hard part will be the parsing: accept the optional ? and ?? at the start of a parameter list, just after the '(' (or after "case" in a partial function), or maybe even harder: just before a type name.
It may be worthwile to support all these transformations as well for normal methods and for class parameters, rather than for scripts only. The Scala code in https://github.com/AndreVanDelft/scala/blob/develop/src/subscript/subscript/swing/Scripts.scala contains currently phrases such as
Instead we should be able to write: