▲ | zzo38computer 2 days ago | |||||||
In my opinion, some features of D are good, but I do not like all of them. CTFE is good. I do not really like the UFCS; if you want it to be used like a member of the first parameter then you should define it as a member of the first parameter (possibly as a inline function that only calls the freestanding function with the same name, if that is what you want it to do). (You could use a macro to do this automatically if you want to.) Scoped imports is good, but I think that scoped macros would also be helpful. Exhaustive switch seem like it might be better if designed differently than it is, but the idea seems to be not bad, in general. | ||||||||
▲ | Doxin 2 days ago | parent | next [-] | |||||||
Honestly the main reason UFCS is good is when you don't "own" the type your function would need to be a member of. Most common one I run into is the "to" function from the stdlib. You can do this:
But now lets say you want to convert ints to MyCustomInts? You can hardly attach a new "to" member to int, but with UFCS it's easy. Just declare a to function anywhere in scope:
and it'll magically work:
| ||||||||
▲ | LorenDB 2 days ago | parent | prev [-] | |||||||
UFCS is a bit overreaching but I think it's great for its intended use of chaining expressions on ranges and such. | ||||||||
|