Re: Workaround for DIP 1005

2017-02-14 Thread John Colvin via Digitalmars-d
On Thursday, 9 February 2017 at 05:40:01 UTC, Jonathan M Davis wrote: with(import std.datetime) auto foo(SysTime st1, SysTime st2, Duration d); There is of course the middle way: with(from!q{std.datetime}) I would love to be able to use `with` and have the language accept it in a wider range

Re: Workaround for DIP 1005

2017-02-14 Thread Meta via Digitalmars-d
On Thursday, 9 February 2017 at 05:40:01 UTC, Jonathan M Davis wrote: On Friday, February 03, 2017 14:43:01 Dominikus Dittes Scherkl via Digitalmars-d wrote: Any thoughts? This is really cool, but I have a couple of concerns about this and how it seems deficient in comparison to DIP 1005. I

Re: Workaround for DIP 1005

2017-02-10 Thread Nick Treleaven via Digitalmars-d
On Thursday, 9 February 2017 at 05:40:01 UTC, Jonathan M Davis wrote: auto func(alias pred, R)(R range) if(from!"std.range.primitives".isInputRange!R && is(typeof(pred(range.front)) == bool)) {...} but you can't import std.range.primitives.front to make dynamic arrays work, whereas

Re: Workaround for DIP 1005

2017-02-10 Thread Dominikus Dittes Scherkl via Digitalmars-d
On Friday, 10 February 2017 at 13:28:43 UTC, Dominikus Dittes Scherkl wrote: Sorry, accidentally hit some key-combination that immediately send the message that was not yet complete. With my original proposal you would write auto foo(foo.SysTime st1, foo.SysTime st2,

Re: Workaround for DIP 1005

2017-02-10 Thread Dominikus Dittes Scherkl via Digitalmars-d
On Thursday, 9 February 2017 at 05:40:01 UTC, Jonathan M Davis wrote: On Friday, February 03, 2017 14:43:01 Dominikus Dittes Scherkl via Digitalmars-d wrote: Any thoughts? This is really cool, but I have a couple of concerns about this and how it seems deficient in comparison to DIP 1005.

Re: Workaround for DIP 1005

2017-02-09 Thread Daniel N via Digitalmars-d
On Thursday, 9 February 2017 at 05:40:01 UTC, Jonathan M Davis wrote: The import is only listed once, whereas with this technique, you have to list it for each symbol. e.g. auto foo(from!"std.datetime".SysTime st1, from!"std.datetime".SysTime st2, from!"std.datetime".Duration

Re: Workaround for DIP 1005

2017-02-08 Thread Jonathan M Davis via Digitalmars-d
On Friday, February 03, 2017 14:43:01 Dominikus Dittes Scherkl via Digitalmars-d wrote: > Any thoughts? This is really cool, but I have a couple of concerns about this and how it seems deficient in comparison to DIP 1005. I mentioned it in Andrei's PR for this, but no one has responded to my

Re: Workaround for DIP 1005

2017-02-07 Thread Walter Bright via Digitalmars-d
On 2/7/2017 7:00 AM, Andrea Fontana wrote: I don't understand why we can't use a template like: auto fun_time(SysTime)(SysTime tm) { import std.datetime; static assert (is(SysTime == std.datetime.SysTime)); return tm; } void main() { import std.stdio; import std.datetime;

Re: Workaround for DIP 1005

2017-02-07 Thread Chris Wright via Digitalmars-d
On Tue, 07 Feb 2017 15:00:17 +, Andrea Fontana wrote: > I don't understand why we can't use a template like: You can. However, that makes things awkward when you want to pass that as a delegate. It makes it awkward to read. You don't get to specify the return type unless it happens to be

Re: Workaround for DIP 1005

2017-02-07 Thread Jack Stouffer via Digitalmars-d
On Tuesday, 7 February 2017 at 15:00:17 UTC, Andrea Fontana wrote: ... I think I misunderstood your comment. Please forgive the noise. I need more coffee

Re: Workaround for DIP 1005

2017-02-07 Thread Jack Stouffer via Digitalmars-d
On Tuesday, 7 February 2017 at 15:00:17 UTC, Andrea Fontana wrote: I don't understand why we can't use a template like: auto fun_time(SysTime)(SysTime tm) { import std.datetime; static assert (is(SysTime == std.datetime.SysTime)); return tm; } void main() { import std.stdio;

Re: Workaround for DIP 1005

2017-02-07 Thread Andrea Fontana via Digitalmars-d
On Friday, 3 February 2017 at 15:41:56 UTC, Daniel N wrote: On Friday, 3 February 2017 at 14:43:01 UTC, Dominikus Dittes Scherkl wrote: DIP 1005 provides new syntax to make it possible to avoid global imports. Any thoughts? I like it! template imp(string mod) { mixin("import imp = " ~ mod

Re: Workaround for DIP 1005

2017-02-04 Thread crimaniak via Digitalmars-d
On Saturday, 4 February 2017 at 11:56:52 UTC, Stefan Koch wrote: please refrain from insulting string-mixins. they are by far the most understandable of meta-programming facilities. Most understandable don't mean "good to use". We can do many things with it but it's really hack and easy way

Re: Workaround for DIP 1005

2017-02-04 Thread Stefan Koch via Digitalmars-d
On Saturday, 4 February 2017 at 11:50:50 UTC, crimaniak wrote: On Friday, 3 February 2017 at 21:23:22 UTC, Daniel Nielsen wrote: I just had to try one more thing. It never ceases to amaze me what is possible in D today. Yes, all except of good IDE and tooling. template imp(string mod) {

Re: Workaround for DIP 1005

2017-02-04 Thread crimaniak via Digitalmars-d
On Friday, 3 February 2017 at 21:23:22 UTC, Daniel Nielsen wrote: I just had to try one more thing. It never ceases to amaze me what is possible in D today. Yes, all except of good IDE and tooling. template imp(string mod) { mixin("import imp = " ~ mod ~ ";"); } ... because of string

Re: Workaround for DIP 1005

2017-02-03 Thread Daniel Nielsen via Digitalmars-d
On Friday, 3 February 2017 at 20:04:22 UTC, Daniel Nielsen wrote: On Friday, 3 February 2017 at 19:14:16 UTC, Andrei Alexandrescu wrote: Wow. This is... brilliant. Thanks for the great idea. I ran a few tests and it seems to be doing out of the box most of what we want with DIP1005 with no

Re: Workaround for DIP 1005

2017-02-03 Thread Daniel Nielsen via Digitalmars-d
On Friday, 3 February 2017 at 19:14:16 UTC, Andrei Alexandrescu wrote: Wow. This is... brilliant. Thanks for the great idea. I ran a few tests and it seems to be doing out of the box most of what we want with DIP1005 with no language change at all. Congratulations! Andrei Thank you very

Re: Workaround for DIP 1005

2017-02-03 Thread Andrei Alexandrescu via Digitalmars-d
On 2/3/17 2:14 PM, Andrei Alexandrescu wrote: On 2/3/17 10:41 AM, Daniel N wrote: On Friday, 3 February 2017 at 14:43:01 UTC, Dominikus Dittes Scherkl wrote: DIP 1005 provides new syntax to make it possible to avoid global imports. Any thoughts? I like it! template imp(string mod) {

Re: Workaround for DIP 1005

2017-02-03 Thread Andrei Alexandrescu via Digitalmars-d
On 2/3/17 10:41 AM, Daniel N wrote: On Friday, 3 February 2017 at 14:43:01 UTC, Dominikus Dittes Scherkl wrote: DIP 1005 provides new syntax to make it possible to avoid global imports. Any thoughts? I like it! template imp(string mod) { mixin("import imp = " ~ mod ~ ";"); } auto

Re: Workaround for DIP 1005

2017-02-03 Thread Chris Wright via Digitalmars-d
On Fri, 03 Feb 2017 14:43:01 +, Dominikus Dittes Scherkl wrote: > fun.ST fun() > { > import someModule.SomeType; > alias ST = SomeType; > ... > } What compiler version is this? I'm getting segfaults with both 2.072.2 and 2.073.0. Reported as

Re: Workaround for DIP 1005

2017-02-03 Thread Dominikus Dittes Scherkl via Digitalmars-d
On Friday, 3 February 2017 at 14:59:09 UTC, rikki cattermole wrote: On 04/02/2017 3:43 AM, Dominikus Dittes Scherkl wrote: DIP 1005 provides new syntax to make it possible to avoid global imports. But this can already be worked around with some nice trick: Any thoughts? Needless syntax

Re: Workaround for DIP 1005

2017-02-03 Thread Daniel N via Digitalmars-d
On Friday, 3 February 2017 at 14:43:01 UTC, Dominikus Dittes Scherkl wrote: DIP 1005 provides new syntax to make it possible to avoid global imports. Any thoughts? I like it! template imp(string mod) { mixin("import imp = " ~ mod ~ ";"); } auto fun_time(imp!"std.datetime".SysTime tm) {

Re: Workaround for DIP 1005

2017-02-03 Thread rikki cattermole via Digitalmars-d
On 04/02/2017 3:43 AM, Dominikus Dittes Scherkl wrote: DIP 1005 provides new syntax to make it possible to avoid global imports. Till now global imports are necessary if a function uses types declared in some imported module within it's declaration or definition (otherwise a local import will

Workaround for DIP 1005

2017-02-03 Thread Dominikus Dittes Scherkl via Digitalmars-d
DIP 1005 provides new syntax to make it possible to avoid global imports. Till now global imports are necessary if a function uses types declared in some imported module within it's declaration or definition (otherwise a local import will do). But this can already be worked around with some