Embrace the from template?

Jonathan Marler johnnymarler at gmail.com
Sat Aug 25 10:18:22 UTC 2018


On Saturday, 25 August 2018 at 09:30:27 UTC, Jonathan M Davis 
wrote:
> On Saturday, August 25, 2018 2:02:51 AM MDT Jonathan Marler via 
> Digitalmars- d wrote:
>> [...]
>
> Honestly, I don't want to be doing _anything_ like from with 
> _any_ syntax. It's not just a question of from itself being too 
> long. It's the fact that you're having to use the import path 
> all over the place. I don't want to be putting anything other 
> than the actual symbol name in the function's signature. IMHO, 
> the ideal is to be able to just put
>
> import blah;
>
> at the top and then just use whatever was in module blah 
> without having to repeat it everywhere. On the whole, I find 
> this whole trend of constantly having to list exactly which 
> symbols you're importing / exactly where a symbol comes from 
> instead of just being able to just slap an import at the top 
> and use the symbols te be way, way too verbose and a general 
> maintenance problem. Yes, it can make it easier to figure out 
> where a symbol came from when reading the code, and sometimes, 
> it can improve compilation speed, but it means having to add a 
> ton of extra code in comparison to just importing the module 
> once, and you have to maintain all of that, constantly tweaking 
> import statements, because you've changed which symbols you've 
> used. It's like a cancer except that it comes with just enough 
> benefits that some folks keep pushing for it.
>
> from is not the entire problem, but IMHO, it's definitely the 
> straw that breaks the camel's back. It's taking all of this 
> specificity way too far. I don't want to have to write or read 
> code that's constantly putting import information everywhere. 
> Sadly, it makes C's #include mess start looking desirable in 
> comparison.
>
> - Jonathan M Davis

I can certainly understand this sentiment.  I personally use both 
styles depending no the situation.  Each has their pros and cons, 
it's verbosity vs specificity.  At least with D I can define the 
`from` template in my own projects even if the core language 
doesn't add it.  I'm just of the opinion that it's useful enough 
to warrant additions to the core language in some form to make it 
easier to use.  Thanks for chiming in.


More information about the Digitalmars-d mailing list