Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - admin

Pages: [1]
1
General Discussion / Re: Diffs to C99 and C11
« on: March 13, 2017, 08:05:37 AM »
Since C2 uses the clang preprocessor, all normal C preprocessor command should work. This is more a by-effect than
a real  design target..

2
General Discussion / Re: VLA crash
« on: March 13, 2017, 08:04:29 AM »
Good one!
I'll turn it into a unit test and fix it this evening..

3
General Discussion / Re: Complex numbers
« on: March 06, 2017, 08:02:26 AM »
I haven't really thought about that yet. I almost never (read: never) write code with Complex numbers and such.
Are there specific painpoints using them in C?

4
General Discussion / Re: Typo in manual
« on: March 06, 2017, 08:00:52 AM »
ouch, I'll fix start right away (this evening)

5
Ideas / Re: [Email suggestion No. 3] type casts in C2 + bugs
« on: July 22, 2016, 09:22:47 AM »
Yes, the parser ignores them currently, I'll put a task on my backlog to fix this properly

6
Ideas / Re: [Email suggestion No. 1] macros in C2
« on: July 22, 2016, 09:17:40 AM »
Maybe we can also create a new point that forbids the use of macro's within a macro?

7
see also this post (http://www.c2lang.org/forum/index.php?topic=56.msg154#msg154).

The library system is currently undergoing an overhaul. In the current system, there would be an interface
file, for example stdio.c2i (in c2libs/libc/). In the libc manifest file there would be an entry also naming
(for C libs) an header file name. During compilation, the header file name would be generated in C-code.
Then during the compilation of the generated C-code, this (system) header (stdio.h) would actually be
used.

In the new system, headers are generated from the c2 interface file. And this generated header would be
used (so #include "stdio.h" (notice the double quotes "" instead of <>). This has the advantage that the
header is guaranteed to be the same as the interface file.

8
Ideas / Re: [Email suggestion No. 3] type casts in C2 + bugs
« on: July 21, 2016, 08:03:47 AM »
I couldn't agree more. The <> syntax just looks like C++ templates is is just plain ugly..

However ugly, it does have the advantage of requiring parentheses around the thing being
cast. With the c-style cast, it's not always obvious what exactly is cast. This has to do with
operator precendence (and could be a source of bugs).

C-style cast are currently not working on purpose. Casts need to be fixed first.

The 2nd 'bug' is also done on purpose for now, since we don't have to check circular initializations now ;)
So the declaration is only added to the scope after it's been done, so after the initialization. But for better
error messages, it might be needed to change this

9
I'm currently working on intergrating a generic library system, and especially libc. What C2 cannot
currently solve is the entire libc incompatibility between different systems. This is just too much. One
future solution that would get rid of a lot of legacy is to rewrite a libc in C2 itself, but that is a separate
project. Anyone?

But what C2 could do is to make the dependency on a libc less inherent. So you can easily say I don't
want my program to depend on any system library. This is also usefull for cross-compiling etc.

One other funny conclusion I came to while working on a library system is that essentially, solving
cross-compilation (issues) is solving the library problem (or vice versa)
. Think about it. Much effort is put into making
sure your program uses a certain version of some library instead of the default (system) library/headers.
This part will certainly be solvable!

What you see in other, new/modern language like Rust/Go/Swift is that they don't rely on system-installed
libraries so much. If your program needs some libX, they just download it into a local build directory and use
that. C2 will allow more fine grained control of which library will be used (system, user, local, etc)

10
Ideas / Re: [Email suggestion No. 1] macros in C2
« on: July 21, 2016, 07:51:26 AM »
It's a bit strange that some language cling to macros, while others
(C#, Java, etc) never seem to need them. To make a really good macro
system, I tried to write do the *purpose* of macros. What I came up
with:
  • replacing common code
  • inlining (instead of function). This one is actually not valid,
      since a function call is superior if the compiler can inline it.
  • feature selection
the difference with a function is that a macro is able to 'access'
the 'calling' scope.

The Nim language is a bit in the same domain as C2. It has some pretty
nice ideas as well. For macros they stated (something like): "with macros
you can change the AST". Indeed the case if you think about it.

http://nim-lang.org/docs/tut2.html#macros

I agree with your design (1-5). My additions:
6. A macro can be public or not, just like other declarations.
7. There needs to be a distinction
 (also described in the nim link): There are *expression* macros and
 *statement/decl* macros. You cannot have a declaration if a place wher
 an expression is expected. It might be possible to discover this, but
 it might be needed for a developer to specify this as well..
8. The argument of a macro must be an identifier (only). This avoids
    nasty issues like in C:
Code: [Select]
        #define MAX(x, y) (x > y ? x : y)
        int c = MAX(a++, b++)
as this  expands to
Code: [Select]
int c = ((a++) > (b++) ? (a++) : (b++));

11
General Discussion / C2 first post
« on: February 01, 2013, 04:43:13 PM »
Hi,

This is the first post on this forum. Since SimpleMachines forum attracted a lot of spam, I had to close
automatic registration. I hope to generate a lot more posts in the coming weeks, so if you're interested
in registering; just send me an email.

Regards,
Bas

Pages: [1]