Pointer to template types?

2014-04-28 Thread Chris via Digitalmars-d-learn
I need an array that contains pointers to types created via template. To stick to my usual example: Person!(string) How can I make an array with pointers to concrete instances of Person!(string)? Something like this only with pointers, i.e. buf holds pointers to concrete Person!(string)s:

Re: Pointer to template types?

2014-04-28 Thread Chris via Digitalmars-d-learn
On Monday, 28 April 2014 at 10:32:18 UTC, bearophile wrote: Chris: I need an array that contains pointers to types created via template. To stick to my usual example: Person!(string) How can I make an array with pointers to concrete instances of Person!(string)? Every template creates a

Re: Pointer to template types?

2014-04-28 Thread Chris via Digitalmars-d-learn
On Monday, 28 April 2014 at 10:32:18 UTC, bearophile wrote: Chris: I need an array that contains pointers to types created via template. To stick to my usual example: Person!(string) How can I make an array with pointers to concrete instances of Person!(string)? Every template creates a

Re: Pointer to template types?

2014-04-28 Thread Chris via Digitalmars-d-learn
On Monday, 28 April 2014 at 10:44:18 UTC, Rene Zwanenburg wrote: On Monday, 28 April 2014 at 10:40:49 UTC, Chris wrote: So there is no way of filling an array with something like Person!(string) *pptr; foreach(person; people) { buf ~= person; } Person!(string)*[] arr; Like this?

Re: Pointer to template types?

2014-04-29 Thread Chris via Digitalmars-d-learn
On Tuesday, 29 April 2014 at 04:44:39 UTC, Jesse Phillips wrote: On Monday, 28 April 2014 at 10:40:49 UTC, Chris wrote: Person!(string) *pptr; Just wanted to point out, the above is C style and not recommended. Person!(string)* pptr, pptr2, pptr3; In D the pointer is part of the type

Cost of assoc array?

2014-05-14 Thread Chris via Digitalmars-d-learn
I have code that uses the following: string[][size_t] myArray; 1. myArray = [0:[t, o, m], 1:[s, m, i, th]]; However, I've found out that I never need an assoc array and a linear array would be just fine, as in 2. myArray = [[t, o, m], [s, m, i, th]]; Is there any huge difference as regards

Re: Cost of assoc array?

2014-05-14 Thread Chris via Digitalmars-d-learn
On Wednesday, 14 May 2014 at 10:20:51 UTC, bearophile wrote: Chris: Is there any huge difference as regards performance and memory footprint between the two? Or is 2. basically 1. under the hood? An associative array is a rather more complex data structure, so if you don't need it, use

Re: Cost of assoc array?

2014-05-14 Thread Chris via Digitalmars-d-learn
On Wednesday, 14 May 2014 at 11:13:10 UTC, John Colvin wrote: On Wednesday, 14 May 2014 at 09:38:10 UTC, Chris wrote: I have code that uses the following: string[][size_t] myArray; 1. myArray = [0:[t, o, m], 1:[s, m, i, th]]; However, I've found out that I never need an assoc array and a

Re: Cost of assoc array?

2014-05-14 Thread Chris via Digitalmars-d-learn
On Wednesday, 14 May 2014 at 13:31:53 UTC, dennis luehring wrote: Am 14.05.2014 15:20, schrieb Chris: Profiling is not really feasible, because for this to work properly, I would have to introduce the change first to be able to compare both. Nothing worse than carefully changing things only to

Re: Cost of assoc array?

2014-05-14 Thread Chris via Digitalmars-d-learn
On Wednesday, 14 May 2014 at 13:44:40 UTC, John Colvin wrote: Yes, they are much faster. Normal array indexing is equivalent to *(myArray.ptr + index) plus an optional bounds check, whereas associative array indexing is a much, much larger job. Why were you using associative arrays in the

Bounds check

2014-05-23 Thread Chris via Digitalmars-d-learn
The following: import std.stdio; void main() { int[5] arg; arg[10] = 3; // Compiler says (of course): Error: array index 10 is out of bounds arg[0 .. 5] } import std.stdio; void main() { int[5] arg; foreach (i; 0..10) { arg[i] = i; } } Compiler says nothing, but

Re: What are the best std algo for testing a range implementation ?

2014-05-27 Thread Chris via Digitalmars-d-learn
On Tuesday, 27 May 2014 at 10:50:54 UTC, BicMedium wrote: Let's say I have a set of containers, using a D-unfriendly-semantic. They rather use a kind of ADA vocabulary (according to https://en.wikipedia.org/wiki/Deque). I want to make them range-aware. If the input/output ranges are easy to

Cost of .dup vs. instantiation

2014-05-28 Thread Chris via Digitalmars-d-learn
I use Appender to fill an array. The Appender is a class variable and is not instantiated with each function call to save instantiation. However, the return value or the function must be dup'ed, like so: Appender!(MyType[]) append; public auto doSomething() { scope (exit) { // clear append

Re: Cost of .dup vs. instantiation

2014-05-29 Thread Chris via Digitalmars-d-learn
On Wednesday, 28 May 2014 at 17:33:19 UTC, monarch_dodra wrote: On Wednesday, 28 May 2014 at 14:36:25 UTC, Chris wrote: I use Appender to fill an array. The Appender is a class variable and is not instantiated with each function call to save instantiation. However, the return value or the

Re: Cost of .dup vs. instantiation

2014-05-29 Thread Chris via Digitalmars-d-learn
On Thursday, 29 May 2014 at 12:04:35 UTC, monarch_dodra wrote: On Thursday, 29 May 2014 at 08:49:10 UTC, Chris wrote: monarch_dodra: Hm. This last point might be an issue. If I process a large input (text in this case) then I might run into trouble with append as a class variable. I also had

dub: strange behavior

2014-06-05 Thread Chris via Digitalmars-d-learn
I've just had the case where after changing the code and running $ dub nothing changed in the output. I couldn't make sense of it. Then I ran $ dub --force and the output was as expected. Has this happened to anyone. I think I came across this before.

splitter for strings

2014-06-09 Thread Chris via Digitalmars-d-learn
Say I wanna split a string that contains hyphens. If I use std.algorithm.splitter I end up with empty elements for each hyphen, e.g.: auto word = bla-bla; auto parts = appender!(string[]); w.splitter('-').copy(parts); // parts.data.length == 3 [bla, , bla] This is not ideal for my purposes,

Re: splitter for strings

2014-06-09 Thread Chris via Digitalmars-d-learn
On Monday, 9 June 2014 at 10:14:40 UTC, bearophile wrote: Chris: auto word = bla-bla; auto parts = appender!(string[]); w.splitter('-').copy(parts); // parts.data.length == 3 [bla, , bla] With the current dmd 2.066alpha this code: void main() { import std.stdio, std.string,

Re: splitter for strings

2014-06-09 Thread Chris via Digitalmars-d-learn
On Monday, 9 June 2014 at 10:54:09 UTC, monarch_dodra wrote: On Monday, 9 June 2014 at 10:23:16 UTC, Chris wrote: Ok, thanks. I'll keep that in mind for the next version. Seems to me to also work with 2.065 and 2.064. From the library reference: assert(equal(splitter(hello world, ' '), [

Re: splitter for strings

2014-06-09 Thread Chris via Digitalmars-d-learn
On Monday, 9 June 2014 at 11:16:18 UTC, monarch_dodra wrote: On Monday, 9 June 2014 at 11:04:12 UTC, Chris wrote: From the library reference: assert(equal(splitter(hello world, ' '), [ hello, , world ])); and If a range with one separator is given, the result is a range with two empty

Re: splitter for strings

2014-06-09 Thread Chris via Digitalmars-d-learn
On Monday, 9 June 2014 at 12:16:30 UTC, monarch_dodra wrote: On Monday, 9 June 2014 at 11:40:24 UTC, Chris wrote: On Monday, 9 June 2014 at 11:16:18 UTC, monarch_dodra wrote: On Monday, 9 June 2014 at 11:04:12 UTC, Chris wrote: From the library reference: assert(equal(splitter(hello world,

Re: splitter for strings

2014-06-09 Thread Chris via Digitalmars-d-learn
On Monday, 9 June 2014 at 14:21:21 UTC, Steven Schveighoffer wrote: On Mon, 09 Jun 2014 07:04:11 -0400, Chris wend...@tcd.ie wrote: On Monday, 9 June 2014 at 10:54:09 UTC, monarch_dodra wrote: On Monday, 9 June 2014 at 10:23:16 UTC, Chris wrote: Ok, thanks. I'll keep that in mind for the

Re: splitter for strings

2014-06-09 Thread Chris via Digitalmars-d-learn
On Monday, 9 June 2014 at 14:47:45 UTC, Steven Schveighoffer wrote: On Mon, 09 Jun 2014 10:39:39 -0400, Chris wend...@tcd.ie wrote: Atm, I have auto parts = appender!(string[]); w.splitter('-').filter!(a = !a.empty).copy(parts); Which looks more elegant and gives me what I want. IMO, the

Re: splitter for strings

2014-06-09 Thread Chris via Digitalmars-d-learn
On Monday, 9 June 2014 at 15:52:24 UTC, monarch_dodra wrote: On Monday, 9 June 2014 at 15:19:05 UTC, Chris wrote: On Monday, 9 June 2014 at 14:47:45 UTC, Steven Schveighoffer wrote: On Mon, 09 Jun 2014 10:39:39 -0400, Chris wend...@tcd.ie wrote: Atm, I have auto parts =

Re: splitter for strings

2014-06-09 Thread Chris via Digitalmars-d-learn
On Monday, 9 June 2014 at 18:09:07 UTC, monarch_dodra wrote: On Monday, 9 June 2014 at 17:57:24 UTC, Steven Schveighoffer wrote: I think we are confusing things here, I was talking about strip :) strip and split are actually both pretty much in the same boat actually in regards to that, so

Re: splitter for strings

2014-06-09 Thread Chris via Digitalmars-d-learn
On Monday, 9 June 2014 at 20:01:05 UTC, monarch_dodra wrote: On Monday, 9 June 2014 at 19:47:29 UTC, Chris wrote: Uh, I see, I misread the signature of std.string.strip(). So that's one option now, to strip all trailing hyphens with std.string.strip(). Well, I'll give it a shot tomorrow. No,

extern (C) Names Signatures

2014-06-16 Thread Chris via Digitalmars-d-learn
I use a library written in C. There are these two functions 1. MyLib_Initialize(), an existing 3rd party function 2. my_lib_initialize(), my custom function On Linux (my main platform) it compiled and worked without an error. On Windows, however, implib printed a warning and said that two

DLLs with Cygwin don't work

2014-06-17 Thread Chris via Digitalmars-d-learn
The following: 1. created test C-dll in Cygwin (gcc -shared -o hello.dll hello.o) 2. used implib.exe /s to create .lib file 3. linked with D program dmd test.d hello.lib Compiles, program starts but begins to hang as soon as it calls the C function (which itself is never executed, no hello

Re: DLLs with Cygwin don't work

2014-06-18 Thread Chris via Digitalmars-d-learn
On Tuesday, 17 June 2014 at 09:51:06 UTC, Chris wrote: The following: 1. created test C-dll in Cygwin (gcc -shared -o hello.dll hello.o) 2. used implib.exe /s to create .lib file 3. linked with D program dmd test.d hello.lib Compiles, program starts but begins to hang as soon as it calls

Concurrency on Windows (spawn)

2014-06-18 Thread Chris via Digitalmars-d-learn
Windows: in a D-DLL I'm trying to spawn a thread. However, nothing happens auto myThread = spawn(myFunction, thisTid); send(myThread, arg); The thread is never called. Any ideas? Thanks! PS In an old DLL it used to work, there I called it with only one argument, i.e. spawn(myFunction). Is

Re: Concurrency on Windows (spawn)

2014-06-19 Thread Chris via Digitalmars-d-learn
On Wednesday, 18 June 2014 at 15:23:11 UTC, Kapps wrote: On Wednesday, 18 June 2014 at 15:03:55 UTC, Ali Çehreli wrote: On 06/18/2014 06:28 AM, Chris wrote: On Wednesday, 18 June 2014 at 11:57:06 UTC, Chris wrote: Windows: in a D-DLL I'm trying to spawn a thread. However, nothing happens

Re: [OT]I throw in the towel

2014-06-26 Thread Chris via Digitalmars-d-learn
On Thursday, 26 June 2014 at 08:36:15 UTC, Chris wrote: On Wednesday, 25 June 2014 at 09:29:35 UTC, Orfeo wrote: I wanted to create a simple application to display and edit data from postgresql database using GtkD and ddb (https://github.com/pszturmaj/ddb) The application should run on

Re: [OT]I throw in the towel

2014-06-26 Thread Chris via Digitalmars-d-learn
On Wednesday, 25 June 2014 at 09:29:35 UTC, Orfeo wrote: I wanted to create a simple application to display and edit data from postgresql database using GtkD and ddb (https://github.com/pszturmaj/ddb) The application should run on WinXp or Win7. After a week of work I throw in the towel ...

Re: [OT]I throw in the towel

2014-06-26 Thread Chris via Digitalmars-d-learn
On Thursday, 26 June 2014 at 08:39:46 UTC, Chris wrote: On Thursday, 26 June 2014 at 08:36:15 UTC, Chris wrote: On Wednesday, 25 June 2014 at 09:29:35 UTC, Orfeo wrote: I wanted to create a simple application to display and edit data from postgresql database using GtkD and ddb

Re: ~ ?

2014-06-27 Thread Chris via Digitalmars-d-learn
On Friday, 27 June 2014 at 05:58:14 UTC, pgtkda wrote: What does this symbol mean in relation to D? ~ ~ D means it's about the best language I've come across so far.

Re: Bizarre compile error in GtkD

2014-06-30 Thread Chris via Digitalmars-d-learn
On Sunday, 29 June 2014 at 20:28:23 UTC, Evan Davis wrote: Hello, I have a compile error when trying to use GtkD 2.3.3. When I try to create a FileChooseDialog, I call new FileChooserDialog(Save File, editor.drawingArea.getParent().getParentWindow(),

Re: Small part of a program : d and c versions performances diff.

2014-07-09 Thread Chris via Digitalmars-d-learn
On Wednesday, 9 July 2014 at 15:09:09 UTC, Larry wrote: On Wednesday, 9 July 2014 at 14:30:41 UTC, John Colvin wrote: On Wednesday, 9 July 2014 at 13:46:59 UTC, Larry wrote: The rest of the code is numerical so it will not change by much the fact that d cannot get back the huge launching time.

Re: How to interact with fortran code

2014-07-10 Thread Chris via Digitalmars-d-learn
On Thursday, 10 July 2014 at 12:12:20 UTC, Marc Schütz wrote: On Wednesday, 9 July 2014 at 15:09:08 UTC, Chris wrote: On Wednesday, 9 July 2014 at 15:00:25 UTC, seany wrote: I apologize many times for this question, may be this had already been answered somewhere, but considering today the

DMDScript

2014-07-11 Thread Chris via Digitalmars-d-learn
Tried to compile on linux, got this error message (I guess I can fix it): dmd -c textgen.d textgen.d(36): Error: cannot implicitly convert expression (DMDScript fatal runtime error: ) of type string to char[] textgen.d(36): Error: cannot implicitly convert expression (0) of type int to char[]

Re: DMDScript

2014-07-14 Thread Chris via Digitalmars-d-learn
On Sunday, 13 July 2014 at 07:18:38 UTC, Jason King wrote: On Friday, 11 July 2014 at 15:45:42 UTC, Chris wrote: Tried to compile on linux, got this error message (I guess I can fix it): dmd -c textgen.d textgen.d(36): Error: cannot implicitly convert expression (DMDScript fatal runtime

Re: DMDScript

2014-07-15 Thread Chris via Digitalmars-d-learn
On Monday, 14 July 2014 at 21:22:12 UTC, Jason King wrote: My idea is to use (at least test) DMDScript for server side JS. I don't mean to sound like a D-hater here, but V8 has had about 2 years more work on it than DMDScript. At one time they were. IIRC, quite close performance-wise but

LuaD: How to load modules

2014-07-17 Thread Chris via Digitalmars-d-learn
I'm using / testing LuaD atm. It works very well, however, I've encountered a problem. When I load the module lualsp (for lua server pages) the app crashes. If I run the lua script on its own $ lua5.1 test.lua it works perfectly fine. The lua server page is executed correctly. If I run the

Re: LuaD: How to load modules

2014-07-17 Thread Chris via Digitalmars-d-learn
On Thursday, 17 July 2014 at 10:53:56 UTC, Chris wrote: I'm using / testing LuaD atm. It works very well, however, I've encountered a problem. When I load the module lualsp (for lua server pages) the app crashes. If I run the lua script on its own $ lua5.1 test.lua it works perfectly fine.

Grabing C(++) stdout

2014-07-23 Thread Chris via Digitalmars-d-learn
Short question: how can I grab the stdout written to by C(++), i.e. C code: fwrite(...); std.cstream will be replaced sooner or later.

Re: Grabing C(++) stdout

2014-07-23 Thread Chris via Digitalmars-d-learn
On Wednesday, 23 July 2014 at 15:12:13 UTC, John Colvin wrote: On Wednesday, 23 July 2014 at 14:53:35 UTC, Chris wrote: Short question: how can I grab the stdout written to by C(++), i.e. C code: fwrite(...); std.cstream will be replaced sooner or later. I don't think I understand the

Re: Grabing C(++) stdout

2014-07-23 Thread Chris via Digitalmars-d-learn
The C++ code does this: size_t fwrite ( const void * ptr, size_t size, size_t count, FILE * stream ); // stream is stdout and text appears in the console (a string). I don't how to grab the text that is written to console. I might have to redirect it from within the C++ code.

[vibe.d] Proper use of preWriteCallback

2014-08-22 Thread Chris via Digitalmars-d-learn
Maybe a trivial question: How do I use preWriteCallback properly? It doesn't work properly for me yet (I might not see the forest for the trees at the moment). I am trying to set a field in the HTTPServerResponse.

Re: [vibe.d] Proper use of preWriteCallback

2014-08-22 Thread Chris via Digitalmars-d-learn
On Friday, 22 August 2014 at 13:58:02 UTC, Chris wrote: Maybe a trivial question: How do I use preWriteCallback properly? It doesn't work properly for me yet (I might not see the forest for the trees at the moment). I am trying to set a field in the HTTPServerResponse.

Build failed LuaD vibe.d

2014-09-17 Thread Chris via Digitalmars-d-learn
DUB version 0.9.21 dmd version 2.065.0 vibe.d version 0.7.20 Since v0.7.19 vibe.d has vibe.utils.dictionarylist. This doesn't go well with LuaD's vibe.utils.dictionarylist (same goes for higher versions of dmd and vibe.d, see below) Compiling... source/luad/conversions/structs.d-mixin-38(38):

Cannot deduce from type

2014-09-22 Thread Chris via Digitalmars-d-learn
Why is that? import std.stdio, std.array void main() { auto output = appender!(string); output ~= world!; // output.data.insertInPlace(0, Hello, ); // Doesn't work auto asString = output.data; asString.insertInPlace(0, Hello, ); // Works writeln(asString); // prints Hello, world!

Re: Cannot deduce from type

2014-09-22 Thread Chris via Digitalmars-d-learn
On Monday, 22 September 2014 at 15:00:09 UTC, anonymous wrote: On Monday, 22 September 2014 at 14:45:31 UTC, Chris wrote: Why is that? import std.stdio, std.array void main() { auto output = appender!(string); output ~= world!; // output.data.insertInPlace(0, Hello, ); // Doesn't work

[dub] Building DLLs

2014-09-29 Thread Chris via Digitalmars-d-learn
Today I tried to build a dll via dub, unfortunately I didn't succeed. I couldn't find much on the internet about it. Is it at all possible, and if yes, what's the config I have to use? I tried this (and similar configs) { name: myDLL32bit, targetName: myDLL.dll, targetType:

Re: Localizing a D application - best practices?

2014-09-29 Thread Chris via Digitalmars-d-learn
On Sunday, 28 September 2014 at 21:29:21 UTC, Cliff wrote: Coming from the C# world, all of localization we did was based on defining string resource files (XML-formatted source files which were translated into C# classes with named-string accessors by the build process) that would get

Obedient threads

2014-10-02 Thread Chris via Digitalmars-d-learn
What is the best way to kill a thread when it pleases the owner (main thread)? The background is playing audio files. The playback happens in a separate thread so the owner can keep on listening to events triggered by the user (like stop, pause). I have to queue audio files, wait until one has

Re: Obedient threads

2014-10-02 Thread Chris via Digitalmars-d-learn
On Thursday, 2 October 2014 at 10:33:02 UTC, thedeemon wrote: Just use non-blocking receives in main thread's event loop. When you get a message from child thread that it's finished playing and you decide you don't need that thread anymore, send a message to child you're dismissed. The child

Re: Obedient threads

2014-10-02 Thread Chris via Digitalmars-d-learn
On Thursday, 2 October 2014 at 13:05:00 UTC, ketmar via Digitalmars-d-learn wrote: On Thu, 02 Oct 2014 11:36:06 + Chris via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: you can use receiveTimeout! to check if there is some message available. That won't do. It blocks

Re: Obedient threads

2014-10-02 Thread Chris via Digitalmars-d-learn
On Thursday, 2 October 2014 at 18:08:40 UTC, Ali Çehreli wrote: On 10/02/2014 06:49 AM, Chris wrote: On Thursday, 2 October 2014 at 13:05:00 UTC, ketmar via Digitalmars-d-learn wrote: On Thu, 02 Oct 2014 11:36:06 + Chris via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote

Re: Obedient threads

2014-10-03 Thread Chris via Digitalmars-d-learn
On Friday, 3 October 2014 at 04:39:38 UTC, ketmar via Digitalmars-d-learn wrote: On Thu, 02 Oct 2014 20:42:49 + Chris via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: I'll try that now. Somehow the 1.msecs solution doesn't seem clean enough. it seems that you want thread

Re: Beginner ?. Why does D suggest to learn java

2014-10-17 Thread Chris via Digitalmars-d-learn
On Thursday, 16 October 2014 at 22:26:51 UTC, RBfromME wrote: I'm a newbie to programming and have been looking into the D lang as a general purposing language to learn, yet the D overview indicates that java would be a better language to learn for your first programming language. Why? Looks

Re: Beginner ?. Why does D suggest to learn java

2014-10-17 Thread Chris via Digitalmars-d-learn
On Friday, 17 October 2014 at 14:38:39 UTC, ketmar via Digitalmars-d-learn wrote: On Fri, 17 Oct 2014 14:33:57 + eles via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: On Friday, 17 October 2014 at 13:59:03 UTC, ketmar via Digitalmars-d-learn wrote: On Fri, 17 Oct 2014

Re: Embedding D Shared Library in WSGI Web Server

2014-10-28 Thread Chris via Digitalmars-d-learn
On Tuesday, 28 October 2014 at 00:16:03 UTC, John McFarlane wrote: Hi, I've written a modest shared library in D that I'd like to call directly from a Python web server (Linux/OS X, Apache, WSGI, Pyramid). I can call it reliably from within Python unit tests but on a running server, the

Re: HTML Parsing lib

2014-10-28 Thread Chris via Digitalmars-d-learn
On Sunday, 26 October 2014 at 06:20:45 UTC, Suliman wrote: Unfortunately that library has no dub package. But you can include it in your project. See info here http://code.dlang.org/package-format I can't understand how to set in dub that I need to to include in compilation process other

Re: Pointer across threads

2014-11-04 Thread Chris via Digitalmars-d-learn
On Tuesday, 4 November 2014 at 12:47:11 UTC, Chris wrote: The following struct DATA { short* data; size_t len; } // data and len are provided by a C function // ... auto data = mymodule.getSpeechData(); // cast to immutable, because of concurrency immutable short* tmp =

Pointer across threads

2014-11-04 Thread Chris via Digitalmars-d-learn
The following struct DATA { short* data; size_t len; } // data and len are provided by a C function // ... auto data = mymodule.getSpeechData(); // cast to immutable, because of concurrency immutable short* tmp = cast(immutable)(data.data); auto proc = spawn(processData, thisTid);

Re: Pointer across threads

2014-11-04 Thread Chris via Digitalmars-d-learn
On Tuesday, 4 November 2014 at 14:01:16 UTC, anonymous wrote: On Tuesday, 4 November 2014 at 12:47:11 UTC, Chris wrote: The following struct DATA { short* data; size_t len; } // data and len are provided by a C function // ... auto data = mymodule.getSpeechData(); // cast to immutable,

Re: Pointer across threads

2014-11-04 Thread Chris via Digitalmars-d-learn
On Tuesday, 4 November 2014 at 14:36:19 UTC, Chris wrote: On Tuesday, 4 November 2014 at 14:01:16 UTC, anonymous wrote: On Tuesday, 4 November 2014 at 12:47:11 UTC, Chris wrote: The following struct DATA { short* data; size_t len; } // data and len are provided by a C function // ... auto

Re: Pointer across threads

2014-11-04 Thread Chris via Digitalmars-d-learn
On Tuesday, 4 November 2014 at 14:47:49 UTC, anonymous wrote: On Tuesday, 4 November 2014 at 14:36:19 UTC, Chris wrote: I'm still curious, though, how D handles this internally, because data.data is still mutable while the other reference to the same address (tmp) is not. What if I change

Re: Pointer across threads

2014-11-04 Thread Chris via Digitalmars-d-learn
On Tuesday, 4 November 2014 at 16:07:11 UTC, thedeemon wrote: On Tuesday, 4 November 2014 at 14:36:19 UTC, Chris wrote: I'm still curious, though, how D handles this internally, because data.data is still mutable while the other reference to the same address (tmp) is not. What if I change

Re: Live without debugger?

2014-11-10 Thread Chris via Digitalmars-d-learn
On Sunday, 9 November 2014 at 08:26:59 UTC, Suliman wrote: I know that a lot of people are using for programming tools like Sublime. I am one of them. But if for very simple code it's ok, how to write hard code? Do you often need debugger when you are writing code? For which tasks debugger

Re: Russian translation of the range term?

2014-11-11 Thread Chris via Digitalmars-d-learn
On Tuesday, 11 November 2014 at 15:03:40 UTC, ketmar via Digitalmars-d-learn wrote: On Tue, 11 Nov 2014 14:52:55 + Kagamin via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: I was thinking about list comprehension, which is what programming on ranges is. Isn't it? list is a

Re: Russian translation of the range term?

2014-11-11 Thread Chris via Digitalmars-d-learn
On Tuesday, 11 November 2014 at 16:10:33 UTC, ketmar via Digitalmars-d-learn wrote: On Tue, 11 Nov 2014 15:38:26 + Chris via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: On Tuesday, 11 November 2014 at 15:03:40 UTC, ketmar via Digitalmars-d-learn wrote: On Tue, 11 Nov

Re: Russian translation of the range term?

2014-11-11 Thread Chris via Digitalmars-d-learn
On Tuesday, 11 November 2014 at 16:15:36 UTC, Dicebot wrote: On Tuesday, 11 November 2014 at 16:14:10 UTC, Chris wrote: Does that entail the concept that ranges (in D) are homogeneous (i.e. every member/item is of the same type)? Yes (if you mean static type) ElementType!Range is used

Crash on Windows with core.stdc.stdlib.free()

2014-11-12 Thread Chris via Digitalmars-d-learn
The following causes the DLL to crash on Windows: Input: immutable(short)* data (immutable because in separate thread). // Later core.stdc.stdlib.free(cast(short *)data); (short* data is provided by the C library, where the memory is allocated) On Linux it works fine and never crashes, in

Re: Crash on Windows with core.stdc.stdlib.free()

2014-11-12 Thread Chris via Digitalmars-d-learn
On Wednesday, 12 November 2014 at 12:58:19 UTC, ketmar via Digitalmars-d-learn wrote: On Wed, 12 Nov 2014 12:40:30 + Chris via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: The following causes the DLL to crash on Windows: Input: immutable(short)* data (immutable because

Re: Crash on Windows with core.stdc.stdlib.free()

2014-11-12 Thread Chris via Digitalmars-d-learn
On Wednesday, 12 November 2014 at 14:26:15 UTC, ketmar via Digitalmars-d-learn wrote: On Wed, 12 Nov 2014 14:11:35 + Chris via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: On Wednesday, 12 November 2014 at 12:58:19 UTC, ketmar via Digitalmars-d-learn wrote: On Wed, 12

Re: Crash on Windows with core.stdc.stdlib.free()

2014-11-12 Thread Chris via Digitalmars-d-learn
On Wednesday, 12 November 2014 at 14:42:34 UTC, Chris wrote: On Wednesday, 12 November 2014 at 14:26:15 UTC, ketmar via if you can extend C DLL, just add wrapper for `free()` there. so you will not call `free()` from D, but call C DLL function which will free the memory. it's a good practice

Re: Crash on Windows with core.stdc.stdlib.free()

2014-11-13 Thread Chris via Digitalmars-d-learn
On Wednesday, 12 November 2014 at 16:10:34 UTC, ketmar via Digitalmars-d-learn wrote: On Wed, 12 Nov 2014 16:03:08 + Chris via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: On Wednesday, 12 November 2014 at 14:42:34 UTC, Chris wrote: On Wednesday, 12 November 2014 at 14

Re: Crash on Windows with core.stdc.stdlib.free()

2014-11-14 Thread Chris via Digitalmars-d-learn
On Thursday, 13 November 2014 at 10:17:35 UTC, ketmar via Digitalmars-d-learn wrote: On Thu, 13 Nov 2014 10:08:47 + Chris via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: Interesting though that it never crashes on Linux, only on Windows did this cause problems. seems

[dub] Size of executable

2014-11-27 Thread Chris via Digitalmars-d-learn
[Maybe this has been asked before.] I usually use dub to create and build projects. I built one of the projects with dub and then by hand with dmd[1] passing all the files etc. Turned out that the executable built with dub was 1.4 MB whereas the one built by hand was only 807 kB. Why is that?

[dub] Size of executable

2014-11-27 Thread Chris via Digitalmars-d-learn
[Maybe this has been asked before.] I usually use dub to create and build projects. I built one of the projects with dub and then by hand with dmd[1] passing all the files etc. Turned out that the executable built with dub was 1.4 MB whereas the one built by hand was only 807 kB. Why is that?

Re: [dub] Size of executable

2014-11-27 Thread Chris via Digitalmars-d-learn
On Thursday, 27 November 2014 at 12:29:03 UTC, Gary Willoughby wrote: On Thursday, 27 November 2014 at 09:33:49 UTC, Chris wrote: I usually use dub to create and build projects. I built one of the projects with dub and then by hand with dmd[1] passing all the files etc. Turned out that the

Re: [dub] Size of executable

2014-11-27 Thread Chris via Digitalmars-d-learn
On Thursday, 27 November 2014 at 13:59:23 UTC, CraigDillabaugh wrote: On Thursday, 27 November 2014 at 13:56:19 UTC, Chris wrote: On Thursday, 27 November 2014 at 12:29:03 UTC, Gary Willoughby wrote: On Thursday, 27 November 2014 at 09:33:49 UTC, Chris wrote: I usually use dub to create and

Re: [dub] Size of executable

2014-11-28 Thread Chris via Digitalmars-d-learn
On Thursday, 27 November 2014 at 17:08:00 UTC, CraigDillabaugh wrote: On Thursday, 27 November 2014 at 14:14:50 UTC, Chris wrote: On Thursday, 27 November 2014 at 13:59:23 UTC, CraigDillabaugh wrote: On Thursday, 27 November 2014 at 13:56:19 UTC, Chris wrote: On Thursday, 27 November 2014 at

Re: Why the DMD Backend?

2014-12-02 Thread Chris via Digitalmars-d-learn
On Friday, 28 November 2014 at 19:59:40 UTC, Xinok wrote: Given that we have GDC with the GCC backend and LDC with the LLVM backend, what are the benefits of keeping the DMD compiler backend? It seems to me that GCC and LLVM are far more developed and better supported by their respective

Re: Why the DMD Backend?

2014-12-02 Thread Chris via Digitalmars-d-learn
On Tuesday, 2 December 2014 at 10:37:18 UTC, bearophile wrote: Chris: As others have said already, the reasons why I use dmd are: Walter has developed the back-end of DMD and he wants to keep using it no matter what. But I love the very small compilation time of dmd sources. Bye,

Re: Why the DMD Backend?

2014-12-02 Thread Chris via Digitalmars-d-learn
On Tuesday, 2 December 2014 at 10:57:20 UTC, Temtaime wrote: It's only words. If we speak about LDC it can compile fast in debug mode with performance average to DMD's backend but with much great performance in release mode thanks to vectorization and other techniques. Also LDC thanks to LLVM

Re: Learning D for a non computer science background person : pre-requisite knowledge?

2014-12-05 Thread Chris via Digitalmars-d-learn
On Tuesday, 2 December 2014 at 21:10:33 UTC, Meta wrote: On Tuesday, 2 December 2014 at 16:38:34 UTC, Mayuresh Kathe wrote: While I have been a programmer for close to 23 years, it's been mostly API level code cobbling work. Would like to learn D, but am a bit intimidated by the fact that I

Re: Learning to XML with D

2015-02-06 Thread Chris via Digitalmars-d-learn
On Friday, 6 February 2015 at 09:15:54 UTC, Derix wrote: So, I set sails to transform a bunch of HTML files with D. This, of course, will happen with the std.xml library. There is this nice example : http://dlang.org/phobos/std_xml.html#.DocumentParser that I put to some use already, however

Re: Learning to XML with D

2015-02-06 Thread Chris via Digitalmars-d-learn
On Friday, 6 February 2015 at 14:11:19 UTC, CraigDillabaugh wrote: On Friday, 6 February 2015 at 14:09:51 UTC, CraigDillabaugh wrote: On Friday, 6 February 2015 at 11:39:32 UTC, Chris wrote: On Friday, 6 February 2015 at 09:15:54 UTC, Derix wrote: clip Thxxx The documentation says:

Re: is eC alot like D?

2015-03-13 Thread Chris via Digitalmars-d-learn
On Wednesday, 11 March 2015 at 03:16:50 UTC, Taylor Hillegeist wrote: So I found http://ec-lang.org/ it seems alot like D, But it has a company backing it. It just seems interesting. Seems to me that structs are not the same as in D, and structs in D are very powerful. I don't like the fact

Re: [Dscanner] Textadept integration

2015-03-24 Thread Chris via Digitalmars-d-learn
On Tuesday, 24 March 2015 at 16:54:47 UTC, Chris wrote: I tried to use Dscanner with Textadpet, but it doesn't work. I created the directory modules/dmd and copied the init.lua file from here [1] into it. What am I doing wrong, or is it an old version that is no longer supported? [1]

[Dscanner] Textadept integration

2015-03-24 Thread Chris via Digitalmars-d-learn
I tried to use Dscanner with Textadpet, but it doesn't work. I created the directory modules/dmd and copied the init.lua file from here [1] into it. What am I doing wrong, or is it an old version that is no longer supported? [1] https://bitbucket.org/SirAlaran/ta-d/

Re: Fibers and async io stuff for beginners

2015-04-23 Thread Chris via Digitalmars-d-learn
On Thursday, 23 April 2015 at 16:57:30 UTC, Jens Bauer wrote: On Thursday, 23 April 2015 at 14:22:01 UTC, Ali Çehreli wrote: On 04/23/2015 06:56 AM, ref2401 wrote: http://ddili.org/ders/d.en/fibers.html I appreciate any feedback before the book is finally printed sometime before DConf.

Re: multiSort for sorting AA by value

2015-04-21 Thread Chris via Digitalmars-d-learn
Maybe something like bearophile's example should go into the documentation of std.algorithm.sorting.multiSort. It's a common enough thing in programming.

Re: Templates: Array slices not recognized

2015-04-20 Thread Chris via Digitalmars-d-learn
On Saturday, 18 April 2015 at 17:59:19 UTC, ketmar wrote: On Sat, 18 Apr 2015 17:50:56 +, Chris wrote: Doh! You're right! My bad. However, this makes the function less generic, but it doesn't matter here. maybe `auto ref` can help here? Yes, auto ref does the trick. I prefer it to

Re: Templates: Array slices not recognized

2015-04-20 Thread Chris via Digitalmars-d-learn
On Monday, 20 April 2015 at 09:58:06 UTC, Marc Schütz wrote: On Monday, 20 April 2015 at 09:07:54 UTC, Chris wrote: On Saturday, 18 April 2015 at 17:59:19 UTC, ketmar wrote: On Sat, 18 Apr 2015 17:50:56 +, Chris wrote: Doh! You're right! My bad. However, this makes the function less

Re: Templates: Array slices not recognized

2015-04-20 Thread Chris via Digitalmars-d-learn
On Monday, 20 April 2015 at 10:27:00 UTC, anonymous wrote: On Monday, 20 April 2015 at 10:14:27 UTC, Chris wrote: string a = bla; string b = blub; auto res = doSomething(a, b); If I didn't use auto ref or ref, string would get copied, wouldn't it? auto ref doSomething(R needle, R

Re: Templates: Array slices not recognized

2015-04-20 Thread Chris via Digitalmars-d-learn
On Monday, 20 April 2015 at 10:42:54 UTC, Chris wrote: On Monday, 20 April 2015 at 10:27:00 UTC, anonymous wrote: On Monday, 20 April 2015 at 10:14:27 UTC, Chris wrote: string a = bla; string b = blub; auto res = doSomething(a, b); If I didn't use auto ref or ref, string would get copied,

Re: multiSort for sorting AA by value

2015-04-21 Thread Chris via Digitalmars-d-learn
On Tuesday, 21 April 2015 at 11:46:24 UTC, bearophile wrote: Chris: I'm happy with it, but maybe there is a more concise implementation? This is a bit shorter and a bit better (writefln is not yet able to format tuples nicely): void main() { import std.stdio: writeln; import

Re: Fibers and async io stuff for beginners

2015-04-24 Thread Chris via Digitalmars-d-learn
On Thursday, 23 April 2015 at 22:26:28 UTC, Jens Bauer wrote: On Thursday, 23 April 2015 at 19:24:31 UTC, Chris wrote: On Thursday, 23 April 2015 at 16:57:30 UTC, Jens Bauer wrote: 3: Audio mixing and playback (eg. a MOD player for instance). 5: Queueing up a bunch of different jobs; At the

  1   2   3   >