Comments (7)
I can see that sometimes an infix operator form may feel more natural as it gets less in the way of the intent of an expression. Scala uses OR ELSE
for chaining options, perhaps that would work here?
expr1 OR ELSE expr2 OR ELSE expr3
Alternatively, we could decide to spend an operator for this but the downside of that would be that it is much harder to read that without knowing it and it seems to small an issue to spend a special character on. If we go down that route, ?
might be a natural character to use since it is also used in the type system to indicate nullability.
from opencypher.
I don't think having two ways of spelling the same thing is beneficial, it only creates more things to learn in the language without any benefit. It would be better to instead propose changing the name of coalesce
to something shorter, at which point I think nvl
is a really poor proposal since that name doesn't provide a direct insight into what the operator does, it is another thing one has to learn by heart, which adds to the complexity of the language.
I'm not saying coalesce
is a perfect word, the effect of the operator is not a perfect match for the dictionary definition of the word, but it is an actual word and it hints in the direction of what the operator does, and manages to do that while being pretty short. If we can come up with a word that does a better job by those criterions, changing it would probably be a great idea.
Just my 2ยข.
from opencypher.
@thobe I see your point about confusion in having two functions that do the same thing. Although the word coalesce
is in the dictionary, however, it's not a common word that you'd use every day. I know to use this function because it's common in other databases (ANSI standard), but other than that I wouldn't think to search for a function with this name.
Databases tend to require more special null
handling since null
doesn't equal null
like in some languages. The point of the ticket was to consider a shorthand since it could be used quite often.
It's commonplace for many languages to offer a shorthand for this, such as the elvis operator ?:
See here for examples: https://en.wikipedia.org/wiki/Null_coalescing_operator
from opencypher.
That being said it was something raised in passing slack conversation and not a burning issue ;-)
from opencypher.
How about |
?
So instead of COALESCE(v1, v2, v3 ...)
you could do v1|v2|v3...
. Since OR
is used for boolean arithmetic, the use of |
would not conflict with anything. And the syntax would read "v1 or v2 or v3, whichever comes first as non-null".
from opencypher.
Updated the original comment to include the name of the CIR
from opencypher.
Throwing in some more operator suggestions: v1 // v2 // v3
or v1 :+: v2 :+: v3
(monoidal combine operator)
from opencypher.
Related Issues (20)
- Deleting the relationship for the dynamic labels in UNWIND HOT 1
- Issue in UNWIND option for duplicate records HOT 2
- Performance is very poor for the create/update relationships HOT 1
- Any plan to release Cypher 10? HOT 3
- Beta version missing dependency ?
- Problem parsing oC_MultiPartQuery with ANTLR4 HOT 3
- OpenCypher Antlr - strange parse tree (c#) HOT 3
- Improve the use of lists stored as property HOT 3
- missing children from `OC_ComparisonExpressionContext` in cpp-runtime of ANTLR HOT 2
- Incomplete EBNF Grammar HOT 9
- NULL token name is a reserved word in C++ HOT 2
- MANDATORY MATCH HOT 3
- Invalid syntax HOT 3
- Commit the .ebnf output into the repo HOT 1
- User defined function in custom namespace parsed as property lookup if function name is a keyword HOT 3
- Validating ``WHERE (value in property)``
- TCK only published with features
- RedisGraph: EOL
- Question on Semantics of WITH clause HOT 1
- Grammar HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. ๐๐๐
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google โค๏ธ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from opencypher.