Infer return type from assignment

2018-04-11 Thread ixid via Digitalmars-d-learn
Is it possible to infer a template's return type from what it's assigned to? If not is this a difficult or worthless feature to add? OUT fun(IN, OUT)(IN value) { return value.to!OUT; } void main() { float a = 5.0; int b = fun(a); }

Re: Infer return type from assignment

2018-04-11 Thread Adam D. Ruppe via Digitalmars-d-learn
On Wednesday, 11 April 2018 at 14:26:53 UTC, ixid wrote: Is it possible to infer a template's return type from what it's assigned to? If not is this a difficult or worthless feature to add? Not really. The function call needs to make sense by itself: fun(a) needs to be a complete thing for a

Re: Infer return type from assignment

2018-04-11 Thread ixid via Digitalmars-d-learn
On Wednesday, 11 April 2018 at 14:33:06 UTC, Adam D. Ruppe wrote: On Wednesday, 11 April 2018 at 14:26:53 UTC, ixid wrote: Is it possible to infer a template's return type from what it's assigned to? If not is this a difficult or worthless feature to add? Not really. The function call needs t

Re: Infer return type from assignment

2018-04-11 Thread Steven Schveighoffer via Digitalmars-d-learn
On 4/11/18 10:26 AM, ixid wrote: Is it possible to infer a template's return type from what it's assigned to? If not is this a difficult or worthless feature to add? OUT fun(IN, OUT)(IN value) {     return value.to!OUT; } void main() {     float a = 5.0;     int b = fun(a); } Sort of: vo

Re: Parse .eml files

2018-04-11 Thread Martin Tschierschke via Digitalmars-d-learn
On Wednesday, 11 April 2018 at 02:37:39 UTC, bachmeier wrote: On Monday, 9 April 2018 at 19:17:20 UTC, Adam D. Ruppe wrote: [...] I had a chance to try this out and it worked without a problem. I did have to download color.d in addition to the other dependencies you listed. In the event that

Escaping address of

2018-04-11 Thread Nick Treleaven via Digitalmars-d-learn
Is this a known bug? With v2.079.0, with or without -dip1000: @safe unittest { struct S { int i; } auto p = &S().i; } The address of field `i` should not escape, right? It's also incorrectly allowed when using an lvalue of S (when -dip1000 is not present).

Re: Escaping address of

2018-04-11 Thread Jonathan M Davis via Digitalmars-d-learn
On Wednesday, April 11, 2018 16:08:06 Nick Treleaven via Digitalmars-d-learn wrote: > Is this a known bug? With v2.079.0, with or without -dip1000: > > @safe unittest > { > struct S > { > int i; > } > auto p = &S().i; > } > > The address of field `i` should not escape,

Hospitals Depending On Telephone Interpretation Services to Communicate With Patients Speaking Different Languages

2018-04-11 Thread markmst via Digitalmars-d-learn
A healthcare facility called River's Edge Hospital and Clinic in Minnesota is using a special video interpretation service that can connect an interpreter with a patient through a video conference to offer necessary interpretation services.If the patient feels that there is an inadequacy in the

Is using function() in templates possible at all?

2018-04-11 Thread Sjoerd Nijboer via Digitalmars-d-learn
I am trying to do a binary insert into my sorted array. To sort classes and structs I would like to give a delegate `(t) => t.myValue` to sort on that value whitout having to implement an interface or specifically declare opCmp for every class I want to have sorted. After all, I might want one

Re: Strange Thread Causing Duplicating `writeln`

2018-04-11 Thread Jonathan via Digitalmars-d-learn
On Tuesday, 10 April 2018 at 23:59:08 UTC, Steven Schveighoffer wrote: On 4/9/18 6:56 PM, Jonathan wrote: On Monday, 9 April 2018 at 22:53:31 UTC, Jonathan wrote: On Monday, 9 April 2018 at 22:49:07 UTC, Cym13 wrote: I don't know, but I can't reproduce either with dmd or ldc. What was your com

Re: Is using function() in templates possible at all?

2018-04-11 Thread Alex via Digitalmars-d-learn
On Wednesday, 11 April 2018 at 21:07:03 UTC, Sjoerd Nijboer wrote: class SortedList(T, int function(T) comparer) I would say, alias template parameter is your friend. https://dlang.org/spec/template.html#TemplateAliasParameter ´´´ import std.stdio; import std.range; void main() { aut

Re: Is using function() in templates possible at all?

2018-04-11 Thread Sjoerd Nijboer via Digitalmars-d-learn
On Wednesday, 11 April 2018 at 21:29:27 UTC, Alex wrote: I would say, alias template parameter is your friend. https://dlang.org/spec/template.html#TemplateAliasParameter class SortedList(T, alias comparer) It works, thank you! But just to be shure, there's no way to have this more strongly t

Re: Parse .eml files

2018-04-11 Thread bachmeier via Digitalmars-d-learn
On Wednesday, 11 April 2018 at 15:20:08 UTC, Martin Tschierschke wrote: My question in the moment is, how do I invoke Thunderbird to display a certain single mail (or maildir) file? How do I use Thunderbird as the client, to show, to answer or to forward these mails. An alternative would be to

Re: Is using function() in templates possible at all?

2018-04-11 Thread Nicholas Wilson via Digitalmars-d-learn
On Wednesday, 11 April 2018 at 22:13:33 UTC, Sjoerd Nijboer wrote: On Wednesday, 11 April 2018 at 21:29:27 UTC, Alex wrote: I would say, alias template parameter is your friend. https://dlang.org/spec/template.html#TemplateAliasParameter class SortedList(T, alias comparer) It works, thank you

Re: Escaping address of

2018-04-11 Thread Uknown via Digitalmars-d-learn
On Wednesday, 11 April 2018 at 16:25:20 UTC, Jonathan M Davis wrote: [...] Adding a destructor makes the compiler return an error about lifetimes, with or without -dip1000 https://run.dlang.io/is/ddXqNu

Passing directory as compiler argument not finding file

2018-04-11 Thread Jamie via Digitalmars-d-learn
With a directory structure as follows: run/ A/ a.d Where a.d is: === module A.d; I'm attempting to compile from the run/ directory. If I run with dmd ../A/a.d it compiles successfully, however if I pass it the directory dmd -I=../A a.d it doesn't compi

Re: Passing directory as compiler argument not finding file

2018-04-11 Thread Nicholas Wilson via Digitalmars-d-learn
On Thursday, 12 April 2018 at 06:22:30 UTC, Nicholas Wilson wrote: On Thursday, 12 April 2018 at 05:39:21 UTC, Jamie wrote: Am I using the -I compiler option incorrectly? is it thinking /../A is an absolute path? try -I=./../A Er, scratch that. I see you already tried it.

Re: Passing directory as compiler argument not finding file

2018-04-11 Thread Nicholas Wilson via Digitalmars-d-learn
On Thursday, 12 April 2018 at 05:39:21 UTC, Jamie wrote: With a directory structure as follows: run/ A/ a.d Where a.d is: === module A.d; I'm attempting to compile from the run/ directory. If I run with dmd ../A/a.d it compiles successfully, however if I p

Re: Passing directory as compiler argument not finding file

2018-04-11 Thread Tony via Digitalmars-d-learn
On Thursday, 12 April 2018 at 05:39:21 UTC, Jamie wrote: Am I using the -I compiler option incorrectly? I believe so. I think it is for finding import files, not the files you are compiling. - -I=directory Look for imports also in

Spurious error: Process does not exist or is not a child process.

2018-04-11 Thread Andre Pany via Digitalmars-d-learn
Hi, I compiled a linux application on my pc (Windows subsystem for Linux) and copied it to AWS EMR (linux) system. The application should execute the console application "aws". Most of the time the exception "Process does not exist or is not a child process." is raised. If I execute the appl