Herb Sutter's CppCon talk "Extending and Simplifying C++: Thoughts on Pattern Matching using `is` and `as`"
Walter Bright
newshound2 at digitalmars.com
Tue Nov 2 01:00:27 UTC 2021
On 11/1/2021 3:02 PM, Andrei Alexandrescu wrote:
>> 1. basic types, structs, and arrays are interchangeable. But I couldn't add
>> tuples to the list, because the function call ABI for structs is "special". Urgh.
>
> 1a. Hash tables have a number of language magic hacks (particularly concerning
> keys that have statically-sized array types) that are thoroughly inconsistent
> with the language rules.
True, but hash tables are not basic types, structs, arrays or tuples!
>> 2. The nature of how const, immmutable, and shared are applied to types is
>> completely consistent, despite many requests to change that.
>
> 2a. Hash tables have any number of qualifier-related hacks that makes them
> impossible to implement as a library.
>
> 2b. Calls to built-in arrays remove the top-level qualifier in a way that is not
> accessible to user code. This makes qualified ranges impossible to implement:
>
>
> void fun(T)(T data) {
> import std;
> writeln(T.stringof);
> }
>
> void main() {
> immutable int a = 42;
> immutable int[] b = [ 69 ];
> fun(a); // fine, prints immutable(int)
> fun(b); // prints immutable(int)[], not immutable(int[])
> }
Maybe qualified ranges should be impossible to implement.
> 2c. There are a number of hacks in the compiler that give special treatment to
> shared numerics. Such is inaccessible to user code. Worse, they don't generate
> correct code.
>
> void main() {
> shared int i = 42;
> i = i + 2; // whatta?
> }
Shared memory reads/writes are no longer allowed. I don't think that's a hack.
>> 4. The way scope & return & ref apply to types is completely consistent. This
>> enables me to advise that when people have problems understanding it, to
>> rewrite their example code in terms of raw pointers, as it will behave the same.
>
> I very much wish this is true and useful.
Show me where it isn't true and/or isn't useful.
More information about the Digitalmars-d
mailing list