Use cursors instead of pointers. Snag the brk() at the beginning and use it as a base-pointer.
char*m=brk();
Then make a #define for memory access.
#define M [m]
M becomes a postfix * applied to integers. (The old a[x] == x[a] trick.)
But, there's more! Then you can have pointer args and returns in functions that are shorter than macros (especially if you abbreviate 'return'):
f(x){return x M;} //implicit ints, but they work like pointers
#define f(x) (x M)
To make a cursor from a pointer, you subtract the base-pointer, yielding a ptrdiff_t, which truncates into an int, losses is yer biz.
charint *pp = sbrk(sizeof(whatever)) - m;
strcpy(m+p, "hello world");
This technique is used in my answer to Write an interpreter for the untyped lambda calculus.
Use cursors instead of pointers. Snag the brk() at the beginning and use it as a base-pointer.
char*m=brk();
Then make a #define for memory access.
#define M [m]
M becomes a postfix * applied to integers. (The old a[x] == x[a] trick.)
But, there's more! Then you can have pointer args and returns in functions that are shorter than macros (especially if you abbreviate 'return'):
f(x){return x M;} //implicit ints, but they work like pointers
#define f(x) (x M)
To make a cursor from a pointer, you subtract the base-pointer, yielding a ptrdiff_t, which truncates into an int, losses is yer biz.
char *p = sbrk(sizeof(whatever)) - m;
strcpy(m+p, "hello world");
This technique is used in my answer to Write an interpreter for the untyped lambda calculus.
Use cursors instead of pointers. Snag the brk() at the beginning and use it as a base-pointer.
char*m=brk();
Then make a #define for memory access.
#define M [m]
M becomes a postfix * applied to integers. (The old a[x] == x[a] trick.)
But, there's more! Then you can have pointer args and returns in functions that are shorter than macros (especially if you abbreviate 'return'):
f(x){return x M;} //implicit ints, but they work like pointers
#define f(x) (x M)
To make a cursor from a pointer, you subtract the base-pointer, yielding a ptrdiff_t, which truncates into an int, losses is yer biz.
int p = sbrk(sizeof(whatever)) - m;
strcpy(m+p, "hello world");
This technique is used in my answer to Write an interpreter for the untyped lambda calculus.
Use cursors instead of pointers. Snag the brk() at the beginning and use it as a base-pointer.
char*m=brk();
Then make a #define for memory access.
#define M [m]
M becomes a postfix * applied to integers. (The old a[x] == x[a] trick.)
But, there's more! Then you can have pointer args and returns in functions that are shorter than macros (especially if you abbreviate 'return'):
f(x){return x M;} //implicit ints, but they work like pointers
#define f(x) (x M)
To make a cursor from a pointer, you subtract the base-pointer, yielding a ptrdiff_t, which truncates into an int, losses is yer biz.
char *p = sbrk(sizeof(whatever)) - m;
strcpy(m+p, "hello world");
This technique is used in my answer to Write an interpreter for the untyped lambda calculus Write an interpreter for the untyped lambda calculus.
Use cursors instead of pointers. Snag the brk() at the beginning and use it as a base-pointer.
char*m=brk();
Then make a #define for memory access.
#define M [m]
M becomes a postfix * applied to integers. (The old a[x] == x[a] trick.)
But, there's more! Then you can have pointer args and returns in functions that are shorter than macros (especially if you abbreviate 'return'):
f(x){return x M;} //implicit ints, but they work like pointers
#define f(x) (x M)
To make a cursor from a pointer, you subtract the base-pointer, yielding a ptrdiff_t, which truncates into an int, losses is yer biz.
char *p = sbrk(sizeof(whatever)) - m;
strcpy(m+p, "hello world");
This technique is used in my answer to Write an interpreter for the untyped lambda calculus.
Use cursors instead of pointers. Snag the brk() at the beginning and use it as a base-pointer.
char*m=brk();
Then make a #define for memory access.
#define M [m]
M becomes a postfix * applied to integers. (The old a[x] == x[a] trick.)
But, there's more! Then you can have pointer args and returns in functions that are shorter than macros (especially if you abbreviate 'return'):
f(x){return x M;} //implicit ints, but they work like pointers
#define f(x) (x M)
To make a cursor from a pointer, you subtract the base-pointer, yielding a ptrdiff_t, which truncates into an int, losses is yer biz.
char *p = sbrk(sizeof(whatever)) - m;
strcpy(m+p, "hello world");
This technique is used in my answer to Write an interpreter for the untyped lambda calculus.
Use cursors instead of pointers. Snag the brk() at the beginning and use it as a base-pointer.
char*m=brk();
Then make a #define for memory access.
#define M [m]
M becomes a postfix * applied to integers. (The old a[x] == x[a] trick.)
But, there's more! Then you can have pointer args and returns in functions that are shorter than macros (especially if you abbreviate 'return'):
f(x){return x M;} //implicit ints, but they work like pointers
#define f(x) (x M)
To make a cursor from a pointer, you subtract the base-pointer, yielding a ptrdiff_t, which truncates into an int, losses is yer biz.
intchar p*p = sbrk(sizeof(whatever)) - m;
strcpy(m+p, "hello world");
This technique is used in my answer to Write an interpreter for the untyped lambda calculus.
Use cursors instead of pointers. Snag the brk() at the beginning and use it as a base-pointer.
char*m=brk();
Then make a #define for memory access.
#define M [m]
M becomes a postfix * applied to integers. (The old a[x] == x[a] trick.)
But, there's more! Then you can have pointer args and returns in functions that are shorter than macros (especially if you abbreviate 'return'):
f(x){return x M;} //implicit ints, but they work like pointers
#define f(x) (x M)
To make a cursor from a pointer, you subtract the base-pointer, yielding a ptrdiff_t, which truncates into an int, losses is yer biz.
int p = sbrk(sizeof(whatever)) - m;
strcpy(m+p, "hello world");
This technique is used in my answer to Write an interpreter for the untyped lambda calculus.
Use cursors instead of pointers. Snag the brk() at the beginning and use it as a base-pointer.
char*m=brk();
Then make a #define for memory access.
#define M [m]
M becomes a postfix * applied to integers. (The old a[x] == x[a] trick.)
But, there's more! Then you can have pointer args and returns in functions that are shorter than macros (especially if you abbreviate 'return'):
f(x){return x M;} //implicit ints, but they work like pointers
#define f(x) (x M)
To make a cursor from a pointer, you subtract the base-pointer, yielding a ptrdiff_t, which truncates into an int, losses is yer biz.
char *p = sbrk(sizeof(whatever)) - m;
strcpy(m+p, "hello world");
This technique is used in my answer to Write an interpreter for the untyped lambda calculus.