Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to perform pointer arithmetic?

Tags:

carbon-lang

I'm new to the Carbon language, how to perform pointer arithmetic? Is this even possible?

p = p + 1;

=>

COMPILATION ERROR: <source>:11: type error in `+`:
could not find implementation of interface AddWith(U = i32) for i32*
Compiler returned: 1
like image 415
D.R. Avatar asked Jun 19 '26 05:06

D.R.


1 Answers

Carbon does not support pointer arithmetic. The only two operations are

  • dereference (*p gives the l-value p points to),
  • address-of (&v gives the address of l-value v).

More detail is available in carbon design notes.

like image 122
user1635327 Avatar answered Jun 22 '26 03:06

user1635327