Literal collections in Cypher - feedback wanted!

22 views
Skip to first unread message

Andres Taylor

unread,
May 8, 2012, 5:33:14 AM5/8/12
to neo4j
Hey amigos,

The Range feature is important, but it doesn't feel right as a function. I want to turn it into a literal expression instead. How would that look?

Groovy:
inclusive 5..8
exclusive 5>..<8

Scala:
inclusive 5 to 8
exclusive 5 until 8
inclusive, step 3 5 to 81 by 3

Ruby:
inclusive 5..8
exclusive 5...8

Lucene:
inclusive [5 TO 8]
exclusive {5 TO 8}

????
inclusive [5..8]
exclusive ]5..8[

WDYT? And, is step an important to make this useful?

Andrés

Michael Klishin

unread,
May 8, 2012, 6:22:23 AM5/8/12
to ne...@googlegroups.com
Andres Taylor:

> WDYT? And, is step an important to make this useful?

Step is relatively rarely used in my experience. Ruby's literal is the least noisy. Scala's approach
would work if Cypher was all similar to "point free Scala" but it's not.

What about

[1.0,2.0]
[1.0,2.0)

and so on?

I personally wouldn't mind having range as a function.

MK


Nigel Small

unread,
May 8, 2012, 8:06:52 AM5/8/12
to ne...@googlegroups.com
I like the [a,b) notation from a mathatical point of view but it's potentially unfamiliar notation to some (and may cause havoc in a text editor with bracket matching!). I agree that the ellipsis notation is cleanest but the difference between ".." and "..." isn't necessarily intuitive to non-Ruby programmers.

Keeping range as a function would seem to be the best lowest common denomiator and IMHO would adhere to the principle of least surprise. But maybe that's my Python head talking :-)

Reply all
Reply to author
Forward
0 new messages