Recent Posts

Pages: [1] 2 3 ... 10
1
Ideas / Re: Fat pointer syntax support for 1D array like structs
« Last post by shiv on December 30, 2020, 05:27:15 PM »
Yes!
2
Ideas / Re: Fat pointer syntax support for 1D array like structs
« Last post by lerno on December 27, 2020, 12:27:48 AM »
Ok, so a sort of syntactic sugar?

Code: [Select]
// So these would be equal:
y = s->data[x];
y = (*s)[x];

Correct?
3
Ideas / Struct wrapping (multi-dimensional) arrays
« Last post by shiv on December 18, 2020, 05:18:35 PM »
Gnu C extension allows:
void * foo (int n) {
struct S { int data[n]; };
int (*s)[n] = malloc( sizeof (int[n]) );
...
}
which is very convenient. It would be even better to allow support for the following:
struct S {
int n;
f32 (*data)[.n]; // the ".n" refers to the internal field
}

It would be even more awesome to allow wrapping multi-dimensional arrays:
struct S2 {
int m;
int n;
f32 (*d)[.m][.n];
}
struct S2 a2;
a2.m = 100;
a2.n = 50;
a2.d = malloc( sizeof( f32[a2.m][a2.n] );
(*a2.d)[0][0] = (*a2.d)[1][1] + (*a2.d)[2][3];

If we then combine with my previous suggestion of allowing array access syntax on "fat pointers" we could do:
(*a2)[0][0] = (*a2)[1][1] + (*a2)[2][3];
4
Ideas / Fat pointer syntax support for 1D array like structs
« Last post by shiv on December 18, 2020, 04:39:20 PM »
It would be nice to allow the following type of syntax:
struct S {
int len;
f32 data[];
};

struct S *s = malloc( sizeof( struct S ) + 100 * sizeof( f32 ) );
s->len = 100;
(*s)[0] = (*s)[1] + (*s)[2];

So if a struct ends with a variable length array (or just a pointer type) then the array access syntax using [] is honored.
5
Ideas / Distinct types
« Last post by lerno on December 17, 2020, 02:54:38 AM »
An interesting feature in Odin is that of "distinct" types. That is, it acts like you actually created a completely new type, not a typedef alias. That way you can for example have a "UserId" type which is an int underneath but typechecks as if it was another type.
6
General Discussion / The return of the forums
« Last post by lerno on December 15, 2020, 10:37:34 PM »
I thought the forums were gone. Happy to see that they're back.
7
General Discussion / Re: Is a self-hosting c2 compiler a project goal?
« Last post by lerno on December 16, 2019, 10:04:25 PM »
Also, self hosting creates a lot of problems with bootstrapping, so it might not be a great thing to do anyway.
8
General Discussion / Re: Is a self-hosting c2 compiler a project goal?
« Last post by lerno on December 16, 2019, 10:03:51 PM »
I started on a C2 compiler written in C, since moving form C to C2 would be pretty easy. I didn't finish it though.
9
General Discussion / Is a self-hosting c2 compiler a project goal?
« Last post by robheus on December 15, 2019, 02:54:54 PM »
c2 is currentely implemented in C++. But would implementing a c2 compiler in c2 be a project goal?
10
General Discussion / Re: C2 discord server
« Last post by bas on October 21, 2019, 11:19:45 PM »
nice!
Pages: [1] 2 3 ... 10