|
|
@pcwalton | |||||
|
Random thought: It sure is nice that we went with typed generics in Rust instead of untyped templates like C++/D/Nim/etc, so that we can even *have* the monomorphization debate at all.
|
||||||
|
||||||
|
Basit Ayantunde
@basit_ayantunde
|
30. sij |
|
Untyped templates in what sense?
Pre-C++-20 expresses type constraints in various forms: type traits, compile time assertions, expression testing, etc.
Moreso, C++ 20 has concepts, which I believe is really really powerful.
|
||
|
|
||
|
|
Patrick Walton
@pcwalton
|
30. sij |
|
Think about how you might compile C++ templates without expanding them first.
(You can’t)
|
||
|
|
||
|
Eyal Lotem 🔥
@EyalL
|
31. sij |
|
Wow, this issue is a pet peeve of mine as a user of D on a large codebase.
Had the urge to create a language to show case this dual compilation mode, but now I don't have to.
Does rust have this already?
|
||
|
|
||
|
Doug Gregor
@dgregor79
|
31. sij |
|
FWIW, Swift implements generics via separate compilation (lots of dynamic dispatch under the hood), and has optimization passes that monomorphize based on usage. The model works fairly well, although the performance can sometimes be unpredictable based on what gets monomorphized
|
||
|
|
||
|
adjoint +/- norm
@adamnemecek1
|
30. sij |
|
You are taking it too seriously, haha. People don't dislike monomorphization. There are singular voices that dislike x for any x.
|
||
|
|
||
|
Rik Arends
@rikarends
|
30. sij |
|
Its awesome so atleast you CAN pick the option. I still choose to avoid generics wherever i can, but thats for compiletime purposes. Everytime i see a <T> i go. Here we go mr compiler.
|
||
|
|
||
|
Brian Hurt
@bhurt42
|
31. sij |
|
IMHO, monomorphization is a compiler optimization- the answers "always" and "never" are both wrong, the correct answer should be "when the compiler decides it's worthwhile".
|
||
|
|
||