Hello guys,
I have small question to discuss (sorry if it was already brought up, couldn't
find it on the lists) - wouldn't it be nice to make Gremlin (or rather GLVs) a
bit more type safe?
Lets consider Gremlin java for example. After each step we return
GraphTraversal which contains all available Gremlin steps. So we can write
something like 'g.V().out().by("name")' which will produce CCE. What if we
would return not GraphTraversal (with all steps) but rather interface with
subset of steps which are relevant after last one.
For example after Modulating steps return Traversal with common steps and By
steps:
default <E2> ByModulatingGraphTraversal<S, Map<String, E2>> project(final
String projectKey, final String... otherProjectKeys) {
...
return (ByModulatingGraphTraversal) this.asAdmin().addStep(new
ProjectStep(...));
}
where:
interface BaseWithByTraversal extends BaseGraphTraversal,
ByModulatingGraphTraversal {}
interface BaseGraphTraversal<S, E> extends Traversal<S, E> {
// common steps
}
interface ByModulatingGraphTraversal<S, E> {
// by stesps
default BaseWithByTraversal<S, E> by() { ... }
default BaseWithByTraversal<S, E> by(final Traversal<?, ?> traversal) { ...
}
...
}
or even:
default <E2, G extends BaseGraphTraversal<S, E2> & ByModulatingTraversal<S,
E2>> G project...
It can be useful in several cases:
1) by modulating steps -> By steps
2) order -> By (with order direction)
3) configuring steps -> with + common steps
4) addE -> to/from + common
5) io -> read / write
6) path -> from/to + common
7) ...
I realize that this is breaking (destroying?) change with relatively low
benefit. So maybe at least it is something to consider for TinkerPop4?
Thanks and regards,
-Yura
P.S. sorry for poorly formatted long message
P.S.S. we have VerificationStrategies but its run time vs compile time
P.S.S.S. this question was inspired by jOOQ (https://github.com/jOOQ/jOOQ)
which allows to write type safe SQL in Java