Re: Can I speed up this log parsing script further?

2017-06-09 Thread rikki cattermole via Digitalmars-d-learn
On 09/06/2017 8:34 AM, uncorroded wrote: Hi guys, I am a beginner in D. As a project, I converted a log-parsing script in Python which we use at work, to D. This link was helpful - ( https://dlang.org/blog/2017/05/24/faster-command-line-tools-in-d/ ) I compiled it with dmd and ldc. The log

Re: Avast virus warning?

2017-06-05 Thread rikki cattermole via Digitalmars-d-learn
On 05/06/2017 5:31 PM, Anonymouse wrote: I just sent a pre-compiled .exe of my project to a friend, and his Avast anti-virus promptly quarantined it and sent it off for analysis. I tried sending him a Hello World[1] with the same results. Is this something common for d programs? Anything I

Re: D scripting in D

2017-06-03 Thread rikki cattermole via Digitalmars-d-learn
On 03/06/2017 4:43 PM, Lewis wrote: On Saturday, 3 June 2017 at 09:28:03 UTC, rikki cattermole wrote: A lot of this can be done by simply implementing shared libraries fully on Windows. There is a reason why TypeInfo doesn't cross the dll boundary right now. Sadly it isn't a high priority (and

Re: D scripting in D

2017-06-03 Thread rikki cattermole via Digitalmars-d-learn
On 03/06/2017 10:03 AM, Mike B Johnson wrote: On Saturday, 3 June 2017 at 00:02:54 UTC, Lewis wrote: On Friday, 2 June 2017 at 20:47:31 UTC, Mike B Johnson wrote: [...] For sure. I actually want to post the source code at some point, but the changes I made are very much set up specifically

Re: Out of memory error (even when using destroy())

2017-05-26 Thread rikki cattermole via Digitalmars-d-learn
On 26/05/2017 9:15 AM, realhet wrote: Thanks for the answer! But hey, the GC knows that is should not search for any pointers in those large blocks. And the buffer is full of 0-s at the start, so there can't be any 'false pointers' in it. And I think the GC will not search in it either. The

Re: Structure of platform specific vs non platform specific code

2017-05-09 Thread rikki cattermole via Digitalmars-d-learn
On 09/05/2017 7:08 PM, Igor wrote: On Tuesday, 9 May 2017 at 15:37:44 UTC, Stefan Koch wrote: On Tuesday, 9 May 2017 at 15:28:20 UTC, WhatMeWorry wrote: On Monday, 8 May 2017 at 21:16:53 UTC, Igor wrote: Hi, I am following Casey Muratori's Handmade Hero and writing it in DLang. This sounds

Re: Structure of platform specific vs non platform specific code

2017-05-09 Thread rikki cattermole via Digitalmars-d-learn
On 09/05/2017 2:53 PM, Jacob Carlborg wrote: On 2017-05-08 23:16, Igor wrote: Hi, I am following Casey Muratori's Handmade Hero and writing it in DLang. I got to Day 011: The Basics of Platform API Design where Casey explains the best way to structure platform specific vs non-platform specific

Re: Converting a string[] to char**

2017-05-08 Thread rikki cattermole via Digitalmars-d-learn
On 09/05/2017 5:22 AM, David Zhang wrote: Hi, I'm playing around with Vulkan, and part of its initialization code calls for an array of strings as char**. I've tried casting directly (cast(char**)) and breaking it down into an array of char*s (char*[]) before getting the pointer to its first

Re: Regex multiple matches

2017-04-13 Thread rikki cattermole via Digitalmars-d-learn
On 14/04/2017 3:54 AM, Jethro wrote: using the rule (?Pregex) e.g., (?P\w*)* how do we get at all the matches, e.g., Joe Bob Buddy? When I access the results captures they are are not arrays and I only ever get the first match even when I'm using matchAll. Pseudo code: foreach(result;

Re: Command Line Parsing

2017-04-12 Thread rikki cattermole via Digitalmars-d-learn
On 12/04/2017 10:51 AM, Russel Winder via Digitalmars-d-learn wrote: Are Argon https://github.com/markuslaker/Argon or darg https://github. com/jasonwhite/darg getting traction as the default command line handling system for D or are they just peripheral and everyone just uses std.getopt

Re: Dub, Git, Mercurial, Bazaar

2017-04-11 Thread rikki cattermole via Digitalmars-d-learn
On 11/04/2017 5:59 AM, Russel Winder via Digitalmars-d-learn wrote: Go only uses Git, Mercurial, or Bazaar for dependency handling. Rust (via Cargo) allows for a central repository, and Git (, and Mercurial ?) repositories. Dub appears only to allow for central repository, or have I missed it's

Re: Single exe vibe.d app

2017-04-11 Thread rikki cattermole via Digitalmars-d-learn
On 11/04/2017 8:08 AM, Suliman wrote: On Friday, 7 April 2017 at 07:15:44 UTC, rikki cattermole wrote: I'm going to give you a very bad but still a good place to begin with explanation. So, what is an executable? Well in modern operating systems that is a file with a very complex structure

Re: std.socket classes

2017-04-09 Thread rikki cattermole via Digitalmars-d-learn
On 09/04/2017 4:19 PM, Jonathan Marler wrote: On Sunday, 9 April 2017 at 15:04:29 UTC, rikki cattermole wrote: On 09/04/2017 3:56 PM, Jonathan Marler wrote: On Sunday, 9 April 2017 at 14:49:14 UTC, rikki cattermole wrote: Don't think too hard, times have changed since std.socket was written.

Re: std.socket classes

2017-04-09 Thread rikki cattermole via Digitalmars-d-learn
On 09/04/2017 3:56 PM, Jonathan Marler wrote: On Sunday, 9 April 2017 at 14:49:14 UTC, rikki cattermole wrote: Don't think too hard, times have changed since std.socket was written. It certainly isn't designed for high performance hence e.g. libasync. What an odd response... You don't think I

Re: std.socket classes

2017-04-09 Thread rikki cattermole via Digitalmars-d-learn
Don't think too hard, times have changed since std.socket was written. It certainly isn't designed for high performance hence e.g. libasync.

Re: Variable Arguments

2017-04-09 Thread rikki cattermole via Digitalmars-d-learn
On 09/04/2017 7:30 AM, Jethro wrote: void foo(A...)(A a) { foreach(aa; a) { for(int i = 0; i < a.length; i++) ... } } A can be strings or char, how can I easily deal with both? (e.g., a.length = 1 for a being a char... and also a[0] = a, so to speak). That is, I

Re: overring binary

2017-04-08 Thread rikki cattermole via Digitalmars-d-learn
On 08/04/2017 7:46 AM, Jethro wrote: I have a custom type and I'm trying to do things like x~1 and 1~x. I can get x~1 no problem by overriding the op "~" but how to I get 1~x to convert 1 in to typeof(x)? instead of x in to typeof(1) so to speak? I really want D to realize that 1~x is suppose

Re: Single exe vibe.d app

2017-04-07 Thread rikki cattermole via Digitalmars-d-learn
I'm going to give you a very bad but still a good place to begin with explanation. So, what is an executable? Well in modern operating systems that is a file with a very complex structure inside, like PE-COFF or ELF. It has a bunch of things as part of this, a dynamic relocation table,

Re: Experimental xml set up

2017-04-02 Thread rikki cattermole via Digitalmars-d-learn
On 02/04/2017 2:58 PM, Begah wrote: To load up 3D models in my application, i decided to use the COLLADA model format, to do that i need to be able to extract information out of an xml file. Since std.xml is going to be deprecated eventually, is opted to try and use std.experiment.xml. So i

Re: clz

2017-04-01 Thread rikki cattermole via Digitalmars-d-learn
On 02/04/2017 6:28 AM, Nicholas Wilson wrote: I have this c++ code with clang uint32_t val = 490560; int leading_zeros = __builtin_clz( val << 1); // equals 0 int leading_ones = __builtin_clz(~val << 1); // equals 1 return (lz == 0 ? lo - 1 : -lz); and want to translate it to D. import

Re: Need advice on using DUB registry

2017-04-01 Thread rikki cattermole via Digitalmars-d-learn
On 02/04/2017 2:37 AM, Eric wrote: I'm planning on some day putting a package in the DUB registry. My package is dependent on my "util" package which is a collection of stuff I use across all my projects. Does this mean I also have to put my util package in the DUB registry? Could I just make

Re: Why is this legal?

2017-03-29 Thread rikki cattermole via Digitalmars-d-learn
On 29/03/2017 10:50 AM, abad wrote: This works: class Foo { protected void bar() { writeln("hello from foo"); } } void main() { auto foo = new Foo; foo.bar(); } Is this on purpose and what's the rationale? http://dlang.org/spec/attribute.html#visibility_attributes

Re: How to continue after the book?

2017-03-28 Thread rikki cattermole via Digitalmars-d-learn
On 28/03/2017 8:27 AM, I Lindström wrote: After getting the basics down, how did you continue when learning programming in general? I do have a need for which I've been trying out a few languages and D seems by far the best for me. Should I just start doing that project and learn as I go by

Re: foreach, is and pointer

2017-03-26 Thread rikki cattermole via Digitalmars-d-learn
On 26/03/2017 7:52 AM, helxi wrote: What's the difference between 1. string x = "abcd"; foreach(character; x) write(character); and string x = "abcd"; foreach(character; x[0..$]) write(character); Hopefully the compiler is smart enough to ignore that slice (since its

Re: high performance client server solution in D?

2017-03-23 Thread rikki cattermole via Digitalmars-d-learn
On 24/03/2017 2:07 AM, biocyberman wrote: I am considering to use D and its library to build a high performance client-server application. The client will be a cross platform (Windows, Mac, Linux) GUI program that can synchronize analysis results with the remote central server, and analyze data

Re: Delay allocating class instance in stack.

2017-03-21 Thread rikki cattermole via Digitalmars-d-learn
You probably want[0] to allocate a class on the stack instead of doing this. [0] http://dlang.org/phobos/std_typecons.html#.scoped

Re: Enums and immutables

2017-03-18 Thread rikki cattermole via Digitalmars-d-learn
On 19/03/2017 1:22 AM, Oleg B wrote: Hello. I found strange behavior while casting enum array and immutable array. import std.stdio; void main() { enum arr = cast(ubyte[])[0,0,0,1,0,0,0,2,0,0,0,3,0,0,0,4]; auto arr1 = cast(void[])arr; immutable arr2 = cast(immutable(void)[])arr;

Re: real simple manifest constant question probably regret asking...

2017-03-15 Thread rikki cattermole via Digitalmars-d-learn
On 16/03/2017 4:27 PM, WhatMeForget wrote: One of my D books says: "an enum declared without any braces is called a manifest constant." The example shows, enum string author = "Mike Parker"; Is this equivalent to const string author = "Mike Parker"; or immutable string author = "Mike Parker";

Re: Can i using D & LLVM & SDL2 for Android?

2017-03-13 Thread rikki cattermole via Digitalmars-d-learn
On 14/03/2017 6:08 AM, Joakim wrote: On Monday, 13 March 2017 at 09:33:39 UTC, rikki cattermole wrote: On 13/03/2017 7:48 PM, Joakim wrote: [...] Why exactly doesn't the Android port support dlopen, dlsym and dlclose? It is provided by the NDK libc. At least according to this[0]. [0]

Re: Can i using D & LLVM & SDL2 for Android?

2017-03-13 Thread rikki cattermole via Digitalmars-d-learn
On 13/03/2017 7:48 PM, Joakim wrote: On Thursday, 9 March 2017 at 10:35:18 UTC, dummy wrote: On Wednesday, 8 March 2017 at 10:24:24 UTC, Joakim wrote: On Tuesday, 7 March 2017 at 12:06:48 UTC, dummy wrote: Just thought. I do want to know. :-) As far as I know is, * LDC2 woring on NDK(yah!)

Re: TLS

2017-03-09 Thread rikki cattermole via Digitalmars-d-learn
On 10/03/2017 8:06 PM, M-exe wrote: On Friday, 10 March 2017 at 06:46:03 UTC, rikki cattermole wrote: On 10/03/2017 7:41 PM, M-exe wrote: I found that D is great language, but for my own reasons I'm trying to use it without TLS at all. Can the TLS directory be avoided? (compiling on windows)

Re: TLS

2017-03-09 Thread rikki cattermole via Digitalmars-d-learn
On 10/03/2017 7:41 PM, M-exe wrote: I found that D is great language, but for my own reasons I'm trying to use it without TLS at all. Can the TLS directory be avoided? (compiling on windows) I mean, can it avoided without losing GC and main language features? I found out that also when with

Re: Where do you test syntax of D regexp online?

2017-03-09 Thread rikki cattermole via Digitalmars-d-learn
On 10/03/2017 5:14 AM, Suliman wrote: Adding "r" helped: auto bigCodeBlock = regex(r"`{3}[\s\S]*?`{3}"); But now output is: [["```\r\nvoid foo()\r\n{\r\n\twriteln(\"ppp\");\r\n}\r\n```"]] But I do not \r\n\ symbols... \r\n is Windows new line characters.

Re: Where do you test syntax of D regexp online?

2017-03-09 Thread rikki cattermole via Digitalmars-d-learn
On 10/03/2017 4:17 AM, Suliman wrote: I would use dpaste and write a quick script but here is where I think your problem is: regex("/.*/g") It should be: regex(".*", "g") As per[0]. [0] http://dlang.org/phobos/std_regex.html#.regex Sorry, but what regexp are you talking? There is nothing

Re: Where do you test syntax of D regexp online?

2017-03-09 Thread rikki cattermole via Digitalmars-d-learn
On 10/03/2017 3:50 AM, Suliman wrote: I wrote two regexp: auto inlineCodeBlock = regex("`(.*?)`"); // --> `(.*?)` auto bigCodeBlock = regex("/`{3}[\\s\\S]*?`{3}/g"); // --> `{3}[\s\S]*?`{3} First for for selection inline code block. Second for

Re: core.sys.windows.winldap

2017-03-09 Thread rikki cattermole via Digitalmars-d-learn
On 09/03/2017 11:52 PM, WebFreak001 wrote: On Thursday, 9 March 2017 at 10:44:00 UTC, rikki cattermole wrote: On 09/03/2017 11:19 PM, WebFreak001 wrote: ... Import libs like static libraries adhere to the same specs of PE-COFF versus OMF. So if you want things to work without much hassle,

Re: core.sys.windows.winldap

2017-03-09 Thread rikki cattermole via Digitalmars-d-learn
On 09/03/2017 11:19 PM, WebFreak001 wrote: I tried using core.sys.windows.winldap (winldap.h) but I get linker errors when I try to run my code. I tried copying Wldap32.lib from my Windows Kits folder but then optlink always says Error 43 Not a Valid Library File. I simply use `dub test` to

Re: index of ddocs

2017-03-06 Thread rikki cattermole via Digitalmars-d-learn
On 06/03/2017 11:25 PM, Christian Köstlin wrote: Hi, I have a small dub-based application project with several modules (it's not a vibe.d project). I can easily create ddocs for the modules by running dub build --build=docs. I am missing at the moment a page, that shows the contents of the

Re: DMD JSON output

2017-02-25 Thread rikki cattermole via Digitalmars-d-learn
On 26/02/2017 4:01 PM, ANtlord wrote: Hello! I've encroutered intresting tool of DMD. It is dump of AST in JSON format (dmd -X main.d). But I it contains only declaration of methods, templates and structs. It doesn't contain statements like a variables or nested functions inside function's body.

Re: [Beginner]Variable length arrays

2017-02-25 Thread rikki cattermole via Digitalmars-d-learn
On 26/02/2017 3:31 AM, helxi wrote: I am trying to create an array which has a user defined size. However the following program is not compiling: import std.stdio; void main(){ write("Enter your array size: "); int n; readf(" %s", ); int[n] arr; //<-Error: variable input cannot

Re: segmentation fault with Object.factory()

2017-02-19 Thread rikki cattermole via Digitalmars-d-learn
On 19/02/2017 11:06 PM, berni wrote: I get a segmentation fault, when I run this program: void main() { A bar = cast(A)Object.factory("AA"); bar.foo(); } class A{ abstract void foo(); } class AA:A { override void foo() {} } The call of bar.foo() is, where the segmentation fault

Re: usage of ref foreach with variadic functions fails with "cannot be ref"

2017-02-11 Thread rikki cattermole via Digitalmars-d-learn
On 12/02/2017 3:41 AM, error wrote: I'm making a serializer that has a variadic write method that takes arbitrary params and serializes them; I want to do the same thing with a read method ( pass in your params by ref, and it populates them with data ) - however, I run into a compiler error -

Re: DerelictFmodStudio not found...

2017-02-10 Thread rikki cattermole via Digitalmars-d-learn
On 11/02/2017 5:38 PM, WhatMeWorry wrote: On Saturday, 11 February 2017 at 03:10:35 UTC, WhatMeWorry wrote: I followed the instructions for derelict.fmod. // Load the Fmod library. DerelictFmod.load(); // compiles fine. // Load the Fmod studio library. DerelictFmodStudio.load(); but

Re: GC question

2017-02-04 Thread rikki cattermole via Digitalmars-d-learn
On 05/02/2017 5:02 PM, thedeemon wrote: snip It may look so from a distance. But in my experience it's not that bad. In most software I did in D it did not matter really (it's either 64-bit or short lived programs) and the control D gives to choose how to deal with everything makes it all

Re: Minimum PR size

2017-01-31 Thread rikki cattermole via Digitalmars-d-learn
On 31/01/2017 11:36 PM, Jason Schroeder wrote: I am interested in contributing to D on GitHub, and was wondering if there is a minimum or preferabe minimum size of a pull request; e.g. I woukd like to work on increasing code coverage, and am wondering if a pull request with one additional line

Re: size of a string in bytes

2017-01-28 Thread rikki cattermole via Digitalmars-d-learn
On 29/01/2017 4:32 AM, Nestor wrote: On Saturday, 28 January 2017 at 14:56:03 UTC, rikki cattermole wrote: On 29/01/2017 3:51 AM, Nestor wrote: Hi, One can get the length of a string easily, however since strings are UTF-8, sometimes characters take more than one byte. I would like to know

Re: size of a string in bytes

2017-01-28 Thread rikki cattermole via Digitalmars-d-learn
On 29/01/2017 3:51 AM, Nestor wrote: Hi, One can get the length of a string easily, however since strings are UTF-8, sometimes characters take more than one byte. I would like to know then how many bytes does a string take, but this code didn't work as I expected: import std.stdio; void main()

Re: Confirming and uninstantiated struct

2017-01-23 Thread rikki cattermole via Digitalmars-d-learn
Structs are a value type and will always have a type that won't be null. If you want it to be nullable you will have to use pointers or classes (there is also Nullable in std.typecons but it won't work with is null). s/have a type that won't be null/have a value that won't be null/ My bad.

Re: Confirming and uninstantiated struct

2017-01-23 Thread rikki cattermole via Digitalmars-d-learn
On 24/01/2017 2:57 AM, aberba wrote: How do I verify this struct has no value Student getStudent() { ... Student s; if(condition) s = Student; return s; } auto stu = getStudent(); //which will work and is best? if (stu is null) //doesn't wrk. if (stu is Student.init) //will

Re: Compile to C?

2017-01-22 Thread rikki cattermole via Digitalmars-d-learn
On 23/01/2017 3:20 PM, Nestor wrote: On Monday, 23 January 2017 at 01:17:20 UTC, Adam D. Ruppe wrote: On Monday, 23 January 2017 at 01:12:21 UTC, Nestor wrote: You mean phobos, or system libraries? Phobos but mostly the druntime that interfaces with the system. I see, I was mostly thinking

Re: Why does multidimensional arrays not allocate properly?

2017-01-22 Thread rikki cattermole via Digitalmars-d-learn
On 22/01/2017 9:05 PM, Jot wrote: auto x = new int[][](n,m); But one cannot freely assign anywhere in x: x[3,6] = 4 crashes. I, can, of course, convert everything to a linear matrix and index by i+w*j, but what's the point of having multidimensional matrices in D if they don't allocate them

Re: Phobos: Determining number of hours or minutes or seconds till now

2017-01-19 Thread rikki cattermole via Digitalmars-d-learn
On 20/01/2017 9:29 AM, Rene Zwanenburg wrote: On Thursday, 19 January 2017 at 14:04:36 UTC, aberba wrote: Using the standard library, how do a get number of hours or seconds or minutes or days or months or years till current time from a past timestamp (like "2 mins ago")? Not with manual

Re: alias not valid with ~

2017-01-18 Thread rikki cattermole via Digitalmars-d-learn
On 19/01/2017 3:35 PM, Ignacious wrote: On Thursday, 19 January 2017 at 02:25:44 UTC, Adam D. Ruppe wrote: On Thursday, 19 January 2017 at 02:15:04 UTC, rikki cattermole wrote: On 19/01/2017 3:08 PM, Ignacious wrote: class Y { int y; alias y this; } class X { Y[] x; alias x

Re: alias not valid with ~

2017-01-18 Thread rikki cattermole via Digitalmars-d-learn
On 19/01/2017 3:25 PM, Adam D. Ruppe wrote: On Thursday, 19 January 2017 at 02:15:04 UTC, rikki cattermole wrote: On 19/01/2017 3:08 PM, Ignacious wrote: class Y { int y; alias y this; } class X { Y[] x; alias x this; } This should not fail: X x = new X; x ~= 3; Yes, it

Re: alias not valid with ~

2017-01-18 Thread rikki cattermole via Digitalmars-d-learn
On 19/01/2017 3:08 PM, Ignacious wrote: class Y { int y; alias y this; } class X { Y[] x; alias x this; } Yet X ~= 3; fails. 3 should be implicitly convertible to Y and then ~ should assign it. ? This should not fail: X x = new X; x ~= 3; This should fail as x is a member

Re: Dub, SDL, and Subpackages

2017-01-16 Thread rikki cattermole via Digitalmars-d-learn
On 16/01/2017 11:14 PM, Russel Winder via Digitalmars-d-learn wrote: The Dub manual says that: name "mylib" targetType "none" dependency "mylib:component1" version="*" subPackage { name "component1" targetType "library" sourcePaths "component1/source"

Re: Convert duration to years?

2017-01-14 Thread rikki cattermole via Digitalmars-d-learn
On 15/01/2017 4:43 PM, Nestor wrote: Hi, I would simply like to get someone's age, but I am a little lost with time and date functions. I can already get the duration, but after reading the documentation it's unclear to me how to convert that into years. See following code: import std.stdio;

Re: Stack Space & Ackermann

2017-01-04 Thread rikki cattermole via Digitalmars-d-learn
On 05/01/2017 7:03 PM, Era Scarecrow wrote: On Thursday, 5 January 2017 at 04:53:23 UTC, rikki cattermole wrote: Well, you could create a fiber[0]. Fibers allow you to set the stack size at runtime. [0] http://dlang.org/phobos/core_thread.html#.Fiber.this Well that certainly does seem to

Re: Stack Space & Ackermann

2017-01-04 Thread rikki cattermole via Digitalmars-d-learn
On 05/01/2017 5:50 PM, Era Scarecrow wrote: Well re-watched a video regarding the Ackermann function which is a heavily recursive code which may or may not ever give a result in our lifetimes. However relying on the power of memoize I quickly find that when the program dies (from 5 minutes or

Re: Dub build for x86_64 on windows

2017-01-01 Thread rikki cattermole via Digitalmars-d-learn
On 02/01/2017 5:12 PM, Andrey wrote: Hello! it is possible to build my application for x86_64 platform? In С++ I can settings mingw_w64 for this. When using dub: $ dub build --arch=x86_64 For Windows you will need to have Visual Studio installed for linker + libc.

Re: Standard output does not get flushed in cygwin?

2017-01-01 Thread rikki cattermole via Digitalmars-d-learn
On 02/01/2017 1:48 AM, Anonymouse wrote: Try this in a cygwin terminal: import std.stdio; import core.thread; void main() { foreach (i; 0..10) { writeln(i); Thread.sleep(1.seconds); } } This program will not output i, wait a second and then output i+1, etc. It will

Re: Unittest hangs on completion

2016-12-30 Thread rikki cattermole via Digitalmars-d-learn
On 31/12/2016 3:32 PM, David Zhang wrote: On Saturday, 31 December 2016 at 02:03:07 UTC, rikki cattermole wrote: As it should, current is never reassigned. You only need one var, next. Of course I didn't read the entire thread chain so, I'm probably missing something. import

Re: Unittest hangs on completion

2016-12-30 Thread rikki cattermole via Digitalmars-d-learn
On 31/12/2016 2:52 PM, David Zhang wrote: Extracting everything into a main() also causes the application to hang. ie: struct S { S* next; } S* _foo; foreach (e; 0 .. 10) _foo = theAllocator.make!S(_foo); S* next, current; next = current = _foo; while (next) { next =

Re: Get fils at compile-time

2016-12-14 Thread rikki cattermole via Digitalmars-d-learn
On 15/12/2016 8:11 PM, Bauss wrote: On Thursday, 15 December 2016 at 02:58:11 UTC, rikki cattermole wrote: I did a lot of work in this area. There are two solutions: 1) Use a package file and public import all modules via it. From this do some form of 'registration' in a module constructor.

Re: Get fils at compile-time

2016-12-14 Thread rikki cattermole via Digitalmars-d-learn
I did a lot of work in this area. There are two solutions: 1) Use a package file and public import all modules via it. From this do some form of 'registration' in a module constructor. Using __traits(allMembers, retrieve the imports and with that the other modules. 2) Before compilation create

Re: Issue with dmd, linker, visualD on windows 10

2016-12-14 Thread rikki cattermole via Digitalmars-d-learn
On 15/12/2016 12:06 AM, aberba wrote: I am trying to get a fellow to try D but just setting up on windows 10 has been headache. He's currently remote. Here's the problem. (Note I'm a Linux user and haven't used windows 10) 1. He installed dmd 2 but the command "dmd" is not recognized. He

Re: rtInfo()

2016-12-14 Thread rikki cattermole via Digitalmars-d-learn
On 14/12/2016 11:52 PM, Satoshi wrote: Hello, is rtInfo() already used by GC? I need to store some data for each class so I'm using this template and m_rtInfo in TypeInfo_Class but now it seems that GC is not working properly in some cases. Thanks. Doesn't look like it.

Re: reading from file

2016-12-13 Thread rikki cattermole via Digitalmars-d-learn
On 14/12/2016 4:42 AM, Namal wrote: Hello, comming from C++, I find it hard to remember and understand how reading from file should be done in D. Especially since I am not very good in functional programming. So I have a file which looks like this: 1,2,3,4 5,6,7,8 9,11,11,12 and so on How

Re: Strange memory corruption / codegen bug?

2016-12-11 Thread rikki cattermole via Digitalmars-d-learn
On 12/12/2016 12:43 AM, TheGag96 wrote: On Sunday, 11 December 2016 at 11:17:50 UTC, rikki cattermole wrote: Not public, please pastebin. https://github.com/TheGag96/evo-pacman/blob/master/source/pacman/tree.d#L135 I just put it on GitHub. No idea why the repo wasn't public even after I set

Re: Strange memory corruption / codegen bug?

2016-12-11 Thread rikki cattermole via Digitalmars-d-learn
On 12/12/2016 12:15 AM, TheGag96 wrote: I was porting my Evolutionary Computing homework written in Python over to D, and I've come across this bug I cannot for the life of me figure out. https://gitlab.com/TheGag96/evo-pacman/blob/master/source/pacman/tree.d#L139 Not public, please pastebin.

Re: The program exits unexpectedly

2016-12-09 Thread rikki cattermole via Digitalmars-d-learn
On 09/12/2016 10:26 PM, unDEFER wrote: Hello! I'm starting port my program to Windows _without_ Cygwin and found big trouble. My main thread exits unexpectedly without any diagnostic messages. The second thread still lives when it happens. The visual studio debugger say that thread exits with

Re: The order of libraries makes error in dub

2016-12-05 Thread rikki cattermole via Digitalmars-d-learn
On 06/12/2016 3:59 AM, Mike Parker wrote: snip Also, let's be clear here, the errors you saw above are linker errors, not DUB errors. This one in particular is very common on Windows when using the MS linker: warning LNK4098: defaultlib 'LIBCMTD' conflicts with use of other libs; use

Re: using assignment statement as conditional in a where

2016-12-03 Thread rikki cattermole via Digitalmars-d-learn
On 04/12/2016 7:26 AM, dan wrote: On Saturday, 3 December 2016 at 09:03:25 UTC, rikki cattermole wrote: On 03/12/2016 9:55 PM, dan wrote: [...] If you can use another compiler do so, gdc is on an old frontend/Phobos now. I recommend ldc or you know the reference compiler dmd if

Re: using assignment statement as conditional in a where

2016-12-03 Thread rikki cattermole via Digitalmars-d-learn
On 03/12/2016 9:55 PM, dan wrote: In c, you can have code like this: static void wtest( void ) { int f; while ( ( f = some_val( ) ) ) { printf(" our value is now: %d\n", f ); } } gcc compiles this without warning or error (at least if you use the double parentheses to assure the

Re: Use class template as a type

2016-11-28 Thread rikki cattermole via Digitalmars-d-learn
On 29/11/2016 3:35 AM, Namespace wrote: We have a handy dandy syntax for this: if (MyClassInt subclass = cast(MyClassInt)value) { writeln(subclass.value); } If it doesn't cast to said type (it will be null) that branch won't execute. Just out of interest: it looks like a dynamic_cast in

Re: Use class template as a type

2016-11-28 Thread rikki cattermole via Digitalmars-d-learn
On 29/11/2016 2:56 AM, dm wrote: On Monday, 28 November 2016 at 11:30:23 UTC, rikki cattermole wrote: In your case I'd just swap out ``MyClass[] someArray;`` to ``Object[] someArray;``. But only because there are no members added without the extra typing in MyClass. Remember types in

Re: Use class template as a type

2016-11-28 Thread rikki cattermole via Digitalmars-d-learn
In your case I'd just swap out ``MyClass[] someArray;`` to ``Object[] someArray;``. But only because there are no members added without the extra typing in MyClass. Remember types in meta-programming in D are not erased, they exist in the assembly and are unique. Unlike Java who did the

Re: Char representation

2016-11-22 Thread rikki cattermole via Digitalmars-d-learn
On 23/11/2016 2:29 AM, RazvanN wrote: Given the following code: char[5] a = ['a', 'b', 'c', 'd', 'e']; alias Range = char[]; writeln(is(ElementType!Range == char)); One would expect that the program will print true. In fact, it prints false and I noticed that if Range is char[], wchar[],

Re: null this

2016-11-21 Thread rikki cattermole via Digitalmars-d-learn
On 21/11/2016 11:25 PM, Satoshi wrote: Hello, how can calling method on local struct throw "null this"? struct is initialized by .init and have default values. struct Foo { Bar bar; static struct Bar { float x, y, z; } Bar getBar() { return bar; } } then Foo foo =

Re: Using mixin in array declarations

2016-11-19 Thread rikki cattermole via Digitalmars-d-learn
On 19/11/2016 10:46 PM, Marduk wrote: In C one can do the following: # define N 10 double M[N][N]; In D I would like to achieve the same result. I tried with: mixin("int N = 10;"); double[N][N] M; but the compiler (DMD) complained with Error: variable N cannot be read at compile time.

Re: -fPIC related error compiling hello_world.d with dmd

2016-11-18 Thread rikki cattermole via Digitalmars-d-learn
On 19/11/2016 3:05 AM, Alessandro wrote: On Friday, 18 November 2016 at 13:12:14 UTC, rikki cattermole wrote: On 19/11/2016 2:09 AM, Alessandro wrote: Hi everyone, I'm almost ashamed to ask help on this... I used dmd/dub on an arch linux machine for some time in the past without any problem.

Re: -fPIC related error compiling hello_world.d with dmd

2016-11-18 Thread rikki cattermole via Digitalmars-d-learn
On 19/11/2016 2:09 AM, Alessandro wrote: Hi everyone, I'm almost ashamed to ask help on this... I used dmd/dub on an arch linux machine for some time in the past without any problem. Now I'm experiencing a strange problem after switching to a debian jessie (testing) machine when compiling even

Re: Question on syntax

2016-11-08 Thread rikki cattermole via Digitalmars-d-learn
On 09/11/2016 7:28 PM, Jim wrote: Hi, I'm a very experienced C++ programmer, looking at a program written in D. D is similar enough to C++ and Java that I have no problem understanding it - except for one thing. I think I may have figured it out, but I want to confirm my understanding. What

Re: fPIC Error

2016-11-03 Thread rikki cattermole via Digitalmars-d-learn
Took me a while to replicate your build environment but it looks like a false alarm. rikki@debian:/tmp/test$ dmd test.d rikki@debian:/tmp/test$ file test test: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux

Re: is there "this"?

2016-11-01 Thread rikki cattermole via Digitalmars-d-learn
On 02/11/2016 3:17 PM, Konstantin Kutsevalov wrote: The question is simple. Is there something like "this" word for classes? For example: ``` class CLS { int numberValue; public this(numberValue) { // how can I put the local numberValue to class property? // in

Re: Is TDPL an accurate description of the D language today?

2016-10-28 Thread rikki cattermole via Digitalmars-d-learn
On 29/10/2016 1:35 AM, Mark wrote: On Tuesday, 27 September 2016 at 17:53:39 UTC, Steven Schveighoffer wrote: On 9/27/16 1:38 PM, Mark wrote: I've been going through Andrei's excellent book and I noticed that the latest printing is from 2010. Since D is still a very young language I can

Re: How to kill whole application if child thread raises an exception?

2016-10-26 Thread rikki cattermole via Digitalmars-d-learn
On 26/10/2016 11:03 PM, dm wrote: On Wednesday, 26 October 2016 at 09:43:10 UTC, rikki cattermole wrote: ```D void entryPoint(alias func)() { try { func(); } catch (Exception e) { import std.stdio; writeln(e.toString()); } } void main() { auto tid =

Re: How to kill whole application if child thread raises an exception?

2016-10-26 Thread rikki cattermole via Digitalmars-d-learn
Basically when you spawn a thread giving the function, you pass it through another function which will catch any exceptions not normally caught. Of course this really should be the default behavior but somebody else may be more of a help here. And it is pseudo code, so please don't expect

Re: How to kill whole application if child thread raises an exception?

2016-10-26 Thread rikki cattermole via Digitalmars-d-learn
On 26/10/2016 9:42 PM, dm wrote: Hi. I tried code below: import std.concurrency; import std.stdio; void func() { throw new Exception("I'm an exception"); } void main() { auto tID = spawn(); foreach(line; stdin.byLine) send(tID, ""); } I expect my application will die

Re: New to D

2016-10-21 Thread rikki cattermole via Digitalmars-d-learn
On 22/10/2016 6:25 PM, Mark wrote: Hello, Im a 3rd year Comp Sci student in Edmonton Alberta, Canada. Ive learned how to use C, and dabbled in C++ in school. Im also in a Oop course using Java. I picked up the book The D Programming Language by Alexrei Alexandrescu a few years ago. Lately Im

Re: Meta-programming detecting anonymous unions inside structs.

2016-10-21 Thread rikki cattermole via Digitalmars-d-learn
On 21/10/2016 9:13 PM, TheFlyingFiddle wrote: On Friday, 21 October 2016 at 07:56:27 UTC, rikki cattermole wrote: You're gonna have to use UDA's for that. Yes, to do the serialization you're right. But my usecase for this is for error reporting. Basically any struct that contains unions

Re: Meta-programming detecting anonymous unions inside structs.

2016-10-21 Thread rikki cattermole via Digitalmars-d-learn
On 21/10/2016 8:55 PM, TheFlyingFiddle wrote: I am trying to port a serialization library I wrote in Lua some time ago. I've ran into a problem relating to types with anonymous unions inside. Given this code: enum Kind { none = 0, array, integer, floating, } struct Foo { Kind

Re: Typesafe variadic argument taking struct

2016-10-20 Thread rikki cattermole via Digitalmars-d-learn
On 21/10/2016 1:48 AM, Satoshi wrote: Hello, why ... cannot be used with structs? struct Foo { this(int a) { } } void bar(Foo foo...) { } bar(42); Because an int is not a Foo.

Re: From Python to Dlang

2016-10-18 Thread rikki cattermole via Digitalmars-d-learn
On 19/10/2016 1:03 AM, Alfred Newman wrote: Hello and greetings, I'm a brand new D developer coming from Python. I decided to move to D, mainly because it's a compiled language and has a great runtime speed (and I don't feel confortable at Cython environment at all). And of course, D has a

Re: Render SVG To Display And Update Periodically

2016-10-16 Thread rikki cattermole via Digitalmars-d-learn
On 17/10/2016 2:20 PM, Jason C. Wells wrote: I have in mind a project to render instruments (speed, pressure, position) to a screen using SVG. I am able to produce the SVG easily enough. What I am looking for is a library/canvas/toolkit that I can use in D inside of a loop and update the

Re: Missing functionality in std.process?

2016-10-15 Thread rikki cattermole via Digitalmars-d-learn
On 15/10/2016 5:33 AM, Andre Pany wrote: Hi, I developed an application which starts and stops other applications like NodeJS HTTP server applications or Java Tomee Servlets. A typical NodeJS application has a process tree of 4-5 levels. I had to switch really fast from std.process

Re: Current State of the GC?

2016-10-10 Thread rikki cattermole via Digitalmars-d-learn
On 11/10/2016 10:12 AM, Martin Lundgren wrote: I've been reading up a bit on the D garbage collector. Seen mostly negative things about it. I've also seen a lot of proposals and what not, but not much about the current state of things. The latest page I can find about it is 2015H1. It mentions

Re: dub command line in config?

2016-10-09 Thread rikki cattermole via Digitalmars-d-learn
On 09/10/2016 9:17 PM, Jinx wrote: On Sunday, 9 October 2016 at 06:55:44 UTC, Mike Parker wrote: On Sunday, 9 October 2016 at 05:34:36 UTC, Jinx wrote: huh? Yes it is necessary. How hard could it be. Editing a script is the same as editing the json file and creates junk files. Why make

Re: Beginner DUB user question...

2016-10-08 Thread rikki cattermole via Digitalmars-d-learn
On 09/10/2016 2:24 PM, WhatMeWorry wrote: I've got a little hello_window DUB project which uses these dependencies: dependency "derelict-util" version="~>2.0.6" dependency "derelict-glfw3" version="~>3.1.0" dependency "derelict-gl3" version="~>1.0.19" dependency "derelict-fi"

Re: Rust-like collect in D

2016-10-06 Thread rikki cattermole via Digitalmars-d-learn
On 07/10/2016 3:32 AM, Nordlöw wrote: Is there a concept in D similar to Rust's `collect`: https://doc.rust-lang.org/std/iter/trait.Iterator.html#method.collect If not, I'm eager to implement it to support D-style containers. What would the desired interface look like? Perhaps:

<    1   2   3   4   5   6   7   8   9   10   >