Not the OP, but the '*' is already the common symbol for multiplication.
Not much of a problem for people who are used to C syntax of course, but may be confusing to anybody else, especially in expressions which have both pointer dereference and multiplication, for instance this is entirely valid C:
int a = 3 ** int_ptr;
The '^' is the pointer symbol in Pascal, so it's not a new thing either, it just fell a bit out of fashion.
edit: The parent's code does a dereference and then a multiplcation. This is because of (imho) bizarre parsing rules for a dereference asterisk. I'm saying that's so horrifying that I would be less horrified if it really was an exponent (as it might seem by mixing languages).
3 ** int_ptr multiplies the vakue pointed at by int_ptr by 3. It is exactly the same code as 3 * (*int_ptr) which is the point the parent was making.
powl(3, int_ptr) would be (int)int_ptr * (int)int_ptr * (int)int_ptr which is also unlikely what you wanted. You probably wanted to say powl(3, *int_ptr)
EDIT: actually even my last paragraph is wrong because the first arg is base... I'm not going to write it out but you get the point...
It was a confusion between ** used as the rise to power operator in languages like Fortran or Python which just validated the grandparent point of confusing syntax for people not used with C that come from other programming languages.
Comments
Not the OP, but the '*' is already the common symbol for multiplication.
Not much of a problem for people who are used to C syntax of course, but may be confusing to anybody else, especially in expressions which have both pointer dereference and multiplication, for instance this is entirely valid C:
The '^' is the pointer symbol in Pascal, so it's not a new thing either, it just fell a bit out of fashion.Related: I like the "down to" operator: https://stackoverflow.com/questions/1642028/what-is-the-oper...
(No, it's not a real operator, it's another case of weird but allowed spacing causing confusion)
That's horrifying, I think I would have preferred
edit: The parent's code does a dereference and then a multiplcation. This is because of (imho) bizarre parsing rules for a dereference asterisk. I'm saying that's so horrifying that I would be less horrified if it really was an exponent (as it might seem by mixing languages).That's not what the code does.
3 ** int_ptr multiplies the vakue pointed at by int_ptr by 3. It is exactly the same code as 3 * (*int_ptr) which is the point the parent was making.
powl(3, int_ptr) would be (int)int_ptr * (int)int_ptr * (int)int_ptr which is also unlikely what you wanted. You probably wanted to say powl(3, *int_ptr)
EDIT: actually even my last paragraph is wrong because the first arg is base... I'm not going to write it out but you get the point...
See, it is confusing, because the code doesn't compute a power.
It's a multiplication with the value pointed to by int_ptr, e.g. rewritten to make more sense:
...or in Odin it would look like this (I think, haven't used Odin all that much yet):I’m not sure I understand your comment, wasn’t the point that
Calculates 3 times (*int_ptr)?It was a confusion between ** used as the rise to power operator in languages like Fortran or Python which just validated the grandparent point of confusing syntax for people not used with C that come from other programming languages.
In Python and Fortran for example: