Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

> So in Lua the "first" element has an index of 1. There's absolutely nothing wrong with this.

I’m beginning to wonder whether a language that doesn’t have indexes at all would be viable.

Swift abandoned C-style for loops (https://github.com/apple/swift-evolution/blob/main/proposals...)

It still has enumerated (https://developer.apple.com/documentation/swift/sequence/enu...()), though.

That’s a special case of zip, though, and programs could use

  zip(items, 0...Int.max)
or

  zip(items, 1...Int.max)
according to their preference.

Also, slices could be created using

  items.subrange( skip: 3, take: 5)
instead of

  items.subrange( startIndex: 3, numItems: 5)
Implementation-wise, those are identical, but conceptually, the first doesn’t use indexes


Consider applying for YC's Summer 2026 batch! Applications are open till May 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: