Array indices start at 0 in C, but start at 32 in F.
All the math geeks: “but what about R???”

@jfbastien 459.67.

I'd make a joke about doing a for loop over floats, but I've been doing a lot of graphics dev lately...

@jfbastien ok fine, Array indices start at 0+0i in C and 0 in R
@jfbastien I wonder if F# has proper imperial arrays available

@jfbastien ASCII is Imperial*, makes sense 🤔

* Printable codes start from 32 / 0x20

@jfbastien .. that's why my Fortran code was never working...
@jfbastien i measure my temperatures in radians fahrenheit :3
@jfbastien Does this mean they start at about 10.67 in D?
@jfbastien Must be a 5x9 array.
@jfbastien it's efficient because it's a power of 2 🤔
@regehr spoken like a true ‘merican!
@jfbastien that’s why no one uses C# or F# which raise this by a semi tone
@jfbastien
does that mean the arrays in R explode at [80] ?

@jfbastien Makes about as much sense as arbitrarily assigning temperature scales to water freezing and boiling points.

Of course... that would also mean that if you're at 1,500m elevation your index would have to be a float since water boils at 95.06º C

@jfbastien It’d make more sense to compare with JavaScript. Where arrays can be indexed by a real value instead of just an integer. 🤣
@jfbastien
So they have space for them?
@jfbastien @cstross this sounds like something intercal would do
@beka_valentine @jfbastien Nah, Perl 4 had the $[ operator to redefine the array base index. (I believe one of the later Perl 5 releases deprecated it and Raku just said "nope". Spoilsports!)
@cstross 5.12 deprecated it, 5.30 made it mostly constant ($[ = 1 is a runtime error now)
@beka_valentine @jfbastien

@dakkar @cstross @beka_valentine @jfbastien

FMTYEWTK about the history of $[:

  • 1987-12-18: perl 1.0 is released, featuring the $[ special global variable that lets you change the array base index whenever you want. (Mainly, I suspect, to make life easier for a2p, the awk-to-perl translator also included in the release, because array indices start at 1 in awk.)

  • 1994-10-17: perl 5.0 is released. It still supports $[ (and a2p), but the semantics of $[ have changed: It is no longer a real variable; instead, assignment to $[ is treated as a compiler directive that affects the current file only. Now module authors don't have to worry about someone else changing $[ at runtime. The documentation describes its use as "discouraged".

  • 2000-03-22: perl 5.6.0 is released. No real change to $[, but its documentation now calls it "highly discouraged".

  • 2007-12-18: perl 5.10.0 is released. The semantics of $[ are tightened further: Assignment to $[ only affects the current lexical scope, not the whole file it is in, bringing it in line with other compiler pragmas (use strict, use warnings, etc).

  • 2010-04-12: perl 5.12.0 is released. $[ is formally deprecated (it was only "highly discouraged" before). a2p no longer generates code that sets $[.

  • 2012-05-20: perl 5.16.0 is released. The implementation of $[ has been pulled out of the perl core proper; it is now provided by the arybase extension module. Also, any code that does use v5.16 (to both require at least perl version 5.16 and opt into all the new features provided by perl 5.16) no longer has access to $[: Reading from it always returns 0; assigning a non-zero value to it is a compiler error.

  • 2015-06-01: perl 5.22.0 is released. It no longer includes a2p, which has been moved to its own CPAN distribution (App::a2p).

  • 2019-05-22: perl 5.30.0 is released. 25 years after its use was "(highly) discouraged" and 9 years after its formal deprecation, $[ has been effectively removed. (The use v5.16 semantics of $[ are now always on: Assigning 0 to $[ has no effect; assigning anything else is a compiler error.) The arybase module no longer exists.

Bill the Lizard (@[email protected])

"Should array indices start at 0 or 1? My compromise of 0.5 was rejected without, I thought, proper consideration." — Stan Kelly-Bootle

Hachyderm.io
@jfbastien This is not accurate. Indices always start at 0, but in F array elements <32 are frozen.
Dario$ (@[email protected])

Allegato: 1 immagine #programming #meme #software #computerscience

Mastodon Uno Social - Italia
@jfbastien ohhhhh programming joke that if you don't know programming you think it is about temperature.

@jfbastien Everyone talks about off-by-one errors but nobody talks about the off-by-thirty-two errors.

And whatever happened to F++ ??