Re: [9fans] void*

2022-05-16 Thread Lucio De Re
On 5/16/22, hiro <23h...@gmail.com> wrote: > i still don't understand it. if you want a pointer of size 1 what > keeps you from using a generic char or uint8 pointer? > I think what he's asking is "what's keeping everyone else from using...". I guess we're all evangelists at heart. Lucio.

Re: [9fans] void*

2022-05-16 Thread hiro
i still don't understand it. if you want a pointer of size 1 what keeps you from using a generic char or uint8 pointer? On 5/16/22, adr wrote: > On Mon, 16 May 2022, Charles Forsyth wrote: >> it's void* because that can be assigned between other pointer types >> without a cast.x =

Re: [9fans] void*

2022-05-16 Thread adr
On Mon, 16 May 2022, Charles Forsyth wrote: it's void* because that can be assigned between other pointer types without a cast.x = malloc(sizeof(*x)); instead of x = (T*)malloc(sizeof(*x)); which just adds clutter. Similarly it's just free(x) instead of free((void*)x); (or free((uchar*)x) as I

Re: [9fans] void*

2022-05-16 Thread Charles Forsyth
it's void* because that can be assigned between other pointer types without a cast. x = malloc(sizeof(*x)); instead of x = (T*)malloc(sizeof(*x)); which just adds clutter. Similarly it's just free(x) instead of free((void*)x); (or free((uchar*)x) as I understand your suggestion). On Sun, 15 May

Re: [9fans] void*

2022-05-16 Thread Bakul Shah
I can see some use of void* arithmetic for malloc/free or when you’re doing your own allocation for various object types, where a size of 1 would be handy. I wonder what a FarC would like! > On May 15, 2022, at 11:27 PM, Skip Tavakkolian > wrote: > >  > If void can have a size, why not 4, 8

Re: [9fans] void*

2022-05-16 Thread Humm
Quoth Skip Tavakkolian: If void can have a size, why not 4, 8 or 16? Really, if it would have a size, it should be zero. And thus p+n==p. Not too useful. It’s fine as it is. -- Humm -- 9fans: 9fans Permalink:

Re: [9fans] void*

2022-05-16 Thread Skip Tavakkolian
If void can have a size, why not 4, 8 or 16? P.S. I discovered Gholami Rudi's work a little while ago. I was especially intrigued by Farsi support in neatroff (intro in Farsi produced by Neatroff and Neatpost: https://litcave.rudi.ir/neatfarsi.pdf) Cool stuff. On Sun, May 15, 2022, 9:09 AM adr

Re: [9fans] void*

2022-05-15 Thread adr
In case someone is asking why this guy is suddenly so thoughtful about void pointers, it is because I'm porting Ali Gholami Rudi's neatroof, and he uses a lot of arithmetics with void* in neatmkfn. I got rid of ape, and this troff looks really easy to port and has a lot of features. I'll share it

Re: [9fans] void*

2022-05-15 Thread ori
Quoth Bakul Shah : > void*f(void*x){return x+1;} $ echo 'void*f(void*x){return x+1;}' > test.c $ cc -pedantic -std=c99 test.c test.c:4:24: warning: arithmetic on a pointer to void is a GNU extension [-Wpointer-arith] void*f(void*x){return x+1;}

Re: [9fans] void*

2022-05-15 Thread Bakul Shah
> On May 15, 2022, at 8:23 AM, Dan Cross wrote: > > On Sun, May 15, 2022 at 9:16 AM adr wrote: > On Sun, 15 May 2022, adr wrote: > > What I mean is if we are going to follow C99 in the use of void*, > > we should allow arithmetic on them. > > Let me be clear, I know that C99 requires the

Re: [9fans] void*

2022-05-15 Thread adr
On Sun, 15 May 2022, o...@eigenstate.org wrote: On Sun, 15 May 2022, arn...@skeeve.com wrote: It allows you pass pointers of any type without requiring casts: struct foo s[5] = ... memmove(s, & s[1], 4 * sizeof(struct foo)); // shift down 1 The compiler won't complain

Re: [9fans] void*

2022-05-15 Thread Dan Cross
On Sun, May 15, 2022 at 9:16 AM adr wrote: > On Sun, 15 May 2022, adr wrote: > > What I mean is if we are going to follow C99 in the use of void*, > > we should allow arithmetic on them. > > Let me be clear, I know that C99 requires the pointer to be a > complete object type to do arithmetic,

Re: [9fans] void*

2022-05-15 Thread ori
Quoth adr : > On Sun, 15 May 2022, arn...@skeeve.com wrote: > > > It allows you pass pointers of any type without requiring casts: > > > >struct foo s[5] = ... > >memmove(s, & s[1], 4 * sizeof(struct foo)); // shift down 1 > > > > The compiler won't complain because any

Re: [9fans] void*

2022-05-15 Thread ori
Quoth adr : > Hi, > one of the first thing I noticed compiling in plan9 is that arithmetic > on void* is illegal. Other compilers treat void* as uchar*. > Conceptually, it makes sense. A pointer to void doesn't point to > any object. But then I've seen the use of void* in functions (like >

Re: [9fans] void*

2022-05-15 Thread adr
On Sun, 15 May 2022, arn...@skeeve.com wrote: It allows you pass pointers of any type without requiring casts: struct foo s[5] = ... memmove(s, & s[1], 4 * sizeof(struct foo)); // shift down 1 The compiler won't complain because any pointer type can be passed to a void*

Re: [9fans] void*

2022-05-15 Thread arnold
adr wrote: > On Sun, 15 May 2022, adr wrote: > > > What I mean is if we are going to follow C99 in the use of void*, > > we should allow arithmetic on them. > > Let me be clear, I know that C99 requires the pointer to be a > complete object type to do arithmetic, and I like that, is consistent.

Re: [9fans] void*

2022-05-15 Thread adr
On Sun, 15 May 2022, adr wrote: What I mean is if we are going to follow C99 in the use of void*, we should allow arithmetic on them. Let me be clear, I know that C99 requires the pointer to be a complete object type to do arithmetic, and I like that, is consistent. But then I don't see the

Re: [9fans] void*

2022-05-15 Thread adr
What I mean is if we are going to follow C99 in the use of void*, we should allow arithmetic on them. If not, there is not point to use void* as char*, just use char* as the generic pointer. When I ask something here about the Plan9 compilers, I'm not asking about some committee's standard, I

Re: [9fans] void*

2022-05-15 Thread Humm
one of the first thing I noticed compiling in plan9 is that arithmetic on void* is illegal. That’s what the standard says. While Plan 9 C doesn’t pretend to be compliant, the core language does roughly match C89 with a few C99 extensions. Other compilers treat void* as uchar*. Conceptually,

[9fans] void*

2022-05-15 Thread adr
Hi, one of the first thing I noticed compiling in plan9 is that arithmetic on void* is illegal. Other compilers treat void* as uchar*. Conceptually, it makes sense. A pointer to void doesn't point to any object. But then I've seen the use of void* in functions (like memccpy) when the pointed