Arc Forumnew | comments | leaders | submit | immanuel's commentslogin

"asdfa"[4..-3] ??? "asdfa"[9 -20] ?? "asdfa"[0..-0] ?? Only seems to make reasoning about code more difficult in return for brevity. Helpful for programmers whose main productivity obstacle is typing speed.

-----

1 point by sjs 6176 days ago | link

"aoeui"[3:1] ??? "aoeui"[12:42] ?? "aoeui"[0:0]

With or without negative indices one can do pointless things with slicing/subseq. Returning an empty string/list is the only sane thing to do in those cases.

    >>> s="aoeui"
    >>> s[3:1]
    ''
    >>> s[4:-3]
    ''
    >>> s[9:-20]
    ''
    >>> s[0:-0]
    ''
    >>> s[12:42]
    ''

-----

1 point by mec 6176 days ago | link

Why not return the reverse when going backwards within bounds?

    >>> s="aoeui"
    >>> s[3:1]
    "eoa"
    >>> s[4:-3]
    "ue"
    >>> s[9:-20]
    ''
    >>> s[0:-0]
    'a'
    >>> s[12:42]
    ''

-----

2 points by sjs 6175 days ago | link

That is too magic for my taste. [0:-0] returning the first char is madness. That should be '' no matter what, as 0 == -0 on modern cpus (thankfully).

-----

6 points by noahlt 6176 days ago | link

It just takes getting used to, like prefix notation.

-----


I would like to use numbers in various encoding like reversed (bigendian on little endian machines and vice versa). I also want the language to natively support all these number encondings and to be able to add two numbers, given their encodings.

-----