Jump to page: 1 2 3
Thread overview
Embrace the from template?
Aug 24, 2018
Jonathan Marler
Aug 24, 2018
aliak
Aug 24, 2018
Jonathan Marler
Aug 24, 2018
aliak
Aug 25, 2018
Basile B.
Aug 24, 2018
Mike Franklin
Aug 24, 2018
Anton Fediushin
Aug 24, 2018
Jonathan Marler
Aug 24, 2018
Anton Fediushin
Aug 24, 2018
Daniel N
Aug 24, 2018
Jonathan Marler
Aug 24, 2018
Seb
Aug 24, 2018
Jonathan Marler
Aug 24, 2018
Anton Fediushin
Aug 25, 2018
tide
Aug 25, 2018
Jonathan Marler
Aug 25, 2018
Jonathan M Davis
Aug 25, 2018
Jonathan Marler
Aug 25, 2018
Daniel N
Aug 25, 2018
Jonathan M Davis
Aug 25, 2018
Jonathan Marler
Aug 25, 2018
Jonathan M Davis
August 24, 2018
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.


August 24, 2018
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.

One of the first things I do after a dub init is create a file called internal.d with the from template in it. My only gripe about this template is it's "autocompletion-able-ness" in IDEs and if that can be handled.

I would not want it globally imported though, "from" is quite popular as an identifier and D doesn't let you use keywords as identifiers.

Cheers,
- Ali
August 24, 2018
On Friday, 24 August 2018 at 06:41:35 UTC, Jonathan Marler wrote:

> 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.

I don't know.  It's not a bad idea, but I don't consider it a major enabler either.  It's easy enough to just cut and paste it to one's arsenal, though I understand the inconvenience of having to maintain it in multiple projects.

One thing to consider is `from` is a *very* general word, and if it's placed in object.d it might cause naming conflicts.  I'd like the name to be more specific, but I know how such naming discussions tend to go.

Mike


August 24, 2018
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.

There's no reason to mess with `object.d` or add it to phobos. Just make a dub package and use it!

I just published it on the dub registry in public domain (I hope Daniel Nielsen is ok with that. After all, it's just 3 lines of code)

Package page: https://from.dub.pm/


Have a good day and don't overthink simple things,
Anton

August 24, 2018
On Friday, 24 August 2018 at 12:06:15 UTC, Anton Fediushin wrote:
> On Friday, 24 August 2018 at 06:41:35 UTC, Jonathan Marler wrote:
>> [...]
>
> There's no reason to mess with `object.d` or add it to phobos. Just make a dub package and use it!
>
> I just published it on the dub registry in public domain (I hope Daniel Nielsen is ok with that. After all, it's just 3 lines of code)
>
> Package page: https://from.dub.pm/
>
>
> Have a good day and don't overthink simple things,
> Anton

It's good to see there are people who are still optimistic about dub. I remember that same feeling so many years ago :)

August 24, 2018
On Friday, 24 August 2018 at 10:58:29 UTC, aliak 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.
>
> One of the first things I do after a dub init is create a file called internal.d with the from template in it. My only gripe about this template is it's "autocompletion-able-ness" in IDEs and if that can be handled.
>
> I would not want it globally imported though, "from" is quite popular as an identifier and D doesn't let you use keywords as identifiers.
>
> Cheers,
> - Ali

Good to know others are using it.  Of course making it a core part of the language would mean that IDEs would be free to add support for it, whether it was added to `object.d` or with some other means such as a new syntax, i.e.

(import std.stdio).writefln(...)

I didn't quite understand your last point.  Adding `from` to `object.d` wouldn't make it a keyword, it would still be an identifier.  And you could still use it as an identifier in your own code.

August 24, 2018
On Friday, 24 August 2018 at 12:06:15 UTC, Anton Fediushin wrote:
>
> I just published it on the dub registry in public domain (I hope Daniel Nielsen is ok with that. After all, it's just 3 lines of code)
>
> Package page: https://from.dub.pm/
>

I'm fine with it, public domain is great! Although I would greatly prefer object.d since I don't use dub myself.

FYI Andrei has an open pull request:
https://github.com/dlang/druntime/pull/1756

But it's stalled due to a bug:
https://issues.dlang.org/show_bug.cgi?id=17181

August 24, 2018
On Friday, 24 August 2018 at 18:34:20 UTC, Daniel N wrote:I don't use dub myself.
On Friday, 24 August 2018 at 18:34:20 UTC, Daniel N wrote:
>
> FYI Andrei has an open pull request:
> https://github.com/dlang/druntime/pull/1756

Oh well I guess great minds think alike :)  Too bad it's been stalled due to a bug. I'd gladly fix it but alas, my pull requests are ignored :(
August 24, 2018
On Friday, 24 August 2018 at 13:48:09 UTC, Jonathan Marler wrote:
> On Friday, 24 August 2018 at 12:06:15 UTC, Anton Fediushin wrote:
>> On Friday, 24 August 2018 at 06:41:35 UTC, Jonathan Marler wrote:
>>> [...]
>>
>> There's no reason to mess with `object.d` or add it to phobos. Just make a dub package and use it!
>>
>> I just published it on the dub registry in public domain (I hope Daniel Nielsen is ok with that. After all, it's just 3 lines of code)
>>
>> Package page: https://from.dub.pm/
>>
>>
>> Have a good day and don't overthink simple things,
>> Anton
>
> It's good to see there are people who are still optimistic about dub. I remember that same feeling so many years ago :)

It got better, I think. It's far from being perfect but there's no way I'm building something like vibe-d manually or with *shivers* make.
August 24, 2018
On Friday, 24 August 2018 at 18:34:20 UTC, Daniel N wrote:
> On Friday, 24 August 2018 at 12:06:15 UTC, Anton Fediushin wrote:
>>
>> I just published it on the dub registry in public domain (I hope Daniel Nielsen is ok with that. After all, it's just 3 lines of code)
>>
>> Package page: https://from.dub.pm/
>>
>
> I'm fine with it, public domain is great! Although I would greatly prefer object.d since I don't use dub myself.
>
> FYI Andrei has an open pull request:
> https://github.com/dlang/druntime/pull/1756
>
> But it's stalled due to a bug:
> https://issues.dlang.org/show_bug.cgi?id=17181

Thanks. This PR is year and a half old so I'm not sure if we'll see it merged this year at all. Fingers crossed.
« First   ‹ Prev
1 2 3