Re: Module Name Resolution
On Wednesday, 26 October 2016 at 05:27:53 UTC, Jason C. Wells wrote: Hence the repeated advice to supply all the filenames on the command line. this is basically 'cause dmd doesn't automatically compile and link imported modules. it you won't specify module in dmd command line, dmd will only look for type declarations in that module, but will not compile any actual code from it. so the link stage fill fail, 'cause it will try to link with non-existing code. the easiest way to solve that is just pass all modules to dmd. or use rdmd -- it automatically process imports and invokes dmd with built module list (that is what i am using, for example).
Re: Module Name Resolution
On Wednesday, 26 October 2016 at 04:51:23 UTC, Jason C. Wells wrote: I am reading through Ketmar's iv.d/nanovg/package.d: module iv.nanovg; public import iv.nanovg.nanovg; This looks like three levels of hierarchy, but is it? it maps to "iv/nanovg/nanovg.d" according to dmd map rules. i used to have all the code in package.d, but later moved it out to nanovg.d. i.e. last name is always a file, everything before it is a directory. I'm a little confused because the corresponding directory in ketmar's source code is named "iv.d" rather than "iv" which is what I would have thought to find based on the import. this is a repository name. it is supposed to be named just "iv", and git names main directory by repository name if you are doing a simple clone. my bad, i should have made that clear. I see mention of a subpackage in my previous thread. Is this how a subpackage is implemented? actually, packages and subpackages are just a convenient terms for something that is not strictly defined in D. this is more a convention: if we'll place all the files in directory, say, "mypkg/a.d", "mypkg/b.d", and add package.d there as "mypkg/package.d", then we'll be able to just write "import mypkg;". dmd will automatically look for "mypkg/package.d" in this case. so, when you're writing "import iv.nanovg;", dmd looks for "iv/nanovg/package.d", and process it. package.d does more imports, so dmd loads 'em too. the only magic here is special "package.d" file.
Re: Module Name Resolution
Suddenly it occurs to me that the module namespace and the filesystem namespace do not necessarily have a one for one match, even though they do by default. When one specifies all the D source files on the command line, any differences between the module namespace and the filesystem namespace are handled automagically by dmd. The "module" declaration is the code by which the module namespace is manually defined. Hence the repeated advice to supply all the filenames on the command line.
Module Name Resolution
I am reading through: https://dlang.org/spec/module.html. I'll soon be working through a previous example provided by Mike Parker. I am reading through Ketmar's iv.d/nanovg/package.d: module iv.nanovg; public import iv.nanovg.nanovg; This looks like three levels of hierarchy, but is it? Should I interpret that import as: iv --nanovg --nanovg Perhaps it really means: iv.nanovg --nanovg I'm a little confused because the corresponding directory in ketmar's source code is named "iv.d" rather than "iv" which is what I would have thought to find based on the import. I see mention of a subpackage in my previous thread. Is this how a subpackage is implemented? Thanks, Jason
Re: vibe.d with explicit threads/threadpool instead of fibers
On Tuesday, 25 October 2016 at 21:23:21 UTC, Arun Chandrasekaran wrote: I am looking for a RESTful framework in D, which can interact with an existing backend processes (C++) via ZeroMQ and shared memory. I thought vibe.d might be a viable option. But I discussed with someone on Freenode #d and found that vibe.d doesn't support explicit threading [1]. I looked at vibe.d examples, one of them uses futures [1], which implies explicit thread handling is possible. But I'm not sure about pre-spawned threadpool. [1] https://github.com/rejectedsoftware/vibe.d/blob/master/examples/future/source/app.d
vibe.d with explicit threads/threadpool instead of fibers
I am looking for a RESTful framework in D, which can interact with an existing backend processes (C++) via ZeroMQ and shared memory. I thought vibe.d might be a viable option. But I discussed with someone on Freenode #d and found that vibe.d doesn't support explicit threading [1]. Can someone confirm the behaviour? Is it not possible to allocate a bunch of threads or a threadpool for vibe.d to work with? PS: We have this working already with C++ only solution where the frontend communication happens on protobuf over ZeroMQ. I'm just trying to migrate it to RESTful interface. [1] http://pastebin.com/cAw2yaYg
Re: getting started with web server - vibe.d dub giving link error
On Monday, 24 October 2016 at 04:46:34 UTC, aman wrote: On Sunday, 23 October 2016 at 19:23:04 UTC, Karabuta wrote: [...] Oh, I see. Actually it got installed auto-magically during dub installation I guess. Now I installed dmd with the script mention on the dlang download page. curl -fsS https://dlang.org/install.sh | bash -s dmd [...] Make sure you install all the vibe.d dependencies. You can refer to my blog post at https://aberba.github.io/2016/hello-world-app-with-the-vibe.d-web-framework/ under the "Setting up your development environment" section.
Re: Neural Networks / ML Libraries for D
On Tuesday, 25 October 2016 at 14:31:39 UTC, bachmeier wrote: On Tuesday, 25 October 2016 at 13:58:33 UTC, Saurabh Das wrote: [...] Installation amounts to installing a couple of R packages that I have on Bitbucket, as described on the project page. I have basic usage examples there as well. You can find the project here: https://bitbucket.org/bachmeil/embedr [...] This is excellent. I will try it out :) Thanks so much.
Re: Real Simple Question?
On 10/22/16 5:34 PM, WhatMeWorry wrote: On Saturday, 22 October 2016 at 20:51:14 UTC, Jonathan M Davis wrote: On Saturday, October 22, 2016 20:35:27 WhatMeWorry via Digitalmars-d-learn wrote: [...] Just put it in a separate module and then import it. e.g. file: mypackage/constants.d == module mypackage.constants; GLfloat[] vertices = [ // Positions // Texture Coords -0.5f, -0.5f, -0.5f, 0.0f, 0.0f, 0.5f, -0.5f, -0.5f, 1.0f, 0.0f, . (lots and lots of values) . ]; I would make this: immutable GLfloat[] vertices If you can do it. This will make it so it's a) accessible from pure functions, and b) will not create a separate thread-local copy for each thread (if you use threading). Ok, but now I'm getting these error in my new mypackage/constants.d ...\common\vertex_data.d(5,15): Error: undefined identifier 'GLfloat' ...\common\vertex_data.d(53,12): Error: undefined identifier 'vec3' It's difficult to know why without more code hints, but it appears that vertex_data.d needs to import the module that defines these types. Note that if you want to have an imported module provide these definitions from another module, then you need to public import the module. So for instance (guessing at your code, since I don't know what you have for import statements): mypackage/my_types.d: alias GLfloat = float; alias vec3 = GLfloat[3]; mypackage/constants.d: public import mypackage.my_types; // this allows importers of constants.d to see the types used GLfloat[] vertices = ... vertex_data.d: import mypackage.constants; // pulls in definitions from my_types.d -Steve
Re: New to D
On 10/22/16 1:25 AM, 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 really wanting to get into D, as It seems like a better version of C, and feels like java in a way. However; Ive run into a bit of a problem while writing some code. Im not sure if Im doing something wrong, or maybe the things Im using are depreciated?? Code Blocks does not give any messages as to what is going wrong. I haven't configured anything, and am not familiar with messing around with IDE settings. Its directly based off of the example on page 8. here is the code that does not compile: import std.stdio, std.string; void main() { ... } void dict() { uint[string] dictionary; foreach(line; stdin.byLine()) { //chunk = splitter(strip(line); ## errors because of splitter foreach(word; splitter(strip(line))) { ## errors because of splitter ?? if(word in dictionary) continue; //writeln(dictionary.length); ## gives 0 ?? auto newID = dictionary.length; dictionary[word] = newId; I will note, that in addition to the other comments, this is going to result in corruption. Simply put, the buffer that `line` uses is reused for each line. So the string data used inside the associative array is going to change. This will result in not finding words already added when using the `word in dictionary` check. You need to use dictionary[word.idup] = newId; This will duplicate the line into a GC string that will live as long as the AA uses it. Alternatively, you can use byLineCopy, but this needlessly copies the line for each iteration, when you may find all the words in the line are already added. -Steve
Re: Neural Networks / ML Libraries for D
On Tuesday, 25 October 2016 at 13:58:33 UTC, Saurabh Das wrote: Oh that sounds pretty cool. While I probably won't use it right now, embedding R inside D would be a good learning opportunity. Is it available on code.dlang.org or on GitHub? Thanks Saurabh Installation amounts to installing a couple of R packages that I have on Bitbucket, as described on the project page. I have basic usage examples there as well. You can find the project here: https://bitbucket.org/bachmeil/embedr This is barebones, designed only to allow passing of data (via pointers) between the two languages and to execute R code from a D program. I have other libraries that do various things (call D functions from R, optimization, quadratic programming, ARMA estimation, etc.) but haven't yet had time to write examples or documentation. If you would like to see any of that or have questions about the embedr library, you can email me at the address given on this page: http://www.k-state.edu/economics/staff/bios/bachmeier.html
Re: Neural Networks / ML Libraries for D
On Tuesday, 25 October 2016 at 13:56:45 UTC, Saurabh Das wrote: On Tuesday, 25 October 2016 at 11:55:27 UTC, maarten van damme wrote: There is mir https://github.com/libmir/mir which is geared towards machine learning, I don't know if it has anything about neural networks, I've yet to use it. If you're only interested in neural networks, I've used FANN (a C library) together with D and it worked very well. 2016-10-25 13:17 GMT+02:00 Saurabh Das via Digitalmars-d-learn < digitalmars-d-learn@puremagic.com>: Hello, Are there any good ML libraries for D? In particular, looking for a neural network library currently. Any leads would be appreciated. Thanks, Saurabh I saw mir but it didn't seem to have anything for NNs. I'll give FANN a try. I used FANN with D too. And it's quite easy to use. Andrea
Re: Neural Networks / ML Libraries for D
On Tuesday, 25 October 2016 at 13:26:49 UTC, bachmeier wrote: On Tuesday, 25 October 2016 at 11:17:29 UTC, Saurabh Das wrote: Hello, Are there any good ML libraries for D? In particular, looking for a neural network library currently. Any leads would be appreciated. Thanks, Saurabh I have written a project to embed R inside D and vice versa for my research (currently Linux only). Any neural network library for R is trivially available inside D. Ideally these libraries would be written in D but I'm a strong believer in reusing working code. If this is something that is of interest, let me know. Oh that sounds pretty cool. While I probably won't use it right now, embedding R inside D would be a good learning opportunity. Is it available on code.dlang.org or on GitHub? Thanks Saurabh
Re: Neural Networks / ML Libraries for D
On Tuesday, 25 October 2016 at 11:55:27 UTC, maarten van damme wrote: There is mir https://github.com/libmir/mir which is geared towards machine learning, I don't know if it has anything about neural networks, I've yet to use it. If you're only interested in neural networks, I've used FANN (a C library) together with D and it worked very well. 2016-10-25 13:17 GMT+02:00 Saurabh Das via Digitalmars-d-learn < digitalmars-d-learn@puremagic.com>: Hello, Are there any good ML libraries for D? In particular, looking for a neural network library currently. Any leads would be appreciated. Thanks, Saurabh I saw mir but it didn't seem to have anything for NNs. I'll give FANN a try.
Re: Real Simple Question?
On Saturday, 22 October 2016 at 21:34:36 UTC, WhatMeWorry wrote: On Saturday, 22 October 2016 at 20:51:14 UTC, Jonathan M Davis wrote: [...] Ok, but now I'm getting these error in my new mypackage/constants.d ..\common\vertex_data.d(5,15): Error: undefined identifier 'GLfloat' ..\common\vertex_data.d(53,12): Error: undefined identifier 'vec3' Is there a way to just suck in the text from say a .txt file that would not be compiled before inclusion in main.d? You could format your array in JSON format, and read it in your program. That could be another solution.
Re: Neural Networks / ML Libraries for D
On Tuesday, 25 October 2016 at 11:17:29 UTC, Saurabh Das wrote: Hello, Are there any good ML libraries for D? In particular, looking for a neural network library currently. Any leads would be appreciated. Thanks, Saurabh I have written a project to embed R inside D and vice versa for my research (currently Linux only). Any neural network library for R is trivially available inside D. Ideally these libraries would be written in D but I'm a strong believer in reusing working code. If this is something that is of interest, let me know.
Re: Bug in std.allocator?
On 10/25/2016 11:30 AM, Benjamin Thaut wrote: Please consider the following program: [...] I would assume that this program should run forever and never run out of memory. But instead it triggers an assert inside alocator_list in pass 11. So I assume this is some bug in std.allocator? I can confirm the crash with 2.071.2. But it doesn't happen with 2.072.0-b2. So, bug that has already been fixed? Also whats interresting. The first allocation in each new pass is _not_ the last allocation to be freed. Instead it seems to "leak" one allocation each pass. From the output of the program: 229a290fd60 <- same 229a2932570 <- leaked? pass 11 229a290fd60 <- same Also looks ok with 2.072.0-b2: 7f448c7ccdb0 7f448c7cd200 pass 99 7f448c7cd200 7f448c7ccdb0
Re: Neural Networks / ML Libraries for D
There is mir https://github.com/libmir/mir which is geared towards machine learning, I don't know if it has anything about neural networks, I've yet to use it. If you're only interested in neural networks, I've used FANN (a C library) together with D and it worked very well. 2016-10-25 13:17 GMT+02:00 Saurabh Das via Digitalmars-d-learn < digitalmars-d-learn@puremagic.com>: > Hello, > > Are there any good ML libraries for D? In particular, looking for a neural > network library currently. Any leads would be appreciated. > > Thanks, > Saurabh > >
Neural Networks / ML Libraries for D
Hello, Are there any good ML libraries for D? In particular, looking for a neural network library currently. Any leads would be appreciated. Thanks, Saurabh
Bug in std.allocator?
Please consider the following program: import std.experimental.allocator.mallocator; import std.experimental.allocator.building_blocks.allocator_list : AllocatorList; import std.experimental.allocator.building_blocks.free_list; import std.experimental.allocator; import std.stdio; enum uint size = 1104; alias ScalableFreeList = AllocatorList!((n) => ContiguousFreeList!(Mallocator, 0, unbounded)(size * 128, size) ); void main(string[] args) { void[][20] allocs; ScalableFreeList allocator; for(int i=0; i < 100; i++) { writefln("pass %d", i); foreach(ref alloc; allocs) { alloc = allocator.allocate(size); writefln("%x", alloc.ptr); } foreach(alloc; allocs) { allocator.deallocate(alloc); } } } I would assume that this program should run forever and never run out of memory. But instead it triggers an assert inside alocator_list in pass 11. So I assume this is some bug in std.allocator? Also whats interresting. The first allocation in each new pass is _not_ the last allocation to be freed. Instead it seems to "leak" one allocation each pass. From the output of the program: 229a290fd60 <- same 229a2932570 <- leaked? pass 11 229a290fd60 <- same Or can anyone see a bug in my program? Kind Regards Benjamin Thaut
Re: Repeat and chunks
On Monday, 24 October 2016 at 16:09:44 UTC, ag0aep6g wrote: On 10/24/2016 04:25 PM, Dorian Haglund wrote: The following code crashes with DMD64 D Compiler v2.071.2: import std.algorithm; import std.stdio; import std.range; int main() { repeat(8, 10).chunks(3).writeln(); return 0; } Looks like a bug. Doesn't happen with 2.072.0-b2, so it has apparently already been fixed. Ok! I'll wait for the next release then. Thanks.