Re: SMTP Mail

2018-04-10 Thread Vino via Digitalmars-d-learn
On Monday, 9 April 2018 at 19:19:53 UTC, Adam D. Ruppe wrote: On Monday, 9 April 2018 at 15:38:55 UTC, Vino.B wrote: Thank you very much, I copied your folder arsd under the phobes folder in c:\D\... and the program was placed on my desktop and tried to execute it from the desktop via rdmd.

Re: SMTP Mail

2018-04-10 Thread Adam D. Ruppe via Digitalmars-d-learn
On Tuesday, 10 April 2018 at 11:09:56 UTC, Vino wrote: Now the program works, but the attachment does not work as expected, message.addAttachment("text/plain", "C:\\Temp\\Test\Test1.txt", "Test"); What did you expect that "Test" argument to do if it was going to read the file as the

Re: How to destruct class instances allocated by a Region-allocator over a single GC block

2018-04-10 Thread rikki cattermole via Digitalmars-d-learn
On 11/04/2018 1:56 AM, Eduard Staniloiu wrote: On Monday, 9 April 2018 at 14:51:24 UTC, Per Nordlöw wrote: On Monday, 9 April 2018 at 13:51:47 UTC, Steven Schveighoffer wrote: Well, you know the type, because make returned it no? The contract is, you call obj = make!X(args), then you have to

Range length property

2018-04-10 Thread Nordlöw via Digitalmars-d-learn
Should ranges always provide a length property? If so, in which cases is a length property an advantage or a requirement?

Re: SMTP Mail

2018-04-10 Thread Vino via Digitalmars-d-learn
On Tuesday, 10 April 2018 at 13:51:02 UTC, Adam D. Ruppe wrote: On Tuesday, 10 April 2018 at 11:09:56 UTC, Vino wrote: Now the program works, but the attachment does not work as expected, message.addAttachment("text/plain", "C:\\Temp\\Test\Test1.txt", "Test"); What did you expect that

Re: Range length property

2018-04-10 Thread Adam D. Ruppe via Digitalmars-d-learn
On Tuesday, 10 April 2018 at 14:25:52 UTC, Nordlöw wrote: Should ranges always provide a length property? No. If so, in which cases is a length property an advantage or a requirement? Just provide it whenever it is cheap to do so. If you need to do complex calculations or especially loop

Re: SMTP Mail

2018-04-10 Thread Adam D. Ruppe via Digitalmars-d-learn
On Tuesday, 10 April 2018 at 15:10:44 UTC, Vino wrote: The variable "to" is of type string[] but we need it as Array!string The variable "Subject" but we need it as Array!string. You'll have to convert them yourself if that is a must, but why would you need that?

Re: Is std.variant.visit not @nogc?

2018-04-10 Thread aliak via Digitalmars-d-learn
On Tuesday, 10 April 2018 at 03:48:25 UTC, Paul Backus wrote: Nope! It's just a tagged union, almost exactly the same as what you'd write by hand in C. You can take a look at the source yourself, if you're curious---it's actually pretty simple:

Re: How to destruct class instances allocated by a Region-allocator over a single GC block

2018-04-10 Thread Eduard Staniloiu via Digitalmars-d-learn
On Monday, 9 April 2018 at 14:51:24 UTC, Per Nordlöw wrote: On Monday, 9 April 2018 at 13:51:47 UTC, Steven Schveighoffer wrote: Well, you know the type, because make returned it no? The contract is, you call obj = make!X(args), then you have to call dispose(obj), where obj is of the type X.

Re: Is std.variant.visit not @nogc?

2018-04-10 Thread Steven Schveighoffer via Digitalmars-d-learn
On 4/10/18 12:59 PM, Paul Backus wrote: On Tuesday, 10 April 2018 at 12:34:07 UTC, aliak wrote: Awesome! this is a neat trick: union {   AliasSeq!(T0, T1) values; } Is that usage documented somewhere, or is it somewhere in phobos maybe? Also, can Algebraic be fully replaced with this

Re: Range length property

2018-04-10 Thread Jonathan M Davis via Digitalmars-d-learn
On Tuesday, April 10, 2018 14:25:52 Nordlöw via Digitalmars-d-learn wrote: > Should ranges always provide a length property? > > If so, in which cases is a length property an advantage or a > requirement? Whether a range has a length property or not is primarily dependent on how efficient it is

Re: stirling numbers and multidimensional arrays

2018-04-10 Thread popgen via Digitalmars-d-learn
On Sunday, 8 April 2018 at 16:51:14 UTC, ag0aep6g wrote: On 04/08/2018 06:15 PM, popgen wrote: [...] [...] [...] [...] [...] Should it be `q <= k` here? You're using q as an index into an array of length k + 1. If you go up to i, you'll exceed that and go out of bounds. That you're

trouble building dlang.org

2018-04-10 Thread Zach Tollen via Digitalmars-d-learn
I'm trying to update the language spec. I have the standard dmd installed on my Mac in `~/dlang/dmd` using the install script from the website "curl -fsS https://dlang.org/install.sh | bash -s dmd". Okay, good, done. Now, according to: dlang.org/CONTRIBUTING.md: "git clone

Re: Is std.variant.visit not @nogc?

2018-04-10 Thread Paul Backus via Digitalmars-d-learn
On Tuesday, 10 April 2018 at 12:34:07 UTC, aliak wrote: Awesome! this is a neat trick: union { AliasSeq!(T0, T1) values; } Is that usage documented somewhere, or is it somewhere in phobos maybe? Also, can Algebraic be fully replaced with this version then or is there some functionality

Re: Destructor call

2018-04-10 Thread Steven Schveighoffer via Digitalmars-d-learn
On 4/10/18 3:24 PM, Jonathan M Davis wrote: On Tuesday, April 10, 2018 18:52:19 kinke via Digitalmars-d-learn wrote: On Tuesday, 10 April 2018 at 18:34:54 UTC, n0fun wrote: Why the destructor is called in the second case and why not in the first? The first case is RAII, where destruction

Re: Range length property

2018-04-10 Thread Nordlöw via Digitalmars-d-learn
On Tuesday, 10 April 2018 at 14:34:40 UTC, Adam D. Ruppe wrote: On Tuesday, 10 April 2018 at 14:25:52 UTC, Nordlöw wrote: Should ranges always provide a length property? No. If so, in which cases is a length property an advantage or a requirement? Just provide it whenever it is cheap to

Re: Destructor call

2018-04-10 Thread kinke via Digitalmars-d-learn
On Tuesday, 10 April 2018 at 18:34:54 UTC, n0fun wrote: Why the destructor is called in the second case and why not in the first? The first case is RAII, where destruction isn't done for not fully constructed instances. The second case is GC finalization at program shutdown and looks like a

Re: Destructor call

2018-04-10 Thread Jonathan M Davis via Digitalmars-d-learn
On Tuesday, April 10, 2018 18:52:19 kinke via Digitalmars-d-learn wrote: > On Tuesday, 10 April 2018 at 18:34:54 UTC, n0fun wrote: > > Why the destructor is called in the second case and why not in > > the first? > > The first case is RAII, where destruction isn't done for not > fully constructed

Destructor call

2018-04-10 Thread n0fun via Digitalmars-d-learn
import std.stdio; struct S(alias n) { this(int) { throw new Exception("Exception"); } ~this() { writeln("destructor " ~ n); } } void main() { writeln("--- 1 ---"); try { auto s = S!"1"(0); } catch (Exception) {} writeln("--- 2 ---");

Re: Range length property

2018-04-10 Thread Cym13 via Digitalmars-d-learn
On Tuesday, 10 April 2018 at 20:08:14 UTC, Jonathan M Davis wrote: On Tuesday, April 10, 2018 19:47:10 Nordlöw via Digitalmars-d-learn wrote: On Tuesday, 10 April 2018 at 14:34:40 UTC, Adam D. Ruppe wrote: > On Tuesday, 10 April 2018 at 14:25:52 UTC, Nordlöw wrote: >> Should ranges always

Re: Should "a is b" compile if a and b have unrelated classes?

2018-04-10 Thread Jonathan M Davis via Digitalmars-d-learn
On Tuesday, April 10, 2018 21:52:22 Michael Coulombe via Digitalmars-d-learn wrote: > I had a bug in my code that was messing me up for a while, and it > boiled down to an identity check between two Object references > with unrelated static types, like below: > > class A {} > class B {} > void

Re: Range length property

2018-04-10 Thread H. S. Teoh via Digitalmars-d-learn
On Tue, Apr 10, 2018 at 10:07:40PM +, Cym13 via Digitalmars-d-learn wrote: [...] > On the other hand I don't think the end user should have to scratch > his head to find the length of a range, especially if it's not trivial > to get (say, O(log n) kind of case). Therefore exposing a method in

Re: Range length property

2018-04-10 Thread Jonathan M Davis via Digitalmars-d-learn
On Tuesday, April 10, 2018 22:07:40 Cym13 via Digitalmars-d-learn wrote: > On Tuesday, 10 April 2018 at 20:08:14 UTC, Jonathan M Davis wrote: > > On Tuesday, April 10, 2018 19:47:10 Nordlöw via > > > > Digitalmars-d-learn wrote: > >> On Tuesday, 10 April 2018 at 14:34:40 UTC, Adam D. Ruppe wrote:

Re: Range length property

2018-04-10 Thread Steven Schveighoffer via Digitalmars-d-learn
On 4/10/18 4:08 PM, Jonathan M Davis wrote: On Tuesday, April 10, 2018 19:47:10 Nordlöw via Digitalmars-d-learn wrote: I'm thinking of my own container Hashmap having its range ByKeyValue requiring one extra word of memory to store the iteration count which, in turn, can be used to calculate

Re: Range length property

2018-04-10 Thread Per Nordlöw via Digitalmars-d-learn
On Tuesday, 10 April 2018 at 20:16:18 UTC, Steven Schveighoffer wrote: e.g. std.array.array is going to pre-allocate an array of the correct length and fill it in, vs. appending each element as it gets them from the range. Personally, I would store the length because typically a container

Should "a is b" compile if a and b have unrelated classes?

2018-04-10 Thread Michael Coulombe via Digitalmars-d-learn
I had a bug in my code that was messing me up for a while, and it boiled down to an identity check between two Object references with unrelated static types, like below: class A {} class B {} void main() { A a = new A; B b = new B; if (a is b) {} // compiles } I was surprised that

Re: Range length property

2018-04-10 Thread Jonathan M Davis via Digitalmars-d-learn
On Tuesday, April 10, 2018 19:47:10 Nordlöw via Digitalmars-d-learn wrote: > On Tuesday, 10 April 2018 at 14:34:40 UTC, Adam D. Ruppe wrote: > > On Tuesday, 10 April 2018 at 14:25:52 UTC, Nordlöw wrote: > >> Should ranges always provide a length property? > > > > No. > > > >> If so, in which cases

Re: Range length property

2018-04-10 Thread Steven Schveighoffer via Digitalmars-d-learn
On 4/10/18 6:07 PM, Cym13 wrote: On Tuesday, 10 April 2018 at 20:08:14 UTC, Jonathan M Davis wrote: On Tuesday, April 10, 2018 19:47:10 Nordlöw via Digitalmars-d-learn wrote: On Tuesday, 10 April 2018 at 14:34:40 UTC, Adam D. Ruppe wrote: > On Tuesday, 10 April 2018 at 14:25:52 UTC, Nordlöw

Re: Should "a is b" compile if a and b have unrelated classes?

2018-04-10 Thread Steven Schveighoffer via Digitalmars-d-learn
On 4/10/18 5:52 PM, Michael Coulombe wrote: I had a bug in my code that was messing me up for a while, and it boiled down to an identity check between two Object references with unrelated static types, like below: class A {} class B {} void main() {     A a = new A;     B b = new B;     if

Re: Strange Thread Causing Duplicating `writeln`

2018-04-10 Thread Steven Schveighoffer via Digitalmars-d-learn
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 compilation line? dmd -run file.d I am on Window 10 btw. It's a

Re: Parse .eml files

2018-04-10 Thread bachmeier via Digitalmars-d-learn
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 Google brings someone here, this is a complete working