-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve dataflow arrows #73
Comments
Later we may increase the expressiveness for the arrows holding parameters. Since these are translated into cases in a match statements, all things should be allowed that are normally allowed between the word E.g.,
|
When inspecting the parser code I noticed that the |
Re: Priorities.
So, just like in the first use case, at the top of this issue, the arrows should have very low priority.
or
Here the dataflow arrow must have a very high priority; higher than the white space operator, since the arrow should be here an operand of the white space operator. In fact, it seems that we could well use 2 variations of the data flow arrows, like with sequence operators: long arrows having low priority (even lower than new lines), and short arrows with high priority (higher than white space). |
RE: the first use case in this thread.
The problem is the structure of the LHS of the arrow: a sequence; we could define that the result value by default of such a sequence is the result of the last element, and then this should be propagated to the lambda that is implicitly around this sequence, passed as a parameter to the method that is generated for the arrow. |
Data flow arrows
~~>
and~/~>
(for Throwables) are rather new in SubScript.A recent use case revealed that the operator priority needs to change:
With 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==
.Another 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:Moreover we would like to be able to chain such expressions without worrying.
E.g.,
should be equivalent to
i.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 todo x then y else z
.Onother idea of specifying parameters inside the arrows has led to another idea: multiple alternatives, using extra arrows that start with
+
, as in:Now we can use the same plus symbol for the ternary dataflow operator: `x ~~> y +
/> z'.In general the dataflow operator looks like:
Then this would translate to
This 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
.The PartialFunction on the RHS is in fact a partial script; its treatment would be much like the current treatment of partial functions that handle incoming actor messages.
Note that the result of the partial script should be the result of the chosen branch. And other rules are:
x ~~> y +~/~> z
is the result ofy
orz
, whenever either one of these two succeeds or fails (note thaty
may be chosen multiple times, andz
at most once).x ~~> y
is set to the result ofy
when that succeeds or fails, or to the result ofx
when that fails.x ~/~> z
is set to the result ofx
when this succeeds or ofz
when that succeeds or fails.Most of this work seems relatively simple; I am not sure about the last parts (translating match expressions and setting the result value).
The gain would be big: dataflow operators would work almost completely (except for some compile time type checking), and lots of nice use cases will benefit, such as the Twitter Search example.
The text was updated successfully, but these errors were encountered: