{"action":"opened","issue":{"url":"https://api.github.com/repos/AndreVanDelft/scala/issues/73","labels_url":"https://api.github.com/repos/AndreVanDelft/scala/issues/73/labels{/name}","comments_url":"https://api.github.com/repos/AndreVanDelft/scala/issues/73/comments","events_url":"https://api.github.com/repos/AndreVanDelft/scala/issues/73/events","html_url":"https://github.com/AndreVanDelft/scala/issues/73","id":56094823,"number":73,"title":"Improve dataflow arrows","user":{"login":"AndreVanDelft","id":3143379,"avatar_url":"https://avatars.githubusercontent.com/u/3143379?v=3","gravatar_id":"","url":"https://api.github.com/users/AndreVanDelft","html_url":"https://github.com/AndreVanDelft","followers_url":"https://api.github.com/users/AndreVanDelft/followers","following_url":"https://api.github.com/users/AndreVanDelft/following{/other_user}","gists_url":"https://api.github.com/users/AndreVanDelft/gists{/gist_id}","starred_url":"https://api.github.com/users/AndreVanDelft/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/AndreVanDelft/subscriptions","organizations_url":"https://api.github.com/users/AndreVanDelft/orgs","repos_url":"https://api.github.com/users/AndreVanDelft/repos","events_url":"https://api.github.com/users/AndreVanDelft/events{/privacy}","received_events_url":"https://api.github.com/users/AndreVanDelft/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/AndreVanDelft/scala/labels/enhancement","name":"enhancement","color":"84b6eb"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-01-30T22:44:01Z","updated_at":"2015-01-30T22:44:01Z","closed_at":null,"body":"Data flow arrows `~~>` and `~/~>` (for Throwables) are rather new in SubScript. \r\n[A recent use case](http://subscript-lang.org/task-management/) revealed that the operator priority needs to change:\r\n```\r\nquery.findInBackground \r\n \r\n~~task:Task[List[ParseObject]]~~> \r\n \r\nfor (post <- task.getResult) \r\n& (  post.put(\"published\", true)\r\n     post.saveInBackground\r\n  )\r\n```\r\nWith the current high priority the RHS of the arrow would be the `for`-construct, but it should extend to the end of the code fragment. It seems that the arrow's operator priority should be very low; maybe the lowest possible priority, lower even than the newl line. At least it should be lower than the priority of `==`.\r\n\r\nAnother issue: currently there is one main dataflow operator: `x ~~> y ~/~> z', where either the left or right arrow is optional. This is a bit ambiguous, as the following expressions are all different:\r\n```\r\nx ~~> y ~/~> z\r\nx ~~> (y ~/~> z)\r\n(x ~~> y) ~/~> z\r\n```\r\nMoreover we would like to be able to chain such expressions without worrying.\r\nE.g.,\r\n```\r\n`x1 ~~> x2 ~~> x3 ~/~> z'\r\n```\r\nshould be equivalent to\r\n```\r\n`((x1 ~~> x2) ~~> x3) ~/~> z'\r\n```\r\ni.e. a dataflow pipe with `z` as fallback in case the pipe breaks down somewhere. Then we must have different syntax for the ternary use coming down to `do x then y else z`.\r\n\r\nOnother idea of specifying parameters inside the arrows has led to another idea: multiple alternatives, using extra arrows that start with `+`, as in:\r\n```\r\nx  ~~p1:P1~~> y1\r\n+~~p2:P2~~> y2           \r\n```\r\nNow we can use the same plus symbol for the ternary dataflow operator: `x ~~> y +~/~> z'.\r\n\r\nIn general the dataflow operator looks like:\r\n```\r\nx ~~a1:A1~~> y1\r\n +~~a2:A2~~> y2\r\n +~~a3:A3~~> y3\r\n+~/~e1:E1~~> z1\r\n+~/~e2:E2~~> z2\r\n+~/~e3:E3~~> z3\r\n```\r\nLet A = U Ai and E = U Ei; then this would translate to\r\n```\r\nx ~~> (a:Any) ==> a match (\r\n                    case a1:A1 ==> y1\r\n                    case a2:A2 ==> y2\r\n                    case a3:A3 ==> y3\r\n                    case _ ==> {fail(new MatchException(a))}\r\n                  )\r\n +~/~> (e:E) \r\n            ==> e match (\r\n                  case e1:E1 ==> z1\r\n                  case e2:E2 ==> z2\r\n                  case e3:E3 ==> z3\r\n                  case _ :Throwable  ==> {fail(e)}\r\n                )\r\n```\r\nThis transformation would be done by the compiler. It also translates the arrows into call scripts in DSL.scala by the names of `_dataflow_then_else`, `_dataflow_then`, `_dataflow_else`.\r\n\r\nThe match statements may probably be translated by regarding the RHS as a partial script; then the further treatment would be much like the current treatment of partial functions that handle incoming actor messages."}}