Re: readonly member (but assignable at constructor time)

2018-04-27 Thread lempiji via Digitalmars-d-learn
On Friday, 27 April 2018 at 02:59:16 UTC, Dr.No wrote: In C# you can have a readonly member assignable either at declaration or constructor time, like this: class C { readonly myClass mc; this() { mc = new myClass(); } void doSomething() { mc = new myClass(); // wrong! re

Re: E-mail attachment with unwanted characters

2018-04-27 Thread Adam D. Ruppe via Digitalmars-d-learn
On Friday, 27 April 2018 at 17:57:26 UTC, Vino.B wrote: headers.insert(to!string(Base64.encode(Content)) ~ ".\r\n"); headers.insert("--" ~ boundary ~ "."); what are those random dots for?

E-mail attachment with unwanted characters

2018-04-27 Thread Vino.B via Digitalmars-d-learn
Hi All, Request your help, the below code is working as expected, but when I receive the attachment, the attachment contains the orginal text plus some unwanted characters like below, can someone help me how to remove these unwanted characters. Unwanted characters This is a test documento

Re: Get files from directory sorted by name

2018-04-27 Thread Dr.No via Digitalmars-d-learn
On Friday, 27 April 2018 at 14:48:00 UTC, Jesse Phillips wrote: On Thursday, 26 April 2018 at 16:59:45 UTC, Dr.No wrote: On Wednesday, 25 April 2018 at 19:25:11 UTC, Jesse Phillips wrote: On Wednesday, 25 April 2018 at 17:34:41 UTC, Dr.No wrote: Is there something implemented already to get the

Re: Making an .exe that executes source file inside itself.

2018-04-27 Thread IntegratedDimensions via Digitalmars-d-learn
On Friday, 27 April 2018 at 14:57:34 UTC, BoQsc wrote: On Friday, 27 April 2018 at 04:30:32 UTC, IntegratedDimensions wrote: On Thursday, 26 April 2018 at 06:18:25 UTC, BoQsc wrote: On Wednesday, 25 April 2018 at 20:44:10 UTC, u0_a183 wrote: On Wednesday, 25 April 2018 at 19:54:26 UTC, BoQsc w

Re: Making an .exe that executes source file inside itself.

2018-04-27 Thread BoQsc via Digitalmars-d-learn
On Friday, 27 April 2018 at 04:30:32 UTC, IntegratedDimensions wrote: On Thursday, 26 April 2018 at 06:18:25 UTC, BoQsc wrote: On Wednesday, 25 April 2018 at 20:44:10 UTC, u0_a183 wrote: On Wednesday, 25 April 2018 at 19:54:26 UTC, BoQsc wrote: On Wednesday, 25 April 2018 at 19:43:31 UTC, Jonat

Re: Get files from directory sorted by name

2018-04-27 Thread Jesse Phillips via Digitalmars-d-learn
On Thursday, 26 April 2018 at 16:59:45 UTC, Dr.No wrote: On Wednesday, 25 April 2018 at 19:25:11 UTC, Jesse Phillips wrote: On Wednesday, 25 April 2018 at 17:34:41 UTC, Dr.No wrote: Is there something implemented already to get the files from directory by name using D or I'm on my own and I hav

Re: Template to retrieve compile-time enum member from run-time enum member?

2018-04-27 Thread Alex via Digitalmars-d-learn
On Friday, 27 April 2018 at 13:43:47 UTC, Timoses wrote: `instantiateWith` gets called in three variations (menum.A, menum.B and menum.C). This causes instantiateWith to return TempStruct for each case of Temp... However, I was under the impression that a templated function will exist multi

Re: Auto expiring cache library

2018-04-27 Thread Jack Stouffer via Digitalmars-d-learn
On Friday, 27 April 2018 at 09:07:31 UTC, Pasqui23 wrote: I want a library that offers an in-memory data structure,such that I can write,for example: cache.insert(key,value,expiry) and I can retrieve the value with something like cache[key],unless it has passed expiry seconds. Can be done?W

Re: Template to retrieve compile-time enum member from run-time enum member?

2018-04-27 Thread Timoses via Digitalmars-d-learn
On Friday, 27 April 2018 at 13:39:22 UTC, Simen Kjærås wrote: That's an unfortunate error message. The problem is TempStruct is defined inside the Temp template. In the same way that struct Foo(T) {} is different for Foo!int and Foo!string, TempStruct is a different type for Temp!(menum.A) and

Re: Template to retrieve compile-time enum member from run-time enum member?

2018-04-27 Thread Simen Kjærås via Digitalmars-d-learn
On Friday, 27 April 2018 at 13:27:45 UTC, Timoses wrote: Bumped across another problem : / ``` import std.stdio; enum menum { A, B, C } void main() { foo(menum.A); } void foo(menum e) { writeln(instantiateWith!Temp(e)); } auto instantiateWith(alias Fn, T)(T x) if (is(T == enum)) {

Re: Template to retrieve compile-time enum member from run-time enum member?

2018-04-27 Thread Timoses via Digitalmars-d-learn
Bumped across another problem : / ``` import std.stdio; enum menum { A, B, C } void main() { foo(menum.A); } void foo(menum e) { writeln(instantiateWith!Temp(e)); } auto instantiateWith(alias Fn, T)(T x) if (is(T == enum)) { switch (x) { import std.traits : EnumMemb

Re: Idiomatic way to add examples to dub package

2018-04-27 Thread Basile B. via Digitalmars-d-learn
On Thursday, 26 April 2018 at 18:16:01 UTC, FreeSlave wrote: Most dub packages are libraries and should provide runnable examples. What's the current idiomatic way to add examples? IMO the most simple way (and the best too) is to put single file packages in the example folder, so that an exam

Re: Idiomatic way to add examples to dub package

2018-04-27 Thread drug via Digitalmars-d-learn
27.04.2018 13:58, Laurent Tréguier пишет: This is the way Rust packages handle their Cargo.lock file, if I'm not mistaken, and it seems reasonable to me Exactly

Re: Idiomatic way to add examples to dub package

2018-04-27 Thread Laurent Tréguier via Digitalmars-d-learn
On Friday, 27 April 2018 at 10:18:53 UTC, drug wrote: dub.selections.json shouldn't be included in case of library because it should be configured at import site. in case of application it has been configured and so dub.selections.json should be included. IMHO. This is the way Rust packages h

Re: Template to retrieve compile-time enum member from run-time enum member?

2018-04-27 Thread Timoses via Digitalmars-d-learn
On Thursday, 26 April 2018 at 16:46:11 UTC, Simen Kjærås wrote: The only step you're missing is the template needs to be instantiated inside the static foreach, like this: auto instantiateWith(alias Fn, T)(T x) if (is(T == enum)) { import std.traits : EnumMembers; switch (x) {

Re: Idiomatic way to add examples to dub package

2018-04-27 Thread drug via Digitalmars-d-learn
26.04.2018 21:16, FreeSlave пишет: Most dub packages are libraries and should provide runnable examples. What's the current idiomatic way to add examples? I used sub-packages with dependency on the library and "*" as version and running them as dub run :examplename Now I've noticed vibed uses a

Auto expiring cache library

2018-04-27 Thread Pasqui23 via Digitalmars-d-learn
I want a library that offers an in-memory data structure,such that I can write,for example: cache.insert(key,value,expiry) and I can retrieve the value with something like cache[key],unless it has passed expiry seconds. Can be done?What library should I use?

Re: Making an .exe that executes source file inside itself.

2018-04-27 Thread evilrat via Digitalmars-d-learn
On Thursday, 26 April 2018 at 10:06:57 UTC, JN wrote: On Wednesday, 25 April 2018 at 19:19:58 UTC, BoQsc wrote: Alternatively, I don't know about specifics how to implement it in D, but the key phrase you are looking for is "code hotswap" or "hot loading". It's being popularized right now in g