Why is `scope` planned for deprecation?

via Digitalmars-d digitalmars-d at puremagic.com
Mon Nov 17 03:00:05 PST 2014


On Monday, 17 November 2014 at 10:18:41 UTC, Walter Bright wrote:
> (Another problem with strlen() is that the string pointed to is 
> in a different piece of memory, and it'll have to be loaded 
> into the cache to scan for the 0. Whereas with slices, the 
> length data is in the hot cache.)

Oh, I am not saying that strlen() is a good contemporary 
solution. I am saying that when you have <32KiB RAM total it 
makes sense to save space by not storing the string length.

>>> deadalnix busted that myth a while back with benchmarks.
>>
>> I haven't seen it,
>
> It's in the n.g. archives somewhere in a thread about 
> implementing lexers.

Well, then it is just words.

> That's the wrong question. The question is does a trailing 
> sentinel result in a faster FA? deadalnix demonstrated that the 
> answer is 'no'.

I hear that, but the fact remains, you do less work. It should 
therefore be faster. So if it is not, then you're either doing 
something wrong or you have bubbles in the pipeline on a specific 
CPU that you fail to fill. On newer CPUs you have a tiny loop 
buffer for tight inner loops that runs microops without decode, 
you want to keep the codesize down there.

Does it matter a lot in the world of SIMD? Probably not, but then 
you get a more complex lexer to maintain.

> deadalnix's benchmark. But the stuff you are positing is 
> well-trodden ground. There's a damn good reason why D uses 
> slices and not 0 terminated strings.

I've never said that D should use 0 terminated strings. Now you 
twist the debate.


More information about the Digitalmars-d mailing list