You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tinkerpop.apache.org by "Florian Hockmann (Jira)" <ji...@apache.org> on 2021/10/20 13:52:00 UTC
[jira] [Commented] (TINKERPOP-1853) Use generic version of
ITraversal for arguments in Traversal API
[ https://issues.apache.org/jira/browse/TINKERPOP-1853?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17431251#comment-17431251 ]
Florian Hockmann commented on TINKERPOP-1853:
---------------------------------------------
I've spent some time working on this but now I'm not sure any more whether it's actually feasible to get a working implementation that still allows the {{DotNetTranslator}} to produce valid C# traversals. One example where I noticed this in our test suite is this overload:
{code:c#}
public GraphTraversal<S, E> To (ITraversal toVertex) {code}
which I would now like to change into:
{code:c#}
public GraphTraversal<S, E> To (ITraversal<Vertex> toVertex) {code}
I think that is a nice improvement for most use cases as it still allows something like {{To(__.V())}} or {{To(__.AddV())}} but we cannot produce working code with the translator for something like {{to(__.select('v'))}} as the translator would need to translate this into {{To(__.Select<Vertex>('v'))}}. However, I don't know how we could change the translator to use the correct generic type parameter for {{Select}} here without making it a lot more complex. (Right now, it always uses {{object}} as the type parameter which works without these changes.) It would at least need to inspect what kind of type the outer step needs (here {{To()}} needs an {{ITraversal<Vertex>}}). The translator however only operates on {{Bytecode}} which doesn't have such type information.
This is now only for the {{To()}} step but I think that the same could apply for most if not all steps that take a traversal as an argument.
While this seems to be a nice improvement in my opinion as it would reduce the need to provide generic type parameters in some places and make it harder to produce invalid {{Bytecode}} from Gremlin.NET, I'm not sure any more if it's really worth the effort given the problems with the {{DotNetTranslator}}. I'm however open for any suggestions here. So, I pushed my current changes which at least result in a clean build as a WIP here: [https://github.com/apache/tinkerpop/tree/TINKERPOP-1853]
If nobody has a good idea how the problem with the code translation could be solved, then I'll probably close this as _won't do_.
> Use generic version of ITraversal for arguments in Traversal API
> ----------------------------------------------------------------
>
> Key: TINKERPOP-1853
> URL: https://issues.apache.org/jira/browse/TINKERPOP-1853
> Project: TinkerPop
> Issue Type: Improvement
> Components: dotnet
> Affects Versions: 3.3.0, 3.2.6
> Reporter: Florian Hockmann
> Assignee: Florian Hockmann
> Priority: Minor
>
> Currently, we use {{ITraversal}} as the type for arguments in the traversal API of Gremlin.Net when a traversal is expected:
> {code}
> public GraphTraversal< S , E2 > Choose<E2> (ITraversal traversalPredicate, ITraversal trueChoice)
> {code}
> The Java equivalent is more useful as it only allows {{Traversal<?, E2>}} for the second argument:
> {code}
> public default <E2> GraphTraversal<S, E2> choose(final Traversal<?, ?> traversalPredicate, final Traversal<?, E2> trueChoice)
> {code}
> We should also use the generic type {{ITraversal<object, E2>}} in Gremlin.Net in those cases. Then it wouldn't be necessary to specify the type for the arguments and the step as it can be interfered from the type of the arguments.
--
This message was sent by Atlassian Jira
(v8.3.4#803005)