mastodontech.de ist einer von vielen unabhängigen Mastodon-Servern, mit dem du dich im Fediverse beteiligen kannst.
Offen für alle (über 16) und bereitgestellt von Markus'Blog

Serverstatistik:

1,5 Tsd.
aktive Profile

#pointers

0 Beiträge0 Beteiligte0 Beiträge heute

I would claim that I'm *very* experienced with #programming in #C. But still, C gets annoyingly weird when it comes to #pointers *to* #arrays.

Does the following code look sober to you? 🤔 (My compiler doesn't complain)

Especially interested in the highlighted line, but also the block above trying to expand the array ...

Context: I started work on a generic/configurable rate-limiter to add to #swad.

I would claim that I'm *very* experienced with #programming in #C. But still, C get's annoyingly weird when it comes to #pointers *to* #arrays.

Does the following code look sober to you? 🤔 (My compiler doesn't complain)

Especially interested in the highlighted line, but also the block above trying to expand the array ...

Context: I started work on a generic/configurable rate-limiter to add to #swad.

TIL: C array subscript operators are handled in such a way that `letters[i]` is equivalent to `*(letters + i)` and because addition is commutative, that expression is identical to `*(i + letters)`, which means that `i[letters]` is the same as `letters[i]`.

```
#include <stdio.h>
#include <stddef.h>

int main() {
char letters[3] = "abc";
size_t i = 2;
printf("letters: %p\n", (void *)&letters);
printf("i[letters] (%p): %c\n", (void*)&(i[letters]), i[letters]);
printf("letters[i] (%p): %c\n", (void*)&(letters[i]), letters[i]);
return 0;
}
```

Which outputs:
```
letters: 0x7ffc68ec7bb9
i[letters] (0x7ffc68ec7bbb): c
letters[i] (0x7ffc68ec7bbb): c
```

Mind blown... :neofox_floof_explode:
#til #clang #pointers #programming

Three Libraries for the Python-kings under the ML sky,
Seven for the C++-lords in their halls of hackerone,
Nine for Mortal Frontenders doomed to DROP BY,
One libc on his dark throne;
In the Land of Pointers where the void * lie.
One Library to rule them all, one Library to find them,
One Library to bring them all, and in the pointer arithmetics bind them;
In the Land of Pointers where the void * lie.

no matter how many docs I read, no matter how many stackoverflow/reddit/whatever posts I read, no matter how many videos I watch to try to understand the concept,

i just cannot fucking grasp the usage of pointers in golang.

i 100% understand what they are (memory addresses) and the benefits of using them (use address where data is instead of copying or passing around all the actual data). but none of that knowledge helps me develop a "muscle memory" for the ways * and & are used when reviewing pull requests or existing code.

I have no prior experience with pointers in any other language, so comparisons to C aren't helpful.

anyone else ever struggle really fucking hard with pointers in golang, no matter how much you "academically" understand what they are? any resources or exercises that might help it "click" for me?

Scientists May Have Solved The Mystery Of How The Andes Got So Big
--
sciencealert.com/scientists-ma <-- shared article
--
doi.org/10.1016/j.epsl.2023.11 <-- shared paper
--
[although my postgrad was in geology and I am licensed in the field, it has been a number of years since I worked directly in a geologic discipline; that said, I very much like to try and keep up with ‘things geology’…]
#GIS #spatial #mapping #geology #southamerica #data #modeling #model #mathematics #mathematicalmodeling #structuralgeology #andes #chile #peru #platetectonics #tectonics #tectonic #movement #mountain #mountainbuilding #remotesensing #geologists #orogeny #vulcanism #pointers #APM #RPM