&foo[bar] or (foo + bar) ?
-
that's exactly what &foo[bar] does. Literally it reads as take the address of the bar element of foo.
Check out my IoT graphics library here: https://honeythecodewitch.com/gfx And my IoT UI/User Experience library here: https://honeythecodewitch.com/uix
-
what is your preference? I'm guessing some people prefer
&foo[bar]
because they may find the intent to be expressed more clearly. I find(foo + bar)
to be more succinct with less steps, and therefore clearer to me.Check out my IoT graphics library here: https://honeythecodewitch.com/gfx And my IoT UI/User Experience library here: https://honeythecodewitch.com/uix
-
I used to write things like 2[array] to wind up certain colleagues. (Often the ones that insisted on putting the constant on the LHS of a comparison operator.)
Software rusts. Simon Stephenson, ca 1994. So does this signature. me, 2012
-
I used to write things like 2[array] to wind up certain colleagues. (Often the ones that insisted on putting the constant on the LHS of a comparison operator.)
Software rusts. Simon Stephenson, ca 1994. So does this signature. me, 2012
-
what is your preference? I'm guessing some people prefer
&foo[bar]
because they may find the intent to be expressed more clearly. I find(foo + bar)
to be more succinct with less steps, and therefore clearer to me.Check out my IoT graphics library here: https://honeythecodewitch.com/gfx And my IoT UI/User Experience library here: https://honeythecodewitch.com/uix
-
Did you intend to put an 'Enter' between 'foo' and 'bar'? If the comma was intended as an 'Enter', I guess that the comma between, 'bar' and '+' would have fouled it up.
That is wrong, yes ... I was letting it slide because I was so late in on the thread that I figured no one would notice. Is it me or has the complexion of such changed lately? Anyway. What I meant to type was "foo,bar+". I'm no programmer just an antique calculator button presser. :sigh:
-
what is your preference? I'm guessing some people prefer
&foo[bar]
because they may find the intent to be expressed more clearly. I find(foo + bar)
to be more succinct with less steps, and therefore clearer to me.Check out my IoT graphics library here: https://honeythecodewitch.com/gfx And my IoT UI/User Experience library here: https://honeythecodewitch.com/uix
One of the things that pisses me off in this book I bought about programming GPUs is that he presents so called "pseudocode" example for presenting his solutions. This pseudocode makes extensive use of C style pointer arithmetic, such as (foo + bar) without a word of mention; the reader is supposed to understand what it means, regardless of his programming background or preferred language. I do have enough background to understand it when I see it. But I see pseudocode as abstracted above one specific programming language, not just as an excuse for ignoring specific requirements of one chosen language. (foo+bar) is something you'll never find in any comparable language. It doesn't belong in any abstracted pseudocode. So does it belong in concrete code in one specific language? Well, if you strive to establish a tribal code, to distinguish between those who are in and those outside, this may be one of your tools. Those who say 'But that is an array, FGS! - Why don't you treat it as one?' - and recoil in horror. Maybe those could have been good developers for your project.
-
That's not really a trick. It's "get me the address of the Nth array element." It's just another way of writing (foo + bar); If you insist on not mixing pointer and array ops than you'd be stuck with the very syntax you don't like in order to get the address of an array element, unless there's a 3rd way to do it I'm not considering?
Check out my IoT graphics library here: https://honeythecodewitch.com/gfx And my IoT UI/User Experience library here: https://honeythecodewitch.com/uix
honey the codewitch wrote:
It's just another way of writing (foo + bar);
yes I know.
honey the codewitch wrote:
If you insist on not mixing pointer and array ops
Not sure what you mean. If I create an array of pointers then I would use it like an array. If I create a pointer to memory that contains sequential blocks (regardless of type) then I would use it like a pointer. The fact that syntactically the access is the same and tradable is not a consideration.
-
honey the codewitch wrote:
It's just another way of writing (foo + bar);
yes I know.
honey the codewitch wrote:
If you insist on not mixing pointer and array ops
Not sure what you mean. If I create an array of pointers then I would use it like an array. If I create a pointer to memory that contains sequential blocks (regardless of type) then I would use it like a pointer. The fact that syntactically the access is the same and tradable is not a consideration.
jschell wrote:
Not sure what you mean.
I mean this
jschell wrote:
If I create an array of pointers then I would use it like an array. If I create a pointer to memory that contains sequential blocks (regardless of type) then I would use it like a pointer
So I think somewhere we started talking past each other.
Check out my IoT graphics library here: https://honeythecodewitch.com/gfx And my IoT UI/User Experience library here: https://honeythecodewitch.com/uix