Why is `scope` planned for deprecation?
via Digitalmars-d
digitalmars-d at puremagic.com
Sun Nov 16 11:59:52 PST 2014
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. It is a bit
confusing in the beginning since it is more or less unique to C.
> 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.
Nothing prevents you from creating a slice as a struct though.
> 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
More information about the Digitalmars-d
mailing list