Re: [video tutorial] Cleaning up our command line argument parsing code

2014-02-19 Thread simendsjo
On Wednesday, 19 February 2014 at 21:55:35 UTC, Brad Anderson wrote: On Wednesday, 19 February 2014 at 14:46:57 UTC, simendsjo wrote: Spam spam http://youtu.be/ZRUcTJC0D7M Good stuff. Are you going to upload the older videos to this same channel? Is that necessary? The playlist includes the

Re: Method template optimization that works in C++, but not very well D

2014-02-19 Thread Vladimir
https://github.com/AlexeyAB/cpp_find_order/blob/06a80340ff403c4693bfe0ff8b80584f029c71a3/main.cpp. I forgot to say that if you want to compile this program with help gcc you must use options: -O3 -march=native -std=gnu++11

Re: Method template optimization that works in C++, but not very well D

2014-02-19 Thread Vladimir
I would like to understand the request first. Neither ProccessRow() nor OptimizedProcessTable() take isUseField as template parameters. Besides, isUseField is generated at runtime. No, I don't understand. :) Yes, isUseField is generated at runtime. For example, user can select the column th

Re: Method template optimization that works in C++, but not very well D

2014-02-19 Thread Vladimir
On Wednesday, 19 February 2014 at 15:40:41 UTC, bearophile wrote: ... In generale in D the name of functions and variabiles start with a lower case I apologize that I did not checked the style guide. I rewrote my example according yours recommendation. Thank you. alias TypeTuple(Types

Re: Dynamic library loading gives error about importing a module

2014-02-19 Thread Tolga Cakiroglu
Simply "import"ing should work; doing that should not bring definitions to the code. However, one side should also include the module during its build. Have you included the module on both the program's and library's builds? Ali Hi Ali, Both of them have normal import for that module. I

Re: Why function template 'among' is of complexity O(1) and not O(n)?

2014-02-19 Thread Chris Williams
On Thursday, 20 February 2014 at 02:10:50 UTC, anonymous wrote: The foreach is definitely always evaluated at compile time. That's independent of the values being known statically. It generates a couple of if statements. But optimizing those if statements away for static values is not guaranteed

Re: Why function template 'among' is of complexity O(1) and not O(n)?

2014-02-19 Thread anonymous
On Thursday, 20 February 2014 at 01:41:25 UTC, Chris Williams wrote: On Thursday, 20 February 2014 at 00:36:38 UTC, anonymous wrote: On Wednesday, 19 February 2014 at 22:46:45 UTC, Chris Williams wrote: When the template writes out the definition of the function, if the parameters can be interp

Re: Why function template 'among' is of complexity O(1) and not O(n)?

2014-02-19 Thread Chris Williams
On Thursday, 20 February 2014 at 00:36:38 UTC, anonymous wrote: On Wednesday, 19 February 2014 at 22:46:45 UTC, Chris Williams wrote: When the template writes out the definition of the function, if the parameters can be interpreted during compile-time, then the foreach ( O(n) ) will be run by t

Re: Why function template 'among' is of complexity O(1) and not O(n)?

2014-02-19 Thread anonymous
On Wednesday, 19 February 2014 at 22:46:45 UTC, Chris Williams wrote: When the template writes out the definition of the function, if the parameters can be interpreted during compile-time, then the foreach ( O(n) ) will be run by the compiler to detect the correct parameter and the function wil

Re: DMD exit code -9

2014-02-19 Thread Etienne Cimon
On 2014-02-19 17:15, Craig Dillabaugh wrote: However, I would still be interested in finding out where I could get a listing of what the various exit codes mean ... or do I need to delve into the DMD source code? That seems to be the SIGKILL signal from linux kernel (-9). DMD didn't have a ch

Re: Dynamic library loading gives error about importing a module

2014-02-19 Thread cal
On Wednesday, 19 February 2014 at 09:45:41 UTC, Tolga Cakiroglu wrote: I have written a programme and a library under Linux. When programme is run, it tries to load the library. Both the programme code and the library imports a module as "apps.common.lib.config". Now, when I run the programme,

Re: Why function template 'among' is of complexity O(1) and not O(n)?

2014-02-19 Thread Chris Williams
On Wednesday, 19 February 2014 at 22:05:49 UTC, Peter Alexander wrote: If you want to get even more anal about it, searching an array is technically O(1) because an array cannot be bigger than size_t.max, and since size_t.max is a constant, O(size_t.max) is O(1). Again, completely misleading bu

Re: Possible to do receive on a delegate?

2014-02-19 Thread John Colvin
On Wednesday, 19 February 2014 at 16:23:36 UTC, Bienlein wrote: Hello, I was wondering whether it can be done somehow to select on a delegate in the receive block when spawning a thread: void spawnedFunc(Tid tid) { // Receive a message from the owner thread. receive( (int i)

Re: DMD exit code -9

2014-02-19 Thread Craig Dillabaugh
On Wednesday, 19 February 2014 at 22:07:55 UTC, Craig Dillabaugh wrote: I am trying to build a small application (I am using DUB) and when I try to build, I get the following output: dub build dub: /usr/lib64/libcurl.so.4: no version information available (required by dub) vibe-d: ["vibe-d",

Re: Why function template 'among' is of complexity O(1) and not O(n)?

2014-02-19 Thread Peter Alexander
On Wednesday, 19 February 2014 at 09:46:04 UTC, Gopan wrote: On Wednesday, 19 February 2014 at 09:09:25 UTC, Tobias Pankrath It's O(k) with k = vals.length, which is the number of arguments given to the function, which is a compile time constant and not dependent on any input of the final progr

DMD exit code -9

2014-02-19 Thread Craig Dillabaugh
I am trying to build a small application (I am using DUB) and when I try to build, I get the following output: dub build dub: /usr/lib64/libcurl.so.4: no version information available (required by dub) vibe-d: ["vibe-d", "libevent", "openssl"] vibe-d: ["vibe-d", "libevent", "openssl"] libd: [

Re: [video tutorial] Cleaning up our command line argument parsing code

2014-02-19 Thread Brad Anderson
On Wednesday, 19 February 2014 at 14:46:57 UTC, simendsjo wrote: Spam spam http://youtu.be/ZRUcTJC0D7M Good stuff. Are you going to upload the older videos to this same channel?

Re: Why function template 'among' is of complexity O(1) and not O(n)?

2014-02-19 Thread Jakob Ovrum
On Wednesday, 19 February 2014 at 21:52:06 UTC, anonymous wrote: Nope. v and vals are runtime parameters, their values are not known at compile time. What's known at compile time is vals.length. While this is correct, note that there is also an overload that takes `values` as compile-time para

Re: Why function template 'among' is of complexity O(1) and not O(n)?

2014-02-19 Thread anonymous
On Wednesday, 19 February 2014 at 19:45:39 UTC, Ali Çehreli wrote: On 02/19/2014 01:46 AM, Gopan wrote: [...] > uint among(T, Us...)(T v, Us vals) > { > foreach (i, U; Us) > { > writeln("checking ", v, " == ", vals[i]); > if (v == vals[i]) > return i + 1; >

Re: Container templates

2014-02-19 Thread Meta
On Wednesday, 19 February 2014 at 19:44:12 UTC, Meta wrote: On Wednesday, 19 February 2014 at 19:10:44 UTC, Frustrated wrote: Are there container templates that one can mixin to classes that give them container behavior? e.g., instead of class A { Array!int x; } I want class A { mix

Re: How to resume iteration from previous point in associative array

2014-02-19 Thread Ali Çehreli
On 02/19/2014 04:11 AM, bearophile wrote: Nicolas Sicard: Are byKey and byValue guaranteed to iterate the associative array in the same order? Nope, or not yet, sorry. Bye, bearophile Is there a bug report about that? I can't imagine how they can iterate in any other order. Ali

Re: Dynamic library loading gives error about importing a module

2014-02-19 Thread Ali Çehreli
On 02/19/2014 01:45 AM, Tolga Cakiroglu wrote: > I have written a programme and a library under Linux. When programme is > run, it tries to load the library. Both the programme code and the > library imports a module as "apps.common.lib.config". Now, when I run > the programme, following error is

Re: Possible to do receive on a delegate?

2014-02-19 Thread Tobias Pankrath
I don't really understand why foo has to be static to compile. But this is really nice now :-). -- Bienlein A nested function has a context pointer to its outer scope, like a delegate. static makes it an ordinary function.

Re: Container templates

2014-02-19 Thread monarch_dodra
On Wednesday, 19 February 2014 at 19:44:12 UTC, Meta wrote: On Wednesday, 19 February 2014 at 19:10:44 UTC, Frustrated wrote: Are there container templates that one can mixin to classes that give them container behavior? e.g., instead of class A { Array!int x; } I want class A { mix

Re: Container templates

2014-02-19 Thread Frustrated
On Wednesday, 19 February 2014 at 19:44:12 UTC, Meta wrote: On Wednesday, 19 February 2014 at 19:10:44 UTC, Frustrated wrote: Are there container templates that one can mixin to classes that give them container behavior? e.g., instead of class A { Array!int x; } I want class A { mix

Re: Possible to do receive on a delegate?

2014-02-19 Thread Bienlein
On Wednesday, 19 February 2014 at 17:05:01 UTC, John Colvin wrote: delegate isn't a type. try int delegate() instead Thanks for the hint! This works now: void spawnedFunc(Tid tid) { receive( (int i) { writeln("Received the number ", i);}, (int function() fp) { writeln

Re: Why function template 'among' is of complexity O(1) and not O(n)?

2014-02-19 Thread Dicebot
On Wednesday, 19 February 2014 at 19:45:39 UTC, Ali Çehreli wrote: ... This is much better explanation - O(n) compile-time algorithm which results in O(1) run-time code generated :)

Re: Why function template 'among' is of complexity O(1) and not O(n)?

2014-02-19 Thread Ali Çehreli
On 02/19/2014 01:46 AM, Gopan wrote: > On Wednesday, 19 February 2014 at 09:09:25 UTC, Tobias Pankrath wrote: >> On Wednesday, 19 February 2014 at 08:58:10 UTC, Gopan wrote: >>> Recently, I came across the following thread >>> http://forum.dlang.org/thread/l8nocr$1dv5$1...@digitalmars.com?page=2

Re: Container templates

2014-02-19 Thread Meta
On Wednesday, 19 February 2014 at 19:10:44 UTC, Frustrated wrote: Are there container templates that one can mixin to classes that give them container behavior? e.g., instead of class A { Array!int x; } I want class A { mixin Array!int; } so that I can do something like a.Add(3) in

Re: Method template optimization that works in C++, but not very well D

2014-02-19 Thread Ali Çehreli
On 02/19/2014 07:13 AM, Vladimir wrote: > I`m learning templates in D language and I want to thank the creators of > the language for this. > > There is an educational task: process table entries, if you know which > column to use. [...] > In c++ I can create in compile-time special vesrion Pro

Container templates

2014-02-19 Thread Frustrated
Are there container templates that one can mixin to classes that give them container behavior? e.g., instead of class A { Array!int x; } I want class A { mixin Array!int; } so that I can do something like a.Add(3) instead of a.x.Add(3). In fact, I do want the first case because I w

Re: Possible to do receive on a delegate?

2014-02-19 Thread John Colvin
On Wednesday, 19 February 2014 at 16:23:36 UTC, Bienlein wrote: Hello, I was wondering whether it can be done somehow to select on a delegate in the receive block when spawning a thread: void spawnedFunc(Tid tid) { // Receive a message from the owner thread. receive( (int i)

Possible to do receive on a delegate?

2014-02-19 Thread Bienlein
Hello, I was wondering whether it can be done somehow to select on a delegate in the receive block when spawning a thread: void spawnedFunc(Tid tid) { // Receive a message from the owner thread. receive( (int i) { writeln("Received the number ", i);} (delegate d) { wri

Re: Method template optimization that works in C++, but not very well D

2014-02-19 Thread bearophile
Vladimir: Where I'm wrong? How I can rewrite the program to make effect more evident? Or may be, this optimization is meaningless in D...? The L1 code cache is small and it's easy to create cache misses, so increasing the code size leads to nonlinear changes in the run-time. https://g

Re: Is this meant to be possible?

2014-02-19 Thread Adam D. Ruppe
On Tuesday, 18 February 2014 at 00:59:24 UTC, ted wrote: so is: createDynamicInstance(ClassInfo type) { return type.create(); } the correct implementation ?? - it certainly seems to work... Yeah, that's good as long as you have a no-arg constructor on the class. (the create function never

Method template optimization that works in C++, but not very well D

2014-02-19 Thread Vladimir
I`m learning templates in D language and I want to thank the creators of the language for this. There is an educational task: process table entries, if you know which column to use. Simple way to do this: int ProcessTable(.) { int result = 0; foreach (ref row; table)

[video tutorial] Cleaning up our command line argument parsing code

2014-02-19 Thread simendsjo
Spam spam http://youtu.be/ZRUcTJC0D7M

Re: Why function template 'among' is of complexity O(1) and not O(n)?

2014-02-19 Thread Tobias Pankrath
On Wednesday, 19 February 2014 at 13:11:32 UTC, Dicebot wrote: On Wednesday, 19 February 2014 at 13:03:38 UTC, Tobias Pankrath wrote: On Wednesday, 19 February 2014 at 09:46:04 UTC, Gopan wrote: Index of 3 in (1,2,5,3) is 4 Or, is my undertanding about Big-O notation of complexity wrong? Th

Re: Why function template 'among' is of complexity O(1) and not O(n)?

2014-02-19 Thread Dicebot
On Wednesday, 19 February 2014 at 13:03:38 UTC, Tobias Pankrath wrote: On Wednesday, 19 February 2014 at 09:46:04 UTC, Gopan wrote: Index of 3 in (1,2,5,3) is 4 Or, is my undertanding about Big-O notation of complexity wrong? Thanks, Gopan O(1) = O(k) for any constant k. I don't think it

Re: Why function template 'among' is of complexity O(1) and not O(n)?

2014-02-19 Thread Tobias Pankrath
On Wednesday, 19 February 2014 at 09:46:04 UTC, Gopan wrote: Index of 3 in (1,2,5,3) is 4 Or, is my undertanding about Big-O notation of complexity wrong? Thanks, Gopan O(1) = O(k) for any constant k.

[video tutorial] Command line arguments with std.getopt

2014-02-19 Thread simendsjo
http://youtu.be/mNQqtauO9IM The entire playlist: http://www.youtube.com/playlist?list=PLqABwcsDQUo59iBOM5DFtqbwrMhL4PWcQ I wont be maintaining the old channel anymore. New videos are uploaded here: http://www.youtube.com/channel/UCz3NlrGpjV9NlJAhKJLu_-w

Re: How to resume iteration from previous point in associative array

2014-02-19 Thread bearophile
Nicolas Sicard: Are byKey and byValue guaranteed to iterate the associative array in the same order? Nope, or not yet, sorry. Bye, bearophile

Re: How to resume iteration from previous point in associative array

2014-02-19 Thread Nicolas Sicard
On Wednesday, 19 February 2014 at 09:28:27 UTC, bearophile wrote: Tarman: We're doing some "super computing" "big data" style stuff with D. We have a system where we're comparing associative arrays with billions of entries. Built-in associative arrays were never tested with so many pairs, s

Re: How to resume iteration from previous point in associative array

2014-02-19 Thread Tarman
@bearophile: Thanks for your suggestion! Yes we've tried this but unfortunately the performance doesn't work for us, maybe because all our CPUs are quite saturated. @simendsjo: Thanks also for your suggestion, we are using tasks and yield in our code but in this case we felt that using it j

Dynamic library loading gives error about importing a module

2014-02-19 Thread Tolga Cakiroglu
I have written a programme and a library under Linux. When programme is run, it tries to load the library. Both the programme code and the library imports a module as "apps.common.lib.config". Now, when I run the programme, following error is seen: Fatal Error while loading 'dll/lib.so': The

Re: Why function template 'among' is of complexity O(1) and not O(n)?

2014-02-19 Thread Gopan
On Wednesday, 19 February 2014 at 09:09:25 UTC, Tobias Pankrath wrote: On Wednesday, 19 February 2014 at 08:58:10 UTC, Gopan wrote: Recently, I came across the following thread http://forum.dlang.org/thread/l8nocr$1dv5$1...@digitalmars.com?page=2 On Monday, 16 December 2013 at 22:10:52 UTC, And

Re: How to resume iteration from previous point in associative array

2014-02-19 Thread Tobias Pankrath
On Wednesday, 19 February 2014 at 09:21:48 UTC, Tarman wrote: Hi, We're doing some "super computing" "big data" style stuff with D. We have a system where we're comparing associative arrays with billions of entries. However in this system we need to fairly consider possible solutions for ma

Re: How to resume iteration from previous point in associative array

2014-02-19 Thread simendsjo
On Wednesday, 19 February 2014 at 09:21:48 UTC, Tarman wrote: Hi, We're doing some "super computing" "big data" style stuff with D. We have a system where we're comparing associative arrays with billions of entries. However in this system we need to fairly consider possible solutions for ma

Re: trace GC work

2014-02-19 Thread Ruslan Mullakhmetov
On Tuesday, 18 February 2014 at 22:59:00 UTC, Mike wrote: On Tuesday, 18 February 2014 at 18:10:40 UTC, Ruslan Mullakhmetov wrote: Hi, Is it possible to trace GC allocation calls to determine times of program "death" and have some stats? So i want the following information: - garbage colle

Re: How to resume iteration from previous point in associative array

2014-02-19 Thread bearophile
Tarman: We're doing some "super computing" "big data" style stuff with D. We have a system where we're comparing associative arrays with billions of entries. Built-in associative arrays were never tested with so many pairs, so perform exhaustive performance benchmarks first, and report in B

Re: How to resume iteration from previous point in associative array

2014-02-19 Thread Tarman
I guess what might work here is to allow some kind of argument to "byKey" that will let us resume so maybe something like: foreach (item; massiveAssociativeArray.byKey(indexOfKeyToStartFrom)) { } If something like this isn't possible, then would one of our engineers be able to submit a patch

How to resume iteration from previous point in associative array

2014-02-19 Thread Tarman
Hi, We're doing some "super computing" "big data" style stuff with D. We have a system where we're comparing associative arrays with billions of entries. However in this system we need to fairly consider possible solutions for many "units" at a time within a single thread. So we'd like to.

Re: Why function template 'among' is of complexity O(1) and not O(n)?

2014-02-19 Thread Tobias Pankrath
On Wednesday, 19 February 2014 at 08:58:10 UTC, Gopan wrote: Recently, I came across the following thread http://forum.dlang.org/thread/l8nocr$1dv5$1...@digitalmars.com?page=2 On Monday, 16 December 2013 at 22:10:52 UTC, Andrei Alexandrescu wrote: On 12/16/13 1:45 PM, Walter Bright wrote: On

Why function template 'among' is of complexity O(1) and not O(n)?

2014-02-19 Thread Gopan
Recently, I came across the following thread http://forum.dlang.org/thread/l8nocr$1dv5$1...@digitalmars.com?page=2 On Monday, 16 December 2013 at 22:10:52 UTC, Andrei Alexandrescu wrote: On 12/16/13 1:45 PM, Walter Bright wrote: On 12/16/2013 12:38 PM, Andrei Alexandrescu wrote: uint among(T,