Hacker News new | ask | show | jobs
by glibgil 3293 days ago
Because reversing an array is super easy and using a library is one function call
1 comments

> Because reversing an array is super easy and using a library is one function call

It's not super easy without using library functions when all the operations that work on arrays (including the constructor that makes them) are as much “library functions” as the one that reverses an array. (Conversely, if the mechanism that reverses an array is part of the language core and not a library, the restriction fails to have the expected effect from the other side.)

The restrictions seem to assume that every language has the same division of distinct core “language” features as distinct from what is provided by libraries.

Writing the following does not use any libraries

a = [0, 1, 2]

print a[1]

That's just how arrays work. If your elements are 32 bit integers then you are establishing a pointer to the first element. Accessing an element is multiplying the index by the element size and jumping from the first element pointer to a memory address offset.

> The restrictions seem to assume that every language has the same division of distinct core “language”

Fine, if your language has a library for arrays, then reimplement it on the whiteboard. Everyone is able to do that if they know what arrays are. They are just contiguous memory