Re: C++ Interop

2018-01-06 Thread qznc via Digitalmars-d-learn
On Saturday, 6 January 2018 at 11:20:01 UTC, Seb wrote: On Saturday, 6 January 2018 at 11:17:56 UTC, Seb wrote: On Friday, 5 January 2018 at 13:02:12 UTC, qznc wrote: I'm exploring [0] C++ interop after watching Walter's presentation [1]. [...] I know about this: https://github.

C++ Interop

2018-01-05 Thread qznc via Digitalmars-d-learn
re or even reimplement C++ code. Has anybody started a libcpp-in-d project? I'm looking for basics like vector and string. [0] https://github.com/qznc/d-cpptest [1] https://youtu.be/IkwaV6k6BmM

Re: Use of "T"

2017-04-12 Thread qznc via Digitalmars-d-learn
On Wednesday, 12 April 2017 at 13:17:42 UTC, solidstate1991 wrote: How can I make use of T? I've seen it being used many times for this application. What "T"? This letter is often used as a generic template parameter. Are you talking about templates? Maybe you can give some examples of the "

Dub and bindings

2017-03-11 Thread qznc via Digitalmars-d-learn
Are there any general tips or best practices for bindings in dub packages? For example, I love the d2sqlite3 package. It just works out of the box. No linker configuration or anything. However, that is probably a testament to sqlite's lack of dependencies. That cannot work for libraries, whic

Re: About spinlock implementation

2016-09-01 Thread qznc via Digitalmars-d-learn
On Thursday, 1 September 2016 at 10:30:12 UTC, Guillaume Piolat wrote: On Thursday, 1 September 2016 at 07:46:04 UTC, qznc wrote: I find the documentation on MemoryOrder lacking about the semantics of rel. :( [0] https://dlang.org/library/core/atomic/memory_order.html What helped me was

Re: About spinlock implementation

2016-09-01 Thread qznc via Digitalmars-d-learn
On Thursday, 1 September 2016 at 06:44:13 UTC, mogu wrote: I found an implementation of spinlock in concurrency.d. ``` static shared struct SpinLock { void lock() { while (!cas(&locked, false, true)) { Thread.yield(); } } void unlock() { atomicStore!(MemoryOrder.rel)(locked, false); }

Re: Implementing a cache

2016-07-03 Thread qznc via Digitalmars-d-learn
On Saturday, 2 July 2016 at 12:21:14 UTC, Lodovico Giaretta wrote: On Saturday, 2 July 2016 at 12:10:28 UTC, qznc wrote: Alternatively, any better idea to implement the cache? I guess there is no off-the-shelf/dub solution. For now, I settled for a sorted array of cache entries plus an AA to

Implementing a cache

2016-07-02 Thread qznc via Digitalmars-d-learn
I want to implement some caching for HTTP GET requests. Basically a map of URL to content. A cache needs some additional meta data (size, age, etc). There seem to be two basic data structures available: Associative array (AA) or red black tree (RBT). With AA cache eviction is inefficient. It

Re: String compare in words?

2016-05-29 Thread qznc via Digitalmars-d-learn
On Sunday, 29 May 2016 at 17:42:48 UTC, Era Scarecrow wrote: Worse I'm not sure if the code generation already does that and possibly does a better job than what we could do by hand... Not with dmd v2.071.0 or ldc 0.17.1. At least not in all the variations I tried to trick them with, like co

Re: String compare in words?

2016-05-29 Thread qznc via Digitalmars-d-learn
On Sunday, 29 May 2016 at 18:15:16 UTC, qznc wrote: On Sunday, 29 May 2016 at 17:38:17 UTC, Jonathan M Davis wrote: And if you're not simply comparing for equality, what are you looking to figure out? Without more information about what you're trying to do, it's kind of hard to

Re: String compare in words?

2016-05-29 Thread qznc via Digitalmars-d-learn
On Sunday, 29 May 2016 at 17:38:17 UTC, Jonathan M Davis wrote: And if you're not simply comparing for equality, what are you looking to figure out? Without more information about what you're trying to do, it's kind of hard to help you. If I write the comparison naively, the assembly clearly s

String compare in words?

2016-05-29 Thread qznc via Digitalmars-d-learn
Given two string (or char[] or ubyte[]) objects, I want to compare them. The naive loop accesses the arrays byte-wise. How could I turn this into a word-wise compare for better performance? Is a cast into size_t[] ok? Some Phobos helper functions?

Re: Newbie to D, first impressions and feedback on the 5 (and more) first minutes.

2016-05-25 Thread qznc via Digitalmars-d-learn
On Wednesday, 25 May 2016 at 09:41:10 UTC, Russel Winder wrote: I do not really have the proper resources to host such a repository and because of this I have not built one. I know I should rather than just moan, but Debian is my main platform and that is covered. Yes, this is the core proble

Re: Newbie to D, first impressions and feedback on the 5 (and more) first minutes.

2016-05-24 Thread qznc via Digitalmars-d-learn
On Tuesday, 24 May 2016 at 15:27:45 UTC, llaine wrote: As written in the description I'm really new to D, I discovered it a few weeks ago thanks to the D Conf in Berlin. After playing around for couple of days with it, I wanted to share my journey with you guys on several points. Thanks for

Re: reading file byLine

2015-09-02 Thread qznc via Digitalmars-d-learn
On Wednesday, 2 September 2015 at 13:46:54 UTC, Namal wrote: On Wednesday, 2 September 2015 at 13:12:39 UTC, cym13 wrote: On Wednesday, 2 September 2015 at 13:01:31 UTC, Namal wrote: Hello, I want to read a file line by line and store each line in a string. I found this example with byLine an

Profiling with LDC/GDC?

2015-09-01 Thread qznc via Digitalmars-d-learn
Is it possible to profile with LDC/GDC? At least LDC lists it as only an "idea". http://wiki.dlang.org/LDC_project_ideas

Re: linking external libs

2015-08-29 Thread qznc via Digitalmars-d-learn
On Thursday, 2 July 2015 at 12:10:52 UTC, Nicholas Wilson wrote: Also is there a binding to GMP somewhere? I just hacked one together. I could need the bindings to fix the pidigits benchmark. There is this 7y old code on dsource: http://www.dsource.org/projects/bindings/browser/trunk/gmp Th

Packing enums

2015-06-30 Thread qznc via Digitalmars-d-learn
I stumbled upon this interesting programming challenge [0], which imho should be possible to implement in D. Maybe someone here wants to try. Task: Given two enums with less than 256 states, pack them into one byte and provide convenient accessor functions. Something like this: enum X { A,

Re: std.container.Array deep-copy?

2014-10-10 Thread qznc via Digitalmars-d-learn
On Friday, 10 October 2014 at 10:59:59 UTC, Sag Academy wrote: On Friday, 10 October 2014 at 10:32:17 UTC, yazd wrote: Like the following? That did not work. Array!Foo y = Array!Foo(x[]); How does it not work? It compiles successfully: http://dpaste.dzfl.pl/583d20e426a0 yeah man. You are

Re: std.container.Array deep-copy?

2014-10-10 Thread qznc via Digitalmars-d-learn
On Friday, 10 October 2014 at 06:27:35 UTC, yazd wrote: On Thursday, 9 October 2014 at 21:24:55 UTC, qznc wrote: On Thursday, 9 October 2014 at 21:14:46 UTC, qznc wrote: How can you deep-copy a std.container.Array instance? Ok, the deep-copy problem already got resolved on reddit: Use dup

Re: std.container.Array deep-copy?

2014-10-09 Thread qznc via Digitalmars-d-learn
On Thursday, 9 October 2014 at 21:14:46 UTC, qznc wrote: How can you deep-copy a std.container.Array instance? Ok, the deep-copy problem already got resolved on reddit: Use dup. However, the error is still open. You cannot give an Array!X argument to constructor/replace/insertBefore of Array

std.container.Array deep-copy?

2014-10-09 Thread qznc via Digitalmars-d-learn
How can you deep-copy a std.container.Array instance? The actual array data is heap-allocated and reference-counted. Assignment and .dup only create additional references. Using a copy constructor yields an error: Array!Foo x; Array!Foo y = Array!Foo(x); Error: template std.container.Array!(Fo

Re: Idiomatic D?

2014-01-31 Thread qznc
On Thursday, 30 January 2014 at 22:40:24 UTC, Tofu Ninja wrote: On Thursday, 30 January 2014 at 20:10:01 UTC, Dicebot wrote: On Thursday, 30 January 2014 at 20:05:11 UTC, Tofu Ninja wrote: I hear it thrown around a lot but what does it actually mean? What does the ideal D code look like? What k

Re: A little of coordination for Rosettacode

2014-01-15 Thread qznc
On Thursday, 16 January 2014 at 01:11:23 UTC, bearophile wrote: - To test the compiler betas to see if they have "regressions" if you try to use the new features. This sounds somewhat paradox to me. How can a new feature have a regression? A "regression" means it has worked before, but new fe

Re: A little of coordination for Rosettacode

2014-01-15 Thread qznc
was to use this for regression testing dmd. Anyways if people try code examples they should compile out of the box for good PR. If you are looking for a low-barrier way to support D a little, feel free to check out the fail list [1] and fix some. :) [0] https://bitbucket.org/qznc/rosetta/src

Re: Why is string.front dchar?

2014-01-14 Thread qznc
And a short overview over Unicode in D: http://qznc.github.io/d-tut/unicode.html

Re: Value or Reference Semantics Trait

2014-01-13 Thread qznc
On Sunday, 12 January 2014 at 20:16:15 UTC, Nordlöw wrote: Is there a trait to check whether a type has value or reference semantics? I need this in a template struct that adaptively (using static if) represent histogram bins as either a dense static array or a sparse associative array. No,

stringpool / string interning

2014-01-11 Thread qznc
I would like to efficiently compare lots of strings. The usual approach is String-interning as Java calls it. After a string is "interned" they can be compared via just a single pointer comparison instead of comparing char by char. I have not found anything like that in Phobos. Somebody alread

Re: Learning D as main systems programming language

2014-01-09 Thread qznc
On Wednesday, 8 January 2014 at 23:38:31 UTC, Goran Petrevski wrote: I'm new in the programming, systems programming especially, but I want to learn D more as a systems programming language and by that I mean avoiding libraries at all. My goal is to write a simple operating system totaly in D (

Re: Dub and GtkD

2013-12-21 Thread qznc
On Saturday, 21 December 2013 at 14:52:08 UTC, Russel Winder wrote: I just created a new vibe.d project using dub, all fine. Well once I had solved the libevent problem. Then, as the project is to be a GUI client, I added a gtk-d dependency. I tried building the empty project and the binary co

Re: Language Support - Read and Write

2013-12-15 Thread qznc
On Sunday, 15 December 2013 at 08:41:42 UTC, Siavash Babaei wrote: Is it not possible to read and write in non-latin languages like Hebrew, Arabic, Farsi, etc?! If so, how, and if not, why? D source files are UTF-8. You can name your variables and functions using the fullw wealth of Unicode.

Re: Ranges: is it ok if front is a data member?

2013-12-12 Thread qznc
On Thursday, 12 December 2013 at 21:55:20 UTC, Ali Çehreli wrote: The third condition that is checked to determine whether it is an OutputRange is indeed assignment to front. http://dlang.org/phobos/std_range.html#.put That condition is what makes a slice an OutputRange, which causes the su

Re: Template resolution and interfaces

2013-12-11 Thread qznc
On Tuesday, 10 December 2013 at 17:50:45 UTC, Torje Digernes wrote: http://pastie.org/8542555 Compositing an class via curry fails when I try to use interfaces. Guessing that this is due to when classes are validated for interface implementation and when templates are instantiated. I thought

Re: Only const or immutable class thread local variables are allowed

2013-12-10 Thread qznc
On Tuesday, 10 December 2013 at 09:50:56 UTC, Joseph Rushton Wakeling wrote: On 10/12/13 09:27, Jonathan M Davis wrote: A lot of dmd's error messages aren't great. Would this be better? Cannot initialize thread-local class variable %s with a mutable value. Only const or immutable initia

Re: Only const or immutable class thread local variables are allowed

2013-12-10 Thread qznc
On Tuesday, 10 December 2013 at 09:50:56 UTC, Joseph Rushton Wakeling wrote: On 10/12/13 09:27, Jonathan M Davis wrote: A lot of dmd's error messages aren't great. Would this be better? Cannot initialize thread-local class variable %s with a mutable value. Only const or immutable initia

Re: Stream-Based Processing of Range Chunks in D

2013-12-10 Thread qznc
On Tuesday, 10 December 2013 at 09:57:44 UTC, Nordlöw wrote: I'm looking for an elegant way to perform chunk-stream-based processing of arrays/ranges. I'm building a file indexing/search engine in D that calculates various kinds of statistics on files such as histograms and SHA1-digests. I want

Re: std.string inPattern() and UTF symbols

2013-12-09 Thread qznc
On Monday, 9 December 2013 at 15:58:53 UTC, qznc wrote: I also smell a unicode bug, due to the combination of foreach and length. Bug reported. :) https://d.puremagic.com/issues/show_bug.cgi?id=11712 That is probably not the root of Fras problem, though.

Re: std.string inPattern() and UTF symbols

2013-12-09 Thread qznc
On Monday, 9 December 2013 at 14:44:23 UTC, Fra wrote: various (UTF) symbols seems to be ignored by inPattern, see http://dpaste.dzfl.pl/e8ff9002 for a quick example (munch() uses inPattern() internally) Is it me doing something in an improper way, or is the documentation lacking more specifi

Re: Simultaneous Assignment

2013-12-09 Thread qznc
On Monday, 9 December 2013 at 09:32:26 UTC, Dfr wrote: What i trying to achieve in my current example is more succinct code. A coming from Perl and instead of writing: if(some_complex_statement.here > 0) { writefln("x is %s", some_long_expression.here); } I got used not to repeat complex s

Re: Only const or immutable class thread local variables are allowed

2013-12-09 Thread qznc
On Monday, 9 December 2013 at 06:43:05 UTC, Joseph Rushton Wakeling wrote: On 09/12/13 01:24, Ali Çehreli wrote: On 12/08/2013 02:40 PM, qznc wrote: I understand you are talking about the "Singleton" design pattern. You might want to look how std.parallelism does it with the defau

Re: Simultaneous Assignment

2013-12-09 Thread qznc
On Monday, 9 December 2013 at 07:38:04 UTC, Dfr wrote: Does D has somtething similar ? http://code.google.com/p/go-wiki/wiki/SimultaneousAssignment No, not in general. There are a few special cases, though. The foreach loop can assign value and index simultaneously. foreach (int i, char c;

Re: Only const or immutable class thread local variables are allowed

2013-12-08 Thread qznc
On Sunday, 8 December 2013 at 21:32:35 UTC, Joseph Rushton Wakeling wrote: On 08/12/13 21:12, Ali Çehreli wrote: In any case, I think class static this is the solution: I think I may have misled you by talking about properties, because I _don't_ mean a property of a class. I mean a public s

Re: scoped chdir and similar patterns

2013-12-04 Thread qznc
On Thursday, 5 December 2013 at 01:07:19 UTC, Timothee Cour wrote: A1. Is there a (clever?) way to achieve the following using a single function call? You could (mis)use destructors. = struct chdir_scoped { string olddir; this(string newdir) { olddir = "bar"; writeln

Re: Rest

2013-12-04 Thread qznc
On Sunday, 1 December 2013 at 18:37:25 UTC, guest wrote: just wanted to know if something in my code is really bad or could be solved in more elegant way. Basicly things which people with more experience in D see on their first view of my code. The line splitting in HttpRequest can be simplif

Re: Thread affinity?

2013-12-04 Thread qznc
On Tuesday, 3 December 2013 at 17:10:07 UTC, Rob T wrote: In core.thread I don't see a portable way to pin a thread to a specific core, or at least pin the thread to whatever core it is currently running in. I found this solution, but it's for Windows only. http://www.gamedev.net/blog/1140/en

Re: Monads compared to InputRanges?

2013-12-04 Thread qznc
er in your language. So Coq, Isabelle, and maybe ATS could do that. A similar challenge would be to check if a user-defined plus operator is commutative (a+b == b+a) like arithmetic plus operations. [0] https://bitbucket.org/qznc/d-monad/src/5b9d41c611093db74485b017a72473447f8d5595/generic.d?at

Re: Accessing mutable data that isn't

2013-11-20 Thread qznc
On Wednesday, 20 November 2013 at 22:49:42 UTC, Spott wrote: I've been screwing around with templates lately, and I'm attempting to figure out why the following won't compile: struct value { int a; const auto opBinary(string op, T)(in T rhs) const pure { static i

Re: D game engine -- Any suggestions?

2013-11-20 Thread qznc
On Wednesday, 20 November 2013 at 16:40:59 UTC, Mineko wrote: On Wednesday, 20 November 2013 at 15:30:32 UTC, Geancarlo Rocha wrote: You should fix your LICENSE following these instructions http://www.gnu.org/licenses/gpl-howto.html. I hope you understand the virality of GPL and why most people

Re: D on learnxinyminutes.com

2013-11-18 Thread qznc
On Sunday, 17 November 2013 at 20:56:47 UTC, John J wrote: Can you please add the D language to the http://learnxinyminutes.com/ That's an interesting way of quickly introducing a language through a long and well commented code example. Writing this is probably a good learning experience for

Re: pure-ifying my code

2013-11-18 Thread qznc
On Monday, 18 November 2013 at 07:37:27 UTC, Jonathan M Davis wrote: This is middleend optimization stuff, though. I'm not quite sure what you mean by this. There is no middle-end. We have the front-end, which is shared by dmd, gdc, and ldc, and then each compiler has its own backend. Anythin

Re: From D struct to C struct

2013-11-18 Thread qznc
On Monday, 18 November 2013 at 08:32:11 UTC, Namespace wrote: I found another approach. It avoids the GC and the Heap: A Circular Buffer: http://dpaste.dzfl.pl/cf1e7afb That should work. It is unsafe, but might work in your specific case. The problem is that future changes might exhibit memo

Re: pure-ifying my code

2013-11-17 Thread qznc
On Sunday, 17 November 2013 at 21:00:16 UTC, Jonathan M Davis wrote: will definitely result in multiple calls to pure_func. It's not that it's impossible for the compiler to do it - it's perfectly possible. But doing so would require at least basic code flow analysis, and dmd almost never does

Re: From D struct to C struct

2013-11-17 Thread qznc
On Sunday, 17 November 2013 at 22:11:02 UTC, Namespace wrote: Hello. I have some trouble with C interfacing. I have a C struct with an integer member and I want to wrap this into a D template. But if I want to access the C API, I have to convert the C struct with the type informations of the D

Re: Efficient string concatenation?

2013-11-15 Thread qznc
On Friday, 15 November 2013 at 22:35:48 UTC, Jacek Furmankiewicz wrote: I am learning D by going through Ali Cehreli's otherwise excellent "Programming in D" PDF and he did not show this in his initial chapter on Strings. Well, Appender is not string specific. D feels like being in a differen

Re: What is the closest to ConcurrentHashMap and NavigableMap in Java?

2013-11-15 Thread qznc
On Thursday, 14 November 2013 at 23:10:58 UTC, Jacek Furmankiewicz wrote: While looking a D, I am just trying to focus on the parts which I know would be a showstopper for us on day one...and this particular issue is it. Yes, I also think for long-running memory-hungry server-stuff the curren

Re: Best data structure for a particle system?

2013-11-15 Thread qznc
On Friday, 15 November 2013 at 14:01:36 UTC, Chris Cain wrote: On Friday, 15 November 2013 at 13:32:38 UTC, Mikko Ronkainen wrote: Ok, thanks! That linked list cache thrashing was just the thing I knew that I don't know :) Let's say I just use dynamic array and grow it when adding new particl

Re: Deimos rules?

2013-11-14 Thread qznc
On Wednesday, 13 November 2013 at 22:46:45 UTC, Jonathan M Davis wrote: On Wednesday, November 13, 2013 23:01:58 Xavier Bigand wrote: I work on XCB integration, so I think that I can add bindings in deimos. C headers are translated to d modules by using DStep or manually? If manually need I

Re: What does func!thing mean?

2013-11-07 Thread qznc
On Friday, 8 November 2013 at 05:46:29 UTC, ProgrammingGhost wrote: I'm a D noob. ".map!(a => a.length)" seems like the lambda is passed into the template. ".map!split" just confuses me. What is split? I thought only types can be after "!". I would guess split is a standard function but then s

Re: UFCS with constructors

2013-11-06 Thread qznc
On Wednesday, 6 November 2013 at 11:04:05 UTC, bearophile wrote: import std.typecons: Typedef; alias Foo = Typedef!double; void main() { auto a1 = Foo(1); pragma(msg, typeof(a1)); auto a2 = 1.Foo; pragma(msg, typeof(a2)); auto a3 = Foo(-1); pragma(msg, typeof(a3)); aut

Re: Cast delegate and functions.

2013-10-31 Thread qznc
On Thursday, 31 October 2013 at 13:12:31 UTC, Wolftein wrote: void delegate(Event) void delegate(T) Where T is a class that inherits Event. I'm trying to cast (void delegate(T)) to (void delegate(Event)) to be able to store them in a map, but when i cast them i get null exeception. Same thin

Re: std.range.chunk without length

2013-10-30 Thread qznc
On Wednesday, 30 October 2013 at 00:20:12 UTC, Stephan Schiffels wrote: Hi, I'd like a version of std.range.chunk that does not require the range to have the "length" property. As an example, consider a file that you would like parse by lines and always lump together four lines, i.e. impor

Re: Looking for something similar to Python's bisect_right

2013-10-30 Thread qznc
On Wednesday, 30 October 2013 at 18:56:42 UTC, Zeke wrote: On Wednesday, 30 October 2013 at 14:17:22 UTC, qznc wrote: Why do you want to find the exact prime first? Just check against sqrt(num) in the loop. auto upper = cast(ulong)sqrt(cast(double)num)) + 1; foreach(ulong prime; primes) { if

Re: Looking for something similar to Python's bisect_right

2013-10-30 Thread qznc
On Wednesday, 30 October 2013 at 06:04:36 UTC, Zeke wrote: Hello, I'm on day 2 of learning D. I've learned C, C++, Java, Python, Ruby in University, but I wanted to broaden my palette by picking up D. This project is a basic implementation of Project Euler problem 10. I build an array of prim

Re: GhostDoc for VisualD?

2013-10-24 Thread qznc
On Wednesday, 23 October 2013 at 15:56:33 UTC, Namespace wrote: Is there anything like this for VisualD? As far as I understand the GhostDoc website it generates prose comments from the type information? The only reason I can think of are weird enterprise requirements like "every method must

Re: Help with concurrency - traversing a DAG

2013-10-23 Thread qznc
On Tuesday, 22 October 2013 at 08:13:57 UTC, tbttfox wrote: On Friday, 18 October 2013 at 19:47:37 UTC, qznc wrote: Create a task for each node without a parent. Let the tasks create new tasks for their children. I was finally able to try this out, but I'm having a problem. My test case

Re: D and C++

2013-10-21 Thread qznc
On Monday, 21 October 2013 at 11:29:54 UTC, develop32 wrote: On Monday, 21 October 2013 at 11:08:15 UTC, qznc wrote: On Saturday, 19 October 2013 at 13:20:28 UTC, develop32 wrote: Hi, Are there any recent improvements in how D interfaces with C++? I got the impression that some work has been

Re: Changing elements during foreach

2013-10-21 Thread qznc
On Monday, 21 October 2013 at 20:14:09 UTC, ixid wrote: On Monday, 21 October 2013 at 19:37:47 UTC, Jonathan M Davis wrote: On Monday, October 21, 2013 21:16:00 qznc wrote: On Monday, 21 October 2013 at 16:22:29 UTC, Krzysztof Ciebiera wrote: > I understand slices now and I don't

Re: Changing elements during foreach

2013-10-21 Thread qznc
On Monday, 21 October 2013 at 16:22:29 UTC, Krzysztof Ciebiera wrote: I understand slices now and I don't find it consistent with "no shoot in the foot by default" statement. I agree. The pitfalls are well understood, yet everybody seems to love them. Ok, compared to C array they are an improv

Re: D and C++

2013-10-21 Thread qznc
On Saturday, 19 October 2013 at 13:20:28 UTC, develop32 wrote: Hi, Are there any recent improvements in how D interfaces with C++? I got the impression that some work has been done on that, in order to make DMD a self-hosting compiler. I do not know of any recent improvements. The current pl

Re: Changing elements during foreach

2013-10-21 Thread qznc
On Monday, 21 October 2013 at 10:31:51 UTC, Krzysztof Ciebiera wrote: Is the following compiler behavior consistent with language specification? import std.stdio; void main() { int a[][] = [[1,2,3]]; foreach(x; a) { x[0] = 0; x ~= 4; } writeln(a); } I under

Re: Help with concurrency - traversing a DAG

2013-10-18 Thread qznc
On Friday, 18 October 2013 at 16:31:13 UTC, tbttfox wrote: My not currently not working implementation has the workers make a pull request from the master. As far as I understand you just want something working right now? Then my suggestion would be to look into std.parallelism [0]. Create a

Re: Help with concurrency - traversing a DAG

2013-10-18 Thread qznc
On Friday, 18 October 2013 at 07:20:07 UTC, tbttfox wrote: So I've got a project in mind, and at the core of that project is a DAG with lots of nodes. This seems to be a great candidate for concurrent evaluation. The problem is that a node can only be evaluated after all of its parents have.

Re: mutable, const, immutable guidelines

2013-10-17 Thread qznc
On Wednesday, 16 October 2013 at 20:33:23 UTC, H. S. Teoh wrote: I'm of the view that code should only require the minimum of assumptions it needs to actually work. If your code can work with mutable types, then let it take a mutable (unqualified) type. If your code works without modifying inpu

Re: mutable, const, immutable guidelines

2013-10-17 Thread qznc
On Wednesday, 16 October 2013 at 20:33:23 UTC, H. S. Teoh wrote: I'm of the view that code should only require the minimum of assumptions it needs to actually work. If your code can work with mutable types, then let it take a mutable (unqualified) type. If your code works without modifying inpu

Re: mutable, const, immutable guidelines

2013-10-16 Thread qznc
On Wednesday, 16 October 2013 at 17:55:14 UTC, H. S. Teoh wrote: Maybe it's helpful to understand how D's const system works. The following diagram may help (please excuse the ASCII graphics): const / \ mutable immutable I think people in this threa

Re: mutable, const, immutable guidelines

2013-10-10 Thread qznc
On Thursday, 10 October 2013 at 18:39:32 UTC, Christian Köstlin wrote: On 10/10/13 1:05 , qznc wrote: Very interesting discussion! > contract between caller and callee. If an argument is const, it means > the callee says he can handle others changing the state concurrently. i think wh

Re: mutable, const, immutable guidelines

2013-10-10 Thread qznc
On Wednesday, 9 October 2013 at 04:31:55 UTC, Ali Çehreli wrote: On 10/08/2013 03:12 PM, qznc wrote: > On Monday, 7 October 2013 at 17:57:11 UTC, Ali Çehreli wrote: >> To look at just one usage example, the following line carries two >> requirements: >> >> auto

Re: Starting D with a project in mind.

2013-10-10 Thread qznc
On Thursday, 10 October 2013 at 19:49:15 UTC, Andrew wrote: Hi All, I've been writing a MUD for a little while, initially using Haskell but now using C. I develop on MacOS X but deploy to a Raspberry Pi. I loved using Haskell especially using the Parsec parser but unfortunately I couldn't bui

Re: mutable, const, immutable guidelines

2013-10-09 Thread qznc
On Wednesday, 9 October 2013 at 15:50:55 UTC, Daniel Davidson wrote: > I would rephrase the second guideline as: "Never dup or idup an argument > to make it mutable or immutable, but require the caller to do this > (might be able to avoid it)". Agreed. But it means you agree with me that immutab

Re: mutable, const, immutable guidelines

2013-10-09 Thread qznc
On Wednesday, 9 October 2013 at 15:50:55 UTC, Daniel Davidson wrote: void foo(const(MutableType) mt); void foo(immutable(MutableType) mt); Naturally the inclination is to choose the second as it is a stronger guarantee that no threads are changing the data. Cool. But wait, the first one still

Re: mutable, const, immutable guidelines

2013-10-09 Thread qznc
On Wednesday, 9 October 2013 at 04:41:35 UTC, Ali Çehreli wrote: > 4. Data structures should not restrict themselves to be mutable, const, > or immutable. What is the template of a struct that can be used as such? Providing simple values seems to be insufficient: struct MyInt { int i;

Re: mutable, const, immutable guidelines

2013-10-08 Thread qznc
On Monday, 7 October 2013 at 17:57:11 UTC, Ali Çehreli wrote: To look at just one usage example, the following line carries two requirements: auto a = T(); immutable b = a; 1) b will be an immutable copy of a. 2) T will always be usable as in that fashion. If T appears on an API, it

Re: mutable, const, immutable guidelines

2013-10-08 Thread qznc
On Wednesday, 2 October 2013 at 13:09:34 UTC, Daniel Davidson wrote: 1. If a variable is never mutated, make it const, not immutable. 2. Make the parameter reference to immutable if that is how you will use it anyway. It is fine to ask a favor from the caller. ... I think guideline 1 should b

Re: unsigned interger overflow

2013-10-02 Thread qznc
On Wednesday, 2 October 2013 at 05:41:50 UTC, Jonathan M Davis wrote: On Wednesday, October 02, 2013 12:32:24 Alexandr Druzhinin wrote: Is it safe to replace code: uint index; // do something index++; if(index == index.max) index = index.init; by the following code uint index; // do something

Re: Learning D - first steps and best practices

2013-10-02 Thread qznc
On Wednesday, 2 October 2013 at 03:28:59 UTC, Jonathan M Davis wrote: On Wednesday, October 02, 2013 03:19:19 Jesse Phillips wrote: For me, if the program didn't format brackets on the same line I wouldn't use it. If you start making things configurable, may as well improve indent's support fo

Re: RosettaCode proposal: RFC diagram converter

2013-10-01 Thread qznc
On Monday, 30 September 2013 at 23:27:48 UTC, bearophile wrote: Inspired by a talk by Eden in the StrangeLoop 2013 conference, I'd like to create a new small Rosettacode Task. Perhaps someone here is able to review this task description a little, or even to implement the D solution: - - - -

Re: Learning D - first steps and best practices

2013-10-01 Thread qznc
On Sunday, 29 September 2013 at 07:49:21 UTC, Jonathan M Davis wrote: I confess that I don't understand why so many people are fixated on having a standard style, particularly when it's very, very clear that most everyone disagrees on what counts as good style. What little we have in terms of o

Re: 'pp' for D?

2013-10-01 Thread qznc
On Tuesday, 1 October 2013 at 09:21:44 UTC, John Colvin wrote: On Monday, 30 September 2013 at 21:24:28 UTC, linkrope wrote: But putting quotes around a string value is obviously not enough. What if the string contains a quote? "hell\"o" would become `"hell"o"`! Would would you want it be bec

Re: Question about garbage collector

2013-08-29 Thread qznc
On Wednesday, 28 August 2013 at 21:28:11 UTC, bioinfornatics wrote: Hi everyone, yesterday i read an article into a french linux journal that in some years garbage collector will disapear. Why ? he explain in very very short as: -- - Moore's law will be not anymore tru

Re: improve concurrent queue

2013-08-27 Thread qznc
On Monday, 26 August 2013 at 19:35:28 UTC, luminousone wrote: I have been working on a project and needed a good concurrent queue What does "good" mean? Concurrent queues have so many design parameters (single reader? single writer? blocking? bounded? etc) and there is no queue, which perform

Re: Limited Semi-PolyMorphic (LSP) structs?

2013-08-26 Thread qznc
On Monday, 26 August 2013 at 11:20:17 UTC, Era Scarecrow wrote: Been a while and out of the loop, I need to get my hands dirty in the code again (soon). Anyways, let's get to the matter at hand as I'm thinking about it. I'm working on some code (or will work on code again) that could use a pol

Range-based INI parser

2013-08-25 Thread qznc
Playing around with ranges I built [0] a little parser for INI files [1]. It does not support multiline values, since then I cannot do the line splitting in a different component. Any good architecture ideas here? The thing with INI is that the definition is fuzzy. This means the parser sho

Re: ElementType!string

2013-08-25 Thread qznc
On Sunday, 25 August 2013 at 19:38:52 UTC, Paolo Invernizzi wrote: On Sunday, 25 August 2013 at 19:25:08 UTC, qznc wrote: Apparently, ElementType!string evaluates to dchar. I would have expected char. Why is that? I think is because they are iterated by ranges as dchar, that's equivale

ElementType!string

2013-08-25 Thread qznc
Apparently, ElementType!string evaluates to dchar. I would have expected char. Why is that?

Re: Creating a growable binary heap or priority queue using Phobos?

2013-06-22 Thread qznc
On Saturday, 22 June 2013 at 07:48:25 UTC, qznc wrote: On Monday, 14 November 2011 at 06:15:18 UTC, SimonM wrote: On 2011/11/14 02:10 AM, bearophile wrote: SimonM: 2009, 27 April: http://www.digitalmars.com/d/archives/digitalmars/D/std.algorithm.BinaryHeap_88811.html See the working

Re: Creating a growable binary heap or priority queue using Phobos?

2013-06-22 Thread qznc
On Monday, 14 November 2011 at 06:15:18 UTC, SimonM wrote: On 2011/11/14 02:10 AM, bearophile wrote: SimonM: 2009, 27 April: http://www.digitalmars.com/d/archives/digitalmars/D/std.algorithm.BinaryHeap_88811.html See the working version: http://rosettacode.org/wiki/Huffman_coding#D Bye, bea

Re: AnalyzeD

2013-06-18 Thread qznc
On Tuesday, 18 June 2013 at 00:20:38 UTC, Andrej Mitrovic wrote: On Thursday, 30 May 2013 at 08:26:01 UTC, bioinfornatics wrote: hi Someone know if AnalyzeD could to be used from command line ? i.e http://dconf.org/talks/rohe.html I failed to find AnalyzeD source code thanks I think it's cl

Monad and its little sisters

2013-05-16 Thread qznc
I implemented the Maybe monad using template specialization. Feedback welcome! https://bitbucket.org/qznc/d-monad/src/ba39f2551af0e2e90a40653af92c048fed519a18/generic.d?at=master However, a few questions or possibly shortcomings of D came up. 1. I could not specify the inheritance between the

Re: std.net.curl is not working?

2013-04-26 Thread qznc
Fri, 26 Apr 2013 19:25:16 +0200: mab wrote > Why i get the following Error, when i try to compile a simple "Hello > World" that imports std.net.curl= > > The Error: > # dmd hello.d /usr/lib/x86_64-linux-gnu/libphobos2.a(curl.o): In > function `_D3std3net4curl4Curl19_sharedStaticCtor28FZv': > std/

Re: Random double

2013-04-24 Thread qznc
On Wednesday, 24 April 2013 at 06:56:44 UTC, Ivan Kazmenko wrote: On Wednesday, 24 April 2013 at 06:37:50 UTC, qznc wrote: It also raises the question what uniform means in the context of floating point. Uniform over the numbers or uniform over the bit patterns? I'd like to mention

  1   2   >