Go Down

Topic: "Pointers make my head spin" etc ... (Read 5083 times) previous topic - next topic

Robin2

To go back to the title - my head is spinning  :)  :)

...R
Two or three hours spent thinking and reading documentation solves most programming problems.

pYro_65

#46
Jul 16, 2016, 03:14 pm Last Edit: Jul 16, 2016, 03:17 pm by pYro_65
To go back to the title - my head is spinning  :)  :)

...R
It sure is. When you get yourself straightened out, feel free to join an intelligent discussion.

Avoiding the question I asked at the top of my last post is credible evidence you are just trolling, and have been caught out in it by answering your own irrationality.
Forum Mod anyone?
https://arduino.land/Moduino/

Robin2

#47
Jul 16, 2016, 06:22 pm Last Edit: Jul 16, 2016, 06:23 pm by Robin2
See my comment at the bottom of Reply #28.

...R
Two or three hours spent thinking and reading documentation solves most programming problems.

Rupert909

The internet is a great thing. Use it.
:s/internet/mind/g
Real Programmers use ++C


Robin2

I am waiting for the sun to emerge from the mist - it is forecast to appear soon.

Let me try to re-present my question.

In Reply #35  I said
Quote
If I want to use this function call
bool RF24::write( const void * buf, uint8_t len)
I can do it like this
Code: [Select]
myRF24.write(myArray, 1);
or
Code: [Select]
myRF24.write(&myVar, 1);
Would it be possible to have written the C/C++ compiler so that these would both work
Code: [Select]
myRF24.write(myArray, 1);
or
Code: [Select]
myRF24.write(myVar, 1);

...R
Two or three hours spent thinking and reading documentation solves most programming problems.

GoForSmoke

I learned Forth before I learned C, which has pointers and is less complicated than C++ so it's been easier for me. Forth uses addresses without extra packaging.

int x;

int y[] = { 0,1,2,3,4 };

The difference between x and y is that x is a variable and y is an array of variables.
They shouldn't be treated the same.

int z = 7;

z += x;
z += y; // trying to treat array y the same as variable x, should z now == 17?

However I can treat x and y[0] pretty much the same which makes sense since both are ints.

x = 4;
y[0] = 4;

To stop the spinning I think that the spinners should learn how memory works, what addresses are and then proceed to how they are used in whatever language has them spinning.

Most confusion is due to either unknown or misunderstood knowledge. First thing to do is to clarify your understanding. I live in a country where so many people consider their ignorance as some kind of sacred, I see the need for clarity all around me every day.
1) http://gammon.com.au/blink  <-- tasking Arduino 1-2-3
2) http://gammon.com.au/serial <-- techniques howto
3) http://gammon.com.au/interrupts
Your sketch can sense ongoing process events in time.
Your sketch can make events to control it over time.

Robin2

Reply #54 does not deal with the question I posed in Reply #53

I am not asking for an explanation of how the language works. Rather I am asking could one aspect of it have been done differently if the original designers had been minded to?

As far as I can see the compiler will be perfectly well aware that myVar is a simple variable and could make the reasonable assumption that I am only interested in the value at that memory location.

...R
Two or three hours spent thinking and reading documentation solves most programming problems.

GoForSmoke

#53
Jul 21, 2016, 09:41 pm Last Edit: Jul 21, 2016, 09:41 pm by GoForSmoke
Perhaps you need caffeine or new glasses.

Quote
The difference between x and y is that x is a variable and y is an array of variables.
They shouldn't be treated the same.[\quote]

is not "how the language works".

1) http://gammon.com.au/blink  <-- tasking Arduino 1-2-3
2) http://gammon.com.au/serial <-- techniques howto
3) http://gammon.com.au/interrupts
Your sketch can sense ongoing process events in time.
Your sketch can make events to control it over time.

Robin2

Perhaps you need caffeine or new glasses.
Some of us like to wonder what might be beyond the hills.

Others are content to stay in the valley :)

...R
Two or three hours spent thinking and reading documentation solves most programming problems.

Go Up