You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit fe823bd
Browse filesBrowse the repository at this point in the historyBrowse files
It reads backwards and gets us lost in silly parens, but is otherwise pretty close to what we wanted. Take a minute to look at the code. Can you see any ways to improve it?
103
103
@@ -508,7 +508,7 @@ produces output in one-to-one correspondence with the grandchildren:
508
508
509
509
```javascript
510
510
g.v('Thor').in().in().out().out().unique().run()
511
-
```
511
+
```
512
512
513
513
The pipetype implementation:
514
514
@@ -924,7 +924,7 @@ There are a couple of tradeoffs with this approach: one is that spatial performa
924
924
925
925
This second point isn't usually an issue, because of the phase separation between when our compiler runs its optimizations and when all the thunking occurs at runtime. In our case we don't have that advantage: because we're using method chaining to implement a fluent interface [^fluentinterface] if we also use thunks to achieve laziness we would thunk each new method as it is called, which means by the time we get to `run()` we have only a thunk as our input, and no way to optimize our query.
926
926
927
-
[^fluentinterface]: Method chaining lets us write `g.v('Thor').in().out().run()` instead of a series of statements that accomplish the same thing.
927
+
[^fluentinterface]: Method chaining lets us write `g.v('Thor').in().out().run()` instead of the six lines of non-fluent JS required accomplish the same thing.
928
928
929
929
Interestingly, our fluent interface hides another difference between our query language and regular programming languages. The query `g.v('Thor').in().out().run()` could be rewritten as `run(out(in(v(g, 'Thor'))))` if we weren't using method chaining. In JS we would first process `g` and `'Thor'`, then `v`, then `in`, `out` and `run`, working from the inside out. In a language with non-strict semantics we would work from the outside in, processing each consecutive nested layer of arguments only as needed.
930
930
@@ -1331,7 +1331,7 @@ after the query transformers have all run. We could run the `times` transformer
0 commit comments