Re: New "cut" operator (was: Pike 8.0 RC1)
Martin Bähr <[email protected]>
| Newsgroups | gmane.comp.lang.pike.user |
|---|---|
| Message-ID | <[email protected]> |
Excerpts from Peter Bortas's message of 2014-11-16 14:40:39 +0100:
> > ("cut left example"<<" ")=="left example"
> > ("cut left example">>"ex")=="cut left "
>
> NAK. It's a very specific and unobvious use of an operator that
> conflict both with both the (unfortunately) adopted C++ iostream
> syntax and the more obvious mathematical "much greater|lesser than".
well, it's kind of left-shift and right-shift for bits.
still somewhat unobvious, because obvious would be a number of positions to
shift which is not much different from array indexing:
"cut left example" << 4 == "left example" == "cut left example"[4..]
if string|array << int is defined as shift by that number of characters then
string << string could be defined as shift to the first occurrence of that string.
but with that definition i'd expect
"cut left example" << " " == " left example"
because it should be equivalent to:
"cut left example" << search("cut left example", " ");
more interesting would be a form of split where only the first occurance (or
the last) is split away, and both parts are returned.
greetings, martin.
--
eKita - the online platform for your entire academic life
--
chief engineer eKita.co
pike programmer pike.lysator.liu.se caudium.net societyserver.org
BLUG secretary beijinglug.org
foresight developer foresightlinux.org realss.com
unix sysadmin
Martin Bähr working in china http://societyserver.org/mbaehr/