Clojure

subs function should count back from the end of the string when given negative offset

Details

  • Type: Enhancement Enhancement
  • Status: Closed Closed
  • Priority: Minor Minor
  • Resolution: Declined
  • Affects Version/s: Release 1.2
  • Fix Version/s: None
  • Component/s: None
  • Labels:
    None
  • Patch:
    Code and Test

Description

subs function should count back from the end of the string when given negative offset.

Patch attached with test and implementation.

Activity

Hide
Stuart Halloway added a comment -

A major strength of Clojure is consistency. If (foo X) works, then (foo Y) should work if X and Y are similar in relevant ways.

The negative offset convenience was considered and rejected when the string library was originally moved into Clojure. In order for a feature like this to be on the table, a proposal would need to include an evaluation of all API fns that take indexes, and a plan to either make all of them handle negative indexes, or have a meaningful rule about which ones do and which ones don't. If someone is interested in doing this, please begin with a motivating problem statement in the Design space.

That said, this feels very low priority.

Show
Stuart Halloway added a comment - A major strength of Clojure is consistency. If (foo X) works, then (foo Y) should work if X and Y are similar in relevant ways. The negative offset convenience was considered and rejected when the string library was originally moved into Clojure. In order for a feature like this to be on the table, a proposal would need to include an evaluation of all API fns that take indexes, and a plan to either make all of them handle negative indexes, or have a meaningful rule about which ones do and which ones don't. If someone is interested in doing this, please begin with a motivating problem statement in the Design space. That said, this feels very low priority.

People

Vote (0)
Watch (1)

Dates

  • Created:
    Updated:
    Resolved: