Embrace the from template?
Jonathan Marler
johnnymarler at gmail.com
Sat Aug 25 01:03:37 UTC 2018
On Saturday, 25 August 2018 at 00:40:54 UTC, tide wrote:
> On Friday, 24 August 2018 at 06:41:35 UTC, Jonathan Marler
> wrote:
>> Ever since I read
>> https://dlang.org/blog/2017/02/13/a-new-import-idiom/ I've
>> very much enjoyed using the new `from` template. It unlocks
>> new idioms in D and have been so useful that I thought it
>> might be a good addition to the core language. I've found
>> that having it in a different place in each project and always
>> having to remember to import it makes it much less ubiquitous
>> for me.
>>
>> One idea is we could add this template to `object.d`. This
>> would allow it to be used from any module that uses druntime
>> without having to import it first. The template itself is
>> also very friendly to "bloat" because it only has a single
>> input parameter which is just a string, extremely easy to
>> memoize. Also, unless it is instantiated, adding it to
>> object.d will have virtually no overhead (just a few AST nodes
>> which would dwarfed by what's already in object.d). It would
>> also be very easy to add, a single PR with 4 lines of code to
>> druntime and we're done.
>>
>> Of course, if we don't want to encourage use of the `from`
>> template then this is not what we'd want. Does anyone have
>> any data/experience with from? All I know is my own usage so
>> feel free to chime in with yours.
>
> What uses does this actually have, I only see one example from
> the article and it is an oversimplistic example that
> effectively translates to either phobos being used or not being
> used. All the extra bloat this template would add to the
> already bloated if constraints is not welcome at all. The
> potential small benefit this might add isn't worth the
> unreadable mess it will turn code into.
I can't help but laugh when you say "all the extra bloat this
template would add..." :) Sorry, I don't mean to insult but that
really gave me a laugh.
I hate to be blunt, but its clear from your response that you
failed to grok the original post, which makes anything else I say
pointless. So I'm going to slowly back away from this
one...step...step..step....*stp*....*s*...*
More information about the Digitalmars-d
mailing list