On 11/16/2014 11:59 AM, "Ola Fosheim Grøstad" <ola.fosheim.grostad+dl...@gmail.com>" wrote:
On Sunday, 16 November 2014 at 19:24:47 UTC, Walter Bright wrote:
This made C far, far more difficult and buggy to work with than it should have
been.

Depends on your view of C, if you view C as step above assembly then it makes
sense to treat everything as pointers.

If you read my article, the fix does not take away anything.


2. 0 terminated strings

This makes it surprisingly difficult to do performant string manipulation, and
also results in a excessive memory consumption.
Whether using sentinels is slow or fast depends on what you want to do, but it
arguably save space for small strings (add a length + alignment and you loose ~6
bytes).
>
Also dealing with a length means you cannot keep everything in registers on
simple CPUs.

A lexer that takes zero terminated input is a lot easier to write and make fast
than one that use length.

I've worked enough with C to know that these arguments do not hold up in real 
code.


Nothing prevents you from creating a slice as a struct though.

I've tried that, too. Doesn't work - the C runtime library prevents it, as well as every other library.


sensibilities to it. But if we were to, a vast amount of C could be
dramatically improved without changing its fundamental nature.

To me the fundamental nature of C is:

1. I can visually imagine how the code maps onto the hardware

2. I am not bound to a complicated runtime

None of the fixes I've suggested impair that in any way.

Reply via email to