Slicing, not as modern as you thought
Jonathan M Davis
newsgroup.d at jmdavisprog.com
Sun Jul 7 21:34:52 UTC 2019
On Sunday, July 7, 2019 8:12:05 AM MDT Patrick Schluter via Digitalmars-d
> After watching this retro-computing video  I was quite
> surprised to discover that the lowly Sinclair ZX81 already
> implemented slicing in its Basic string handling. The syntax was
> of course typical Basic ad hoc, but it seem to work quite nicely.
> X$(1) would get the first character of string X$
> X$(2 TO 4) would give the substr from offset 2 to 4
> the interesting part is that it works also as lvalue so you could
> overwrite part of strings that way
> X$(2 TO 4) = "ab"
> Nice. I would have loved that at that time but neither
> TI-(Extended)-Basic nor Microsoft derived Basics (Applesoft) and
> later basics (GFA, Quick etc.) had this feature.
> So thank you Walter Bright for reinventing something that was
> unfortunately lost in time.
> : https://www.youtube.com/watch?v=_d2g5BXdyfU&t=1811s
I don't think that Walter has ever claimed to invent it. IIRC, he got it
from Pascal, though https://en.wikipedia.org/wiki/Array_slicing doesn't list
Pascal as one of the languages with array slicing (personally, I haven't
used Pascal enough to recall whether it has it or not). It does list perl
and python though, and IIRC, some of the stuff in D was inspired by those
languages. A lot of things in D actually come from other languages having
them and Walter incorporating them or someone else proposing them and having
them incorporated into D. Even ranges don't originate with D (Andrei got the
idea from someone else), though I'm not aware of any other languages that
used them like we do prior to D. Some stuff was invented for D, but most of
it ended up in D by trying to take the best of ideas from elsewhere. I'm
sure that plenty of those ideas are new to people coming to D though, since
a lot of programmers have only used a few languages.
- Jonathan M Davis
More information about the Digitalmars-d