Re: Function template argument deduction

2018-04-06 Thread Uknown via Digitalmars-d-learn
On Saturday, 7 April 2018 at 05:10:05 UTC, Paul Backus wrote: I'm playing around with functional programming in D, and have run into a problem with the following code: [...] I don't see the error you are talking about: https://run.dlang.io/is/XWPIc1 Are you using the latest compiler?

Function template argument deduction

2018-04-06 Thread Paul Backus via Digitalmars-d-learn
I'm playing around with functional programming in D, and have run into a problem with the following code: --- list.d import std.variant: Algebraic, This, visit; import std.typecons: Tuple, tuple; struct Nil {} alias List(T) = Algebraic!( Nil, Tuple!(T, "head", This*, "tail") ); alias

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

2018-04-06 Thread Per Nordlöw via Digitalmars-d-learn
On Tuesday, 3 April 2018 at 09:14:28 UTC, Eduard Staniloiu wrote: So, say `reg` is your allocator, your workflow would be auto obj = reg.make!Type(args); /* do stuff */ reg.dispose(obj); // If Type has a __dtor, it will call obj.__dtor // and then reg.deallocate(obj) If I

Re: Making emplaceRef public

2018-04-06 Thread Seb via Digitalmars-d-learn
On Friday, 6 April 2018 at 17:46:26 UTC, Per Nordlöw wrote: Why isn't `std.conv.emplaceRef` public when `std.conv.emplace` is? AFAICT, emplaceRef(x, ...) is a bit more @safe than emplace(, ...) ... I had the same thoughts too: https://issues.dlang.org/show_bug.cgi?id=18701 We can even

Making emplaceRef public

2018-04-06 Thread Per Nordlöw via Digitalmars-d-learn
Why isn't `std.conv.emplaceRef` public when `std.conv.emplace` is? AFAICT, emplaceRef(x, ...) is a bit more @safe than emplace(, ...) ...

Re: Proper way to fix core.exception.UnicodeException@src\rt\util\utf.d(292): invalid UTF-8 sequence by File.readln()

2018-04-06 Thread Jonathan M Davis via Digitalmars-d-learn
On Friday, April 06, 2018 16:10:56 Dr.No via Digitalmars-d-learn wrote: > I'm reading line by line the lines from a CSV file provided by > the user which is assumed to be UTF8. But an user has provided an > > ANSI file which resulted in the error: >

Proper way to fix core.exception.UnicodeException@src\rt\util\utf.d(292): invalid UTF-8 sequence by File.readln()

2018-04-06 Thread Dr.No via Digitalmars-d-learn
I'm reading line by line the lines from a CSV file provided by the user which is assumed to be UTF8. But an user has provided an ANSI file which resulted in the error: core.exception.UnicodeException@src\rt\util\utf.d(292): invalid UTF-8 sequence (it happend when the user took the

Re: dustmite watch shell script (.test vs .lookahead.*)

2018-04-06 Thread Vladimir Panteleev via Digitalmars-d-learn
On Friday, 6 April 2018 at 15:35:59 UTC, Anonymouse wrote: The dustmite wiki[0] lists the following example script for use to monitor the reduction progress: Here's a more complete version that also works with -j: https://gist.github.com/CyberShadow/2e8f01895c248111c171e982313bb008

dustmite watch shell script (.test vs .lookahead.*)

2018-04-06 Thread Anonymouse via Digitalmars-d-learn
The dustmite wiki[0] lists the following example script for use to monitor the reduction progress: #!/bin/sh watch -cn 0.1 "zsh -c 'ls -al $1.reduced/**/*.d ; colordiff -ru $1.reduced $1.test'" This repeatedly compares the $1.reduced directory with a $1.test directory. The dustmite run

Re: c2 classes

2018-04-06 Thread Uknown via Digitalmars-d-learn
On Friday, 6 April 2018 at 14:43:25 UTC, Ali wrote: On Friday, 6 April 2018 at 14:31:49 UTC, Alex wrote: On Friday, 6 April 2018 at 13:41:50 UTC, aerto wrote: [...] A question from me, since I am also still learning D what is the difference between those following two declarations

Re: c2 classes

2018-04-06 Thread Ali via Digitalmars-d-learn
On Friday, 6 April 2018 at 14:31:49 UTC, Alex wrote: On Friday, 6 April 2018 at 13:41:50 UTC, aerto wrote: its possible to make this work ?? import std.stdio; class UUsers { public: int age; } class users { public: int[int] uid; } void main() { users newuser =

Re: c2 classes

2018-04-06 Thread Ali via Digitalmars-d-learn
On Friday, 6 April 2018 at 13:41:50 UTC, aerto wrote: its possible to make this work ?? import std.stdio; class UUsers { public: int age; } class users { public: int[int] uid; } void main() { users newuser = new users(); newuser.uid[0].age = 23;

Re: c2 classes

2018-04-06 Thread Alex via Digitalmars-d-learn
On Friday, 6 April 2018 at 13:41:50 UTC, aerto wrote: its possible to make this work ?? import std.stdio; class UUsers { public: int age; } class users { public: int[int] uid; } void main() { users newuser = new users(); newuser.uid[0].age = 23;

Re: Compile-time variables

2018-04-06 Thread Kayomn via Digitalmars-d-learn
On Friday, 6 April 2018 at 14:15:08 UTC, Kayomn wrote: On Friday, 6 April 2018 at 13:55:55 UTC, nkm1 wrote: [...] Figured I had a handle on how it worked doing but guess not. One final question, however. [...] Nevermind, I'm blind. I missed the post-increment in newID().

Re: Compile-time variables

2018-04-06 Thread Kayomn via Digitalmars-d-learn
On Friday, 6 April 2018 at 13:55:55 UTC, nkm1 wrote: On Friday, 6 April 2018 at 13:10:23 UTC, Kayomn wrote: ID tags are unique and spsecific to the class type. There shouldn't be more than one type ID assigned to one class type. The idea behind what it is I am doing is I am implementing a

Re: Compile-time variables

2018-04-06 Thread nkm1 via Digitalmars-d-learn
On Friday, 6 April 2018 at 13:10:23 UTC, Kayomn wrote: ID tags are unique and spsecific to the class type. There shouldn't be more than one type ID assigned to one class type. The idea behind what it is I am doing is I am implementing a solution to getting a type index, similar to

c2 classes

2018-04-06 Thread aerto via Digitalmars-d-learn
its possible to make this work ?? import std.stdio; class UUsers { public: int age; } class users { public: int[int] uid; } void main() { users newuser = new users(); newuser.uid[0].age = 23; writeln(newuser.uid[0].age); }

Re: Compile-time variables

2018-04-06 Thread Kayomn via Digitalmars-d-learn
Besides this, I tried something with types used as user defined attributes. https://dlang.org/spec/attribute.html#uda Automatic compile time tagging is not my speciality, however, I think is also achievable with mixins somehow? But I don't know how to workaround the bug

Re: Compile-time variables

2018-04-06 Thread aliak via Digitalmars-d-learn
On Friday, 6 April 2018 at 02:20:29 UTC, Kayomn wrote: Wrong example code, here's the correct example: switch (queryString(childJson,"type")) { case (typeof (Sprite).name): child =

Re: Compile-time variables

2018-04-06 Thread Alex via Digitalmars-d-learn
On Friday, 6 April 2018 at 02:20:29 UTC, Kayomn wrote: Wrong example code, here's the correct example: switch (queryString(childJson,"type")) { case (typeof (Sprite).name): child =