News for hackers. Stuff that matters.
Re:Adding Modules to C in 10 Lines of Code [pdf] by WalterBright on Tuesday June 28, 2022 @02:31PM (#31911266)
Isn't it amazing how the . operator can cleanly replace :: and -> too?
Re:Adding Modules to C in 10 Lines of Code [pdf] by 10x-dev on Tuesday June 28, 2022 @05:46PM (#31913449)
Absolutely! Speaking of operators, out of curiosity, what's the reason for using '!' with templates?

Naively, I would think that making template instantiation look the same as a function call would be a desirable feature, with ambiguous calls needing to be resolved by the user.

Re:Adding Modules to C in 10 Lines of Code [pdf] by schlupa on Wednesday June 29, 2022 @12:08PM (#31922118)
Not many characters left in ASCII. Reuse of an existing operator almost required. Binary operators cannot be use as it would be grammatical ambiguous and would need resolution at the semantic pass which is a big no-no (that's why C++ is so slow at compiling, it cannot be parsed without semantic analysis). This left only the two exlusively unary operators !, ~. As ~ was repurposed for string concatenation, only ! remained.

    templ!thing(a,b)   
I would have thought that templ(thing)(a,b) would have been a good solution, as it is what is used in the declaration/definition side of templates, but this would have made removing redundant () not possible in UFCS expressions.
Re:Adding Modules to C in 10 Lines of Code [pdf] by Shadonototra on Wednesday June 29, 2022 @12:20PM (#31922274)
i would have preferred:

    templ<thing>(a, b)

because with that:

    templ!thing(a, b)
is it a function?, or are you calling thing's function?

you can do:

    templ!(thing)(a, b)
but did you mean?:

    templ!(thing(a, b))()

i personally always use !(), no matter what, and it's annoying to type, i don't want to waste time constantly trying to figure out what is what, it's mentally draining