4 ms·
This has bitten me many times. In particular: Slice index expressions accept any integer type. Integer subtypes can be defined, but there is no way to define
by everybodyknows 4y ago
This has bitten me many times. In particular:
Slice index expressions accept any integer type. Integer subtypes can be defined, but there is no way to define a slice type that is legally indexed with only that defined type.
An expression a.b in some unfamiliar code may denote either a struct field access, or a pointer dereference followed by struct field access. We must read surrounding code (or lean on an IDE) to know which is meant. There was a lot to be said for C's -> operator, however unaesthetic it may appear to the eye.
- k0k0r0 4y agoAbout that slice indexing problem I wrote a bug-report for the language specification like two years ago. The language specification itself is not clear about what types can be used as indices. Accepting int32 and similiar could be regarded as a feature of the compiler. The problem was recognized (like a year later), but then claimed to be fixed and simply ignored. Immediately, I wrote a follow-up issue providing a concrete example how the spec could be improved. No response to that, yet. Now another year has passed.
- morelisp 4y agoWhat's wrong with "the index x must be an untyped constant or its core type must be an integer"? ("Integer" in turn being defined by enumeration in the "Numeric types" section.)
- morelisp 4y ago> Slice index expressions accept any integer type. Integer subtypes can be defined, but there is no way to define a slice type that is legally indexed with only that defined type. What actually-used language did this in the 70s? What other major languages offer this today? I know it's useful, but dunking on Go for features only C++ (and Rust?) have is offensively far from GP's claim.