Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2019-11-20 21:29:33

etc
Developer
Registered: 2010-11-11
Posts: 5,194
Website GitHub

Ranges

In 4.8 it will be possible to use range notations to represent consecutive (mainly numeric) values. For example, you could set Article image field to 2-6, 8 as a shortcut for 2,3,4,5,6,8. This notation is fine for positive values, but is problematic for negative ones: -6--1 looks ugly and is difficult to parse.

What symbol could possibly replace - in ranges? I use .. in some plugins: would -6..-1 or -6...-1 be ok?

Offline

#2 2019-11-20 22:45:36

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,453
Website GitHub

Re: Ranges

Double or triple dot works for me. Double if we can get away with it… means fewer characters in our limited-width database fields.


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Txp Builders – finely-crafted code, design and Txp

Offline

#3 2019-11-20 23:24:47

phiw13
Plugin Author
From: Japan
Registered: 2004-02-27
Posts: 3,196
Website

Re: Ranges

The hyphen as an indicator is very intuitive of course. Would an additional space (required) before and after the hyphen be possible? You would get something like -2 - -6 for a range between -2 and -6-.

CSS for instance forces the use of spaces before/after the hyphen, e.g. for calc() and other functions, precisely to remove any possible ambiguity with negative integers.

Otherwise, triple period would work too. Hmm, triple is more complicated to input actually, iOS and macOS tend to automatically transform or substitute it to … (horizontal ellipsis), fwiw.


Where is that emoji for a solar powered submarine when you need it ?
Sand space – admin theme for Textpattern

Offline

#4 2019-11-21 05:38:18

colak
Admin
From: Cyprus
Registered: 2004-11-20
Posts: 9,091
Website GitHub Mastodon Twitter

Re: Ranges

What about the | symbol?


Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.

Offline

#5 2019-11-21 08:11:57

gaekwad
Server grease monkey
From: People's Republic of Cornwall
Registered: 2005-11-19
Posts: 4,263
GitHub

Re: Ranges

Bloke wrote #320153:

Double or triple dot works for me. Double if we can get away with it… means fewer characters in our limited-width database fields.

Be mindful of confusion between ... and – especially where the browser or editor may substitute the former for the latter.

Offline

#6 2019-11-21 10:09:55

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,453
Website GitHub

Re: Ranges

Yeah, double dot is better, imo.

phiw13 wrote #320161:

Would an additional space (required) before and after the hyphen be possible?

That still takes up 3 characters and is subject to head-scratching (“why is it not working with 6- 13”?!) Plus it still looks odd even with the space when using negative numbers.

Since this is most likely to be used in fields with limited capacity (255 chars max) I vote for the shortest number of chars we can get away with that still conveys the meaning of something is missing where these characters are.

In terms of English usage, ellipses are used in quotations to indicate “missing” content (and also to indicate trailing-off thoughts). There is a sort-of analogue there, but as phiw13 and gaekwad point out, can be auto-corrected from three dots to ellipses, which could cause no end of confusion.

colak wrote #320164:

What about the | symbol?

Hmmm. We have traditionally used that for separating things, and it’s a common device for lists so I’d rather not use it, as it creates an exception to a well-established convention.

all

Just playing devil’s advocate here, but have we got any concrete use cases in mind where we, or someone using Textpattern, might legitimately use ranges with negative numbers? I know it’s a horrible syntax to look at -1--6 but if the number of times it’s going to be used are in the next-to-none range, is it an acceptable trade-off?


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Txp Builders – finely-crafted code, design and Txp

Offline

#7 2019-11-21 10:13:36

gaekwad
Server grease monkey
From: People's Republic of Cornwall
Registered: 2005-11-19
Posts: 4,263
GitHub

Re: Ranges

etc wrote #320151:

This notation is fine for positive values, but is problematic for negative ones: -6--1 looks ugly and is difficult to parse.

Out of curiosity: what’s a real-world example of a negative range in Textpattern terms? Bullet point is fine, I’m clearly missing something obvious.

Offline

#8 2019-11-21 10:15:30

gaekwad
Server grease monkey
From: People's Republic of Cornwall
Registered: 2005-11-19
Posts: 4,263
GitHub

Offline

#9 2019-11-21 10:17:23

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,453
Website GitHub

Re: Ranges

gaekwad wrote #320169:

Out of curiosity: what’s a real-world example of a negative range in Textpattern terms?

Snap! :)


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Txp Builders – finely-crafted code, design and Txp

Offline

#10 2019-11-21 10:19:50

gaekwad
Server grease monkey
From: People's Republic of Cornwall
Registered: 2005-11-19
Posts: 4,263
GitHub

Re: Ranges

Bloke wrote #320171:

Snap! :)

I must be half asleep. Did you sneak in a ninja edit or did I miss that last sentence?

Offline

#11 2019-11-21 10:22:17

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,453
Website GitHub

Re: Ranges

Good find, Pete. I actually quite like the square-bracket notation, even though it is up to three extra chars.

12, 14, 5, [42, 48], 73, [-1,-6]

Encapsulated, and permits an optional space after the comma as well, if you have the capacity in your field to use it (although the lack of space does make it more visually distinct). Plus it’s fairly easy to parse.

Is it intuitive enough? Thoughts?

Last edited by Bloke (2019-11-21 10:26:20)


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Txp Builders – finely-crafted code, design and Txp

Offline

#12 2019-11-21 10:23:25

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,453
Website GitHub

Re: Ranges

gaekwad wrote #320172:

I must be half asleep. Did you sneak in a ninja edit or did I miss that last sentence?

Hehe, no ninja edit (for a change!)

Köffee? :)


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Txp Builders – finely-crafted code, design and Txp

Offline

Board footer

Powered by FluxBB