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: 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

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: 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: 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: 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: 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

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

[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

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

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):

[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.

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.

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.

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

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

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: 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

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: 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: ~ ?

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: [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: 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: 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

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

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

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,

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.

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

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: 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

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

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

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

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?

<    1   2   3