[ 
https://issues.apache.org/jira/browse/TINKERPOP-3055?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17947121#comment-17947121
 ] 

ASF GitHub Bot commented on TINKERPOP-3055:
-------------------------------------------

andreachild commented on code in PR #3099:
URL: https://github.com/apache/tinkerpop/pull/3099#discussion_r2058984158


##########
gremlin-javascript/src/main/javascript/gremlin-javascript/lib/structure/io/binary/internals/ClassSerializer.js:
##########
@@ -0,0 +1,63 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+
+/**
+ * @author Igor Ostapenko
+ */
+'use strict';
+
+const { TraversalStrategy } = 
require('../../../../process/traversal-strategy');
+const { Buffer } = require('buffer');
+
+module.exports = class ClassSerializer {
+  constructor(ioc) {
+    this.ioc = ioc;
+    this.ioc.serializers[ioc.DataType.CLASS] = this;
+  }
+
+  canBeUsedFor(value) {
+    return (
+      typeof value === 'function' &&
+      !!value.prototype &&
+      !!value.prototype.constructor.name &&
+      new value() instanceof TraversalStrategy

Review Comment:
   Would this be better so you don't have to instantiate?
   
   ```
   TraversalStrategy.prototype.isPrototypeOf(value.prototype)
   ```





> withoutStrategies() mechanism in programming languages for providers
> --------------------------------------------------------------------
>
>                 Key: TINKERPOP-3055
>                 URL: https://issues.apache.org/jira/browse/TINKERPOP-3055
>             Project: TinkerPop
>          Issue Type: Improvement
>          Components: dotnet, go, javascript, process, python
>    Affects Versions: 3.7.1
>            Reporter: Stephen Mallette
>            Priority: Major
>
> {{withoutStrategies()}} is in the grammar for TINKERPOP-2862. That change did 
> not address its accessibility for provider strategies in language variants 
> very well. As the syntax requires a {{Class}} (and for the grammar, a 
> registered strategy class) you may not have that reference in a language 
> variant. Users could create dummy classes as the grammar works on simple 
> name, but that's not especially nice. Otoh, most users shouldn't be tinkering 
> with strategies so perhaps that's ok? It could be inconvenient for notebook 
> users and similar tools though to create the dummy. A simple alternative 
> could just be a {{withoutStrategies(String...)}} but that's not particularly 
> nice. Other ideas?
> needs a general look at all strategy construction across all languages:
> 1. check if the strategy construction makes sense in terms of types and 
> syntax in each language
> 2. watch out for wrong types being parsed into {{Configuration}} which can 
> lead to weird looking errors. 
> 3. are there adequate tests to validate all our syntax is working. we 
> technically need to test every strategy configuration options as those 
> corners are where bugs can hide.
> 4. double check {{List}} vs {{Set}} syntax because {{Set}} might be preferred 
> but a lot of folks will reach for {{[ ]}} just out of habit....do we want 
> them failing for that? can we ease the type there without losing {{Set}} in 
> type safe languages?



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to