|
As I understand it declarations are written as if operators e.g. you would write "name[123]" to access the 123'rd element in the array named "name" so that's how it is declared. Maybe it should be "[123]name".
|
|
|
|
|
You seem to be talking about accessing the array, not declaring it. I'm talking about declaring it.
Edit: Or if you are, then I think get your point? My response would be that pointers aren't declared like pointer operations.
Real programmers use butterflies
|
|
|
|
|
They aren't? I would declare a pointer using the rules of operator precedence always starting with the identifier e.g. "char* name" and utilize it as an operator as "*name" so except for the white space and the casting operator "char" which is no longer needed they are the same. Cheerios
|
|
|
|
|
I think we're misunderstanding each other. My OP maybe wasn't as clear as it should have been.
I've always declared pointers with the * next to the type. You CANNOT declare arrays that way. Hence my complaint.
Real programmers use butterflies
|
|
|
|
|
Greetings My point is that if you accept the rules of operator precedence and associativity which I am assuming you do than you must accept the rules of declaration since they are identical. Otherwise you must argue against both and insist e.g. that array elements be referenced as "[123]name" or pointer targets as "name*". Or perhaps you would argue that the rules of declaration be different from the rules of operation but that would complicate things. Kind Regards Cheerios
|
|
|
|
|
Oh, I get you. I guess using operator precedence on type modifiers kind of threw me, but i can see why you look at it that way.
Real programmers use butterflies
|
|
|
|
|
Greetings and Kind Regards Just in passing I wish to mention in case you do not already know about it is that the C text by Harbison & Steele is what the K&R text wished it was. H&S is a beautiful text and is where I learned that declarations and operations follow the same rules. Why K&R didn't explain this is as simply is difficult to understand. Best Wishes Cheerios
|
|
|
|
|
You could use 123[name] as an alternative - that matches the original PDP addressing mode syntax better as well, I suspect!
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
honey the codewitch wrote: I think it's inconsistent, and I think the array specifier should have been declared with the type since it's essentially a type modifier like * and &
One thing it's not is inconsistent - the pointer modifier belongs with the variable, not the type. For example, the following fragment declares a pointer to integer variable and an integer variable.
int *pa, a;
See this Godbolt...
One option, were you using C++...
template<class T, size_t N>
using Array = T[N];
template<class T>
using Ptr = T*;
Array<int, 10> test_array;
Ptr<int> test_pointer;
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Stuart Dootson wrote: One thing it's not is inconsistent - the pointer modifier belongs with the variable, not the type.
Yet it's a type modifier. A pointer to an int is a different type than an int.
Real programmers use butterflies
|
|
|
|
|
Quote: Does it bother anyone else that you declare a pointer like:
char* sz;
It only looks odd if you use it like that. If you use it like the way it was meant to be used:
char *sz;
It makes sense. The way you write it is not consistent and lends itself to errors.
char* szA, szB, szC;
char *szD, *szE, *szF;
Putting the "*" next to the typename is logically inconsistent - you still have to put the "*" in the correct place for other pointer types:
void (*fptr) (void);
So instead of doing it one way for some variables and the correct way for others, just do it the correct way for all.
|
|
|
|
|
I suppose then that I do not like that type modifiers are not declared with the type.
Real programmers use butterflies
|
|
|
|
|
Quote: I suppose then that I do not like that type modifiers are not declared with the type.
Pointers aren't type modifiers.
You can tell by the way that actual type modifiers can be placed in any order ("short int" and "int short") while the pointer notation can only go before the variable name.
short int si1;
int short si2;
short int *psi3;
*short int psi4;
If you do not associate the '*' with the variable name, then everything looks very confusing and arbitrary and some things that should work won't. If you associate the '*' with the variable name then everything is logical and can be worked out - any "*symbol" means that symbol is a pointer to something, so things like this can be worked out:
const char *varname[100];
You cannot logically infer what that means if you think that the "*" is part of the typename. If the "*" is part of the type, that would mean that the pointer can not be changed. In reality, it is the individual chars that cannot be changed, while each of the pointers in the array can be changed.
There's a lot of misunderstanding that will happen when "typename* varname" is used in place of "typename *varname". A compiler won't catch all of it.
|
|
|
|
|
It bothers me to no end. Actually what bothers me even more is that every time I mention it, I mostly get replies defending the stupid Spiral of Death. It's bad enough that it's bad, but worse that people feel this kind of Stockholm Syndrome towards a type syntax that just doesn't make sense. (in some sense it's not even a type syntax, because it's not just a type, there's a declaration stuck in the middle of it)
Anyway I'll show you something even worse, the syntax for returning a function pointer. Let's say you want to return a pointer to a function that takes two ints and returns an int, a function like int add(int a, int b) maybe. It would look like this:
int (*getFunc())(int, int) { … }
Unless you use a typedef of course (in C# that is essentially mandatory: you must declare a delegate with the signature first and then you can use that).
|
|
|
|
|
harold aptroot wrote: but worse that people feel this kind of Stockholm Syndrome towards a type syntax that just doesn't make sense
I think you're the first person on this thread to agree with me.
Real programmers use butterflies
|
|
|
|
|
Greetings but I must differ
int foobar(int, int) { return 0; }
// I merely followed the operator rules of precedence and associativity for:
// "f is a pointer to a function which takes two arguments of type int and int and returns an int"
// and voila though the return type doesn't seem to be an operator unless perhaps a cast operator
int (*f)(int, int) = foobar; // compiles ok
int (*getFunc())(int, int) = foobar; // compiles with syntax error
// Cheerios
|
|
|
|
|
But that's not what I wrote. I wanted to return a function pointer from a function named getFunc .
|
|
|
|
|
Greetings and Kind Regards Please permit me to demonstrate the following: By merely following the rules of operator precedence and associativity I deduce the same declaration for getFunc as yourself. I thank Harbison & Steele for teaching me this in their fine C text. Why K&R don't do this is difficult to understand.
// "getFunc is a function which returns a pointer to a function which takes two int args and returns an int"
// getFunc is a function ...
getFunc()
// ... which returns a pointer ...
*getFunc()
// ... to a function which takes two int args ...
*getFunc()(int, int)
(*getFunc())(int, int) // added ()'s because function call (int, int) has higher precedence than indirection *
// ... and returns an int
int (*getFunc())(int, int)
// Voila No Spiral of Death is needed. Best Wishes Cheerios
|
|
|
|
|
It's hard to believe that of all the replies no one has ever read K&R C.
A variable declaration consists of a type and name and possibly a type reference spec such as * or [].
Multiple variable declarations may be combined in a single statement (line) if they are the same type. this is why reference specs go with the name
char *sz, sz2[], sz3[1024];
Types and reference specs can also have modifiers which are can get very confusing with multiple declarations combined on a line.
static const char sz4, *sz5, const *sz6;
Add initializers and you will see why it's pretty standard now days to put one declaration per line.
|
|
|
|
|
Greetings and Kind Regards May I please direct you to my previous post. Cheerios
The Lounge[^]
|
|
|
|
|
C declarations are fine. The problem is in C pointer expressions, where two unfortunate changes were made. First, Ritchie (I presume) chose to make * the pointer dereference operator and either chose or had forced upon him by the * choice the need to make it a *left* unary operator. Had he followed Wirth's prior example in Pascal (using p^ to dereference p), then your backwards issue is automatically solved.
Why? Because C declarators are based on how the variable is used in an expression. So int *p; has the * first because you use *p in an expression to make use of the pointer. The array dimension come after the variable name: int a[5]; because you use a[index] in an expression to access a member of an array.
If the pointer dereference was on the right, then you wouldn't need the quirky -> operator that only exists to cut down on parentheses, where p->member exists only to avoid typing (*p).member.
By the way, the declaration should be "char *p;" instead of the awful "char* p;" that revisionists like to type. The * says that p is a pointer, not that "char" is a pointer. To see the difference, try using:
int* p1, p2; /* this will NOT declare two integer pointers! */
The correct syntax is:
int *p1, *p1;
...since the * says that what's on the right is a pointer.
Again, this misunderstanding wouldn't even come up with a right-unary dereference operator.
Most of the C language is admirable, particularly as a product of the early '70s, but this (along with allowing the <string.h> and parts of <stdio.h> libraries to become de facto standards) get my votes for Dennis Ritchie's biggest mistakes.
|
|
|
|
|
My mother-in-law had problems with the App "VoiceMail" from the german Telekom.
They called the hotline: "Oh, no problem, just deinstall and install it again, everything will work"...
Only that the new Version doesn't run in her phone because that Android version has been discontinued
And they don't offer the old ones... and neither can I find older versions in play store
After googling a bit I have found a site... apkpure.com
It looks like an "internet archive" for android software, they have a a list with almost 40 different past versions of this App and they offer the same for other stuff...
Do you know it / Have you used it??
Is it trustworthy? Or is a risk to get "something else" within the App?
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
Help me to understand what I'm saying, and I'll explain it better to you
Rating helpful answers is nice, but saying thanks can be even nicer.
|
|
|
|
|
I haven't used it, but ... it looks OK: The 5 Best Sites for Safe Android APK Downloads[^] - the site also lists other sites that may have the APK you wanted.
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
Thanks.
I have checked both, the signatures are the same in both places and match the downloaded file in both too.
BTW... the link you gave me looks like a nice site too. Do you use it regulary?
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
Help me to understand what I'm saying, and I'll explain it better to you
Rating helpful answers is nice, but saying thanks can be even nicer.
|
|
|
|
|
And suddenly I can see this message ... the hamsters have woken up.
It's not one I use often, but it's one of those "hmmm ... bookmark that one" sites you come across from time to time.
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!
|
|
|
|