Re: Deep copy or clone data structure (or object ?)

2013-12-02 Thread Daniel Davidson
On Monday, 2 December 2013 at 13:42:48 UTC, Dfr wrote: Hi I searched through various D documentation sources and did not found anything except 'std.copy', but it's only for slices. Is there such feature in standart library ? Or some easy way to clone for example map of slices of maps or an obj

Re: pure-ifying my code

2013-11-18 Thread Daniel Davidson
On Sunday, 17 November 2013 at 10:56:16 UTC, Jonathan M Davis wrote: I think that the typical approach at this point is to just drop purity for the moment, but if you want you really want it, you are indeed going to have to implement it yourself. But we'll get there with Phobos eventually. Th

Re: how use lowerBound with just sorting key, not complete values

2013-11-12 Thread Daniel Davidson
On Tuesday, 12 November 2013 at 16:34:30 UTC, bearophile wrote: Daniel Davidson: Yes, but that is only giving the dates. I want the actual array elements. Suppose S is a large object with lots of extra fields in addition to `string foo`. There should be a way to pull out the lower bound

Re: how use lowerBound with just sorting key, not complete values

2013-11-12 Thread Daniel Davidson
On Tuesday, 12 November 2013 at 15:51:53 UTC, bearophile wrote: Daniel Davidson: Is there a way to search an array I know is ordered by date by only supplying date? You can use a map to perform a projection: import std.stdio, std.range, std.datetime, std.algorithm, std.array

how use lowerBound with just sorting key, not complete values

2013-11-12 Thread Daniel Davidson
The following code works for finding the lower bound based on needle. But I have to create a needle which I don't want to do. How can I use lowerBound with just the sortKey, date in this case? So I want to do something like the following - but it won't work. Is there a way to search an array I

Re: is there a merge for associative arrays

2013-11-09 Thread Daniel Davidson
On Tuesday, 5 November 2013 at 17:47:16 UTC, bearophile wrote: TV[TK] mergeAAs(TK, TV)(TV[TK] aas...) { It seems even fit for Phobos. Bye, bearophile I have something I would appreciate feedback/criticism on. My first stab at it worked, but had no support for passing in const/immutable. A

Re: How to iterate through all modules for use with the new getUnitTests trait?

2013-11-06 Thread Daniel Davidson
On Wednesday, 6 November 2013 at 21:26:09 UTC, Dicebot wrote: On Wednesday, 6 November 2013 at 21:07:47 UTC, Gary Willoughby wrote: Unfortunately this still suffers the same problem in that you need a module symbol name to do anything. I need to get all module symbols at compile time. You nee

Re: How to re-initialise an associative array.

2013-11-06 Thread Daniel Davidson
On Wednesday, 6 November 2013 at 16:41:19 UTC, Gary Willoughby wrote: I looked at that but apparently it leaves the array in an unsafe state. Source: http://forum.dlang.org/thread/iu3ll6$2d48$1...@digitalmars.com Is that still the case? The following seems to work just fine. Maybe Kenji h

Re: How to re-initialise an associative array.

2013-11-06 Thread Daniel Davidson
On Wednesday, 6 November 2013 at 16:41:19 UTC, Gary Willoughby wrote: x.clear(); I looked at that but apparently it leaves the array in an unsafe state. Source: http://forum.dlang.org/thread/iu3ll6$2d48$1...@digitalmars.com Wow! Good to know, thanks!

Re: How to re-initialise an associative array.

2013-11-06 Thread Daniel Davidson
On Wednesday, 6 November 2013 at 16:15:36 UTC, Gary Willoughby wrote: A simple request but i'm failing hard. How do i re-init an associative array? This is obviously not the way: import std.stdio; void main(string[] args) { int[string] x;

Re: fieldPostBlit - what is wrong with this and workarounds

2013-11-06 Thread Daniel Davidson
On Friday, 1 November 2013 at 20:29:54 UTC, Jonathan M Davis wrote: On Friday, November 01, 2013 14:28:55 Daniel Davidson wrote: On Thursday, 31 October 2013 at 19:39:44 UTC, Jonathan M Davis Deep copying is not the only reason to have a postblit. Smart pointers such as

is there a merge for associative arrays

2013-11-05 Thread Daniel Davidson
The code below causes a crash. What is the idiomatic way to merge associative arrays? If there is a simple version that allows the value at a key to be clobbered by the value of the right hand operand when there is a collision, that is a start. import std.stdio; void main() { double[string]

Re: Linker error regarding importing and unit tests. Is this a bug?

2013-11-01 Thread Daniel Davidson
On Friday, 1 November 2013 at 12:59:24 UTC, Gary Willoughby wrote: I have a small test case that displays a linker error. I wondered if this is an issue with the tool chain or whether i'm doing something wrong. I have a simple directory structure like this: test/methods.d test/test1.d test/te

Re: fieldPostBlit - what is wrong with this and workarounds

2013-11-01 Thread Daniel Davidson
On Thursday, 31 October 2013 at 19:39:44 UTC, Jonathan M Davis wrote: const and postblit fundamentally don't mix, because for it to work, you have to violate the type system. With postblits, the struct gets memcpied and then the postblit constructor has the chance to mutate the resulting object

Re: is this invalid code

2013-11-01 Thread Daniel Davidson
On Friday, 1 November 2013 at 04:26:25 UTC, Ali Çehreli wrote: You are not going to like my answer but this may be the 16-byte struct bug. Add something to RateCurve and your code works fine... :-/ struct RateCurve { private immutable(DateRate)[] _data; ubyte b; // <-- ADDED } I ap

is this invalid code

2013-10-31 Thread Daniel Davidson
The following crashes on writeln, but looks reasonable. Is some form of initializing ctor required for RateCurve? import std.datetime; import std.range; import std.stdio; struct DateRate { Date date; double value = 0.0; } struct RateCurve { private immutable(DateRate)[] _data; } struct

Re: structs holding on to reference data by pointer

2013-10-31 Thread Daniel Davidson
On Thursday, 31 October 2013 at 16:16:36 UTC, bearophile wrote: That's wrong code, you are escaping a reference to memory (of rc variable) allocated in the stack frame of foo(). The D compiler is not smart enough to recognize the bug. There are optimizations that patch and avoid this bug (lik

Re: fieldPostBlit - what is wrong with this and workarounds

2013-10-31 Thread Daniel Davidson
On Thursday, 31 October 2013 at 15:56:45 UTC, Maxim Fomin wrote: On Thursday, 31 October 2013 at 14:03:28 UTC, Daniel Davidson wrote: Given this code: import plus.tvm.rate_curve; struct T { RateCurve m; } struct S { const(T) rc; } I get this error: Error: mutable method

Re: fieldPostBlit - what is wrong with this and workarounds

2013-10-31 Thread Daniel Davidson
On Thursday, 31 October 2013 at 14:28:31 UTC, bearophile wrote: Daniel Davidson: I get this error: Error: mutable method plus.models.dossier.__unittestL42_1.T.__fieldPostBlit is not callable using a const object Related: http://d.puremagic.com/issues/show_bug.cgi?id=4867 Bye, bearophile

structs holding on to reference data by pointer

2013-10-31 Thread Daniel Davidson
The following seems to work, but feels like luck. When foo returns rc should be taken off the stack. If I recall, in C++ something like this would crash, but why not here? import std.stdio; struct RC { this(this) { data = data.dup; } int[] data; } struct T { const(RC) *rc; void goo() {

fieldPostBlit - what is wrong with this and workarounds

2013-10-31 Thread Daniel Davidson
Given this code: import plus.tvm.rate_curve; struct T { RateCurve m; } struct S { const(T) rc; } I get this error: Error: mutable method plus.models.dossier.__unittestL42_1.T.__fieldPostBlit is not callable using a const object Is this fundamentally incorrect? I abandoned i

Re: Dynamic associative array, to hold many values per key

2013-10-29 Thread Daniel Davidson
On Tuesday, 29 October 2013 at 18:02:46 UTC, Logesh Pillay wrote: On Sunday, 20 October 2013 at 16:08:50 UTC, bearophile wrote: Logesh Pillay: Thanks. Coming to D from python, I have to say D's tuples look difficult. I'm going to see how far I can get with structs writing my sudoku solver.

Re: conv text and pure

2013-10-28 Thread Daniel Davidson
On Thursday, 24 October 2013 at 00:02:30 UTC, bearophile wrote: Jonathan M Davis: Progress is being made on that however (as evidenced by the fact that format can now be pure in the beta for 2.064). Now two of the most common "offenders" of pure/nothrow in my high level code are iota() and a

Re: selectively running unittest functions

2013-10-26 Thread Daniel Davidson
Here is a working solution: https://github.com/patefacio/d-help/blob/master/d-help/opmix/ut.d Currently it only pulls in unittests at the module level. I'm sure it will work on unittests scoped to structs/classes, I just need to figure out how to determine if a compile time named object is an

Re: selectively running unittest functions

2013-10-26 Thread Daniel Davidson
On Saturday, 26 October 2013 at 08:09:26 UTC, Dmitry Olshansky wrote: 26-Oct-2013 02:36, Daniel Davidson пишет: On Friday, 25 October 2013 at 16:43:23 UTC, Daniel Davidson wrote: On Friday, 25 October 2013 at 14:14:39 UTC, Dicebot wrote: This will work starting with 2.064: Ok. I'll

Re: selectively running unittest functions

2013-10-25 Thread Daniel Davidson
On Friday, 25 October 2013 at 16:43:23 UTC, Daniel Davidson wrote: On Friday, 25 October 2013 at 14:14:39 UTC, Dicebot wrote: This will work starting with 2.064: Ok. I'll keep pressing. Here is an updated version: http://pastebin.com/g6FWsTkr The idea is to be able to just impo

Re: selectively running unittest functions

2013-10-25 Thread Daniel Davidson
On Friday, 25 October 2013 at 14:14:39 UTC, Dicebot wrote: This will work starting with 2.064: Ok. I'll keep pressing. Here is an updated version: http://pastebin.com/g6FWsTkr The idea is to be able to just import ut, annotate as you have described and get unit tests run. I want to mixin th

Re: selectively running unittest functions

2013-10-25 Thread Daniel Davidson
On Friday, 25 October 2013 at 13:30:54 UTC, Dicebot wrote: On Friday, 25 October 2013 at 13:23:46 UTC, Daniel Davidson wrote: What I'm missing, and apparently others in the original thread, is a way to run tests selectively. It is difficult to do with unittest because they are not name

Re: selectively running unittest functions

2013-10-25 Thread Daniel Davidson
On Friday, 25 October 2013 at 13:04:03 UTC, Dicebot wrote: I strictly believe any unittest enhancing library must be built on top of existing unittest blocks using __traits(getUnittest) and be 100% compatible with normal `-unittest` mode I don't disagree. What exactly does that mean and what w

selectively running unittest functions

2013-10-25 Thread Daniel Davidson
I've been through this thread: http://forum.dlang.org/post/mailman.1454.1369104411.4724.digitalmar...@puremagic.com I would like the named unittests, as describe there, but I don't think it is in the works (if I'm wrong please let me know). So I took an approach outlined here (http://www.redd

proper way to find if attribute present?

2013-10-24 Thread Daniel Davidson
enum Bar = "Bar"; @("Foo") @Bar int x; pragma(msg, __traits(getAttributes, x)); This prints: tuple("Foo", "Bar") How do you run code only if "Bar" is associated with a symbol like x? I was hoping something like this: pragma(msg, hasAnnotation!(x, Bar)); Where getAnnotation from (http://forum

Re: conv text and pure

2013-10-23 Thread Daniel Davidson
On Wednesday, 23 October 2013 at 21:37:25 UTC, H. S. Teoh wrote: On Wed, Oct 23, 2013 at 11:17:30PM +0200, Daniel Davidson wrote: On Wednesday, 23 October 2013 at 20:18:39 UTC, Andrej Mitrovic wrote: >On 10/23/13, Daniel Davidson wrote: >>Great, thanks. What is the best way to ge

Re: conv text and pure

2013-10-23 Thread Daniel Davidson
On Wednesday, 23 October 2013 at 20:18:39 UTC, Andrej Mitrovic wrote: On 10/23/13, Daniel Davidson wrote: Great, thanks. What is the best way to get on that version for the Mac (pointer to instructions)? You can download the beta here: http://forum.dlang.org/thread/52605c84.6010

Re: conv text and pure

2013-10-23 Thread Daniel Davidson
On Wednesday, 23 October 2013 at 19:56:26 UTC, Andrej Mitrovic wrote: On Wednesday, 23 October 2013 at 19:55:26 UTC, Daniel Davidson wrote: Should text be pure? It's pure in 2.064, the upcoming release. Great, thanks. What is the best way to get on that version for the Mac (point

conv text and pure

2013-10-23 Thread Daniel Davidson
Should text be pure? I have multiple enforce statements of the form: enforce(0 == _history.length || !binaryFun!(orderingPred)(additional, _history[$-1]), text(V.stringof, " must be added in chronological order, but ", additional, " comes b

Re: this() immutable

2013-10-23 Thread Daniel Davidson
On Wednesday, 16 October 2013 at 21:11:19 UTC, H. S. Teoh wrote: On Wed, Oct 16, 2013 at 10:09:50PM +0200, Daniel Davidson wrote: [...] I reported my issue with the `chain` function to this NG and tried to start annotating items used by chain with pure to see how far the thread led. Honestly

Re: matrix business in D

2013-10-18 Thread Daniel Davidson
On Thursday, 17 October 2013 at 20:31:38 UTC, Yura wrote: Dear D programmers, I am very new to D programming language. I just started to learn it as an alternative to python since the latter sometimes is too slow. My question is whether there some simple ways to solve linear algebra problems

Re: how would D be different if string were const(char)[]?

2013-10-17 Thread Daniel Davidson
On Thursday, 17 October 2013 at 18:28:31 UTC, Meta wrote: On Thursday, 17 October 2013 at 13:08:18 UTC, Daniel Davidson wrote: If it would be no different then why prefer immutable(char)[] for string? Strings are immutable in quite a few other languages. Ex: Java, Python. I found this old

Re: mutable, const, immutable guidelines

2013-10-17 Thread Daniel Davidson
On Wednesday, 16 October 2013 at 20:33:23 UTC, H. S. Teoh wrote: On Wed, Oct 16, 2013 at 09:45:09PM +0200, Daniel Davidson wrote: On Wednesday, 16 October 2013 at 19:12:48 UTC, Dicebot wrote: [...] >I think any usage of immutable with types/entities not >initially >designed for imm

how would D be different if string were const(char)[]?

2013-10-17 Thread Daniel Davidson
If it would be no different then why prefer immutable(char)[] for string?

Re: does cast make an lvalue appear to be an rvalue

2013-10-16 Thread Daniel Davidson
On Wednesday, 16 October 2013 at 19:49:25 UTC, monarch_dodra wrote: On Wednesday, 16 October 2013 at 17:50:48 UTC, Daniel Davidson wrote: How do you propose to make a mutable copy *generically*? You can't. Let alone generically. If I give you an "immutable int* p", how do

Re: does cast make an lvalue appear to be an rvalue

2013-10-16 Thread Daniel Davidson
On Wednesday, 16 October 2013 at 19:49:25 UTC, monarch_dodra wrote: On Wednesday, 16 October 2013 at 17:50:48 UTC, Daniel Davidson wrote: How do you propose to make a mutable copy *generically*? You can't. Let alone generically. If I give you an "immutable int* p", how do

Re: this() immutable

2013-10-16 Thread Daniel Davidson
On Wednesday, 16 October 2013 at 19:55:41 UTC, Simen Kjaeraas wrote: On 2013-10-16, 18:54, Daniel Davidson wrote: On Thursday, 13 June 2013 at 12:29:57 UTC, Simen Kjaeraas wrote: On Thu, 13 Jun 2013 14:17:22 +0200, Stephan Schiffels wrote: For example, is there a way of instantiating an

Re: mutable, const, immutable guidelines

2013-10-16 Thread Daniel Davidson
On Wednesday, 16 October 2013 at 19:12:48 UTC, Dicebot wrote: On Wednesday, 16 October 2013 at 19:06:06 UTC, Daniel Davidson wrote: I don't understand how it could be fine. As code grows it would lead to people not adding useful members like history just because of the huge repercus

Re: mutable, const, immutable guidelines

2013-10-16 Thread Daniel Davidson
On Wednesday, 16 October 2013 at 19:01:59 UTC, H. S. Teoh wrote: On Wed, Oct 16, 2013 at 08:49:51PM +0200, Daniel Davidson wrote: On Wednesday, 16 October 2013 at 17:55:14 UTC, H. S. Teoh wrote: >On Wed, Oct 16, 2013 at 07:23:24PM +0200, Daniel Davidson >wrote: [...] >>If you have

Re: mutable, const, immutable guidelines

2013-10-16 Thread Daniel Davidson
On Wednesday, 16 October 2013 at 18:52:23 UTC, qznc wrote: 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 / \

Re: mutable, const, immutable guidelines

2013-10-16 Thread Daniel Davidson
On Wednesday, 16 October 2013 at 17:55:14 UTC, H. S. Teoh wrote: On Wed, Oct 16, 2013 at 07:23:24PM +0200, Daniel Davidson wrote: On Wednesday, 2 October 2013 at 13:09:34 UTC, Daniel Davidson wrote: [...] >Maybe it is a philosophical question, but where does >immutability >really

Re: does cast make an lvalue appear to be an rvalue

2013-10-16 Thread Daniel Davidson
On Wednesday, 16 October 2013 at 18:09:55 UTC, Maxim Fomin wrote: On Wednesday, 16 October 2013 at 17:05:25 UTC, Daniel Davidson wrote: The code below fails to compile due to the last line. I was hoping casting away immutable would allow the call to foo. I think it is not accepted because of

Re: does cast make an lvalue appear to be an rvalue

2013-10-16 Thread Daniel Davidson
On Wednesday, 16 October 2013 at 17:55:56 UTC, Dicebot wrote: struct S { R r; this(ref immutable(T) t) immutable { r.tupleof = t.tupleof; } } ? Thanks. It is cute - but not so helpful. The example stands. I *need* to call a createRFromT. Their shapes are the same in this simple ex

Re: does cast make an lvalue appear to be an rvalue

2013-10-16 Thread Daniel Davidson
On Wednesday, 16 October 2013 at 17:58:41 UTC, Dicebot wrote: On Wednesday, 16 October 2013 at 17:50:48 UTC, Daniel Davidson wrote: On Wednesday, 16 October 2013 at 17:16:39 UTC, Dicebot wrote: It works as it should. Make a mutable copy of t2 and pass it. Or make foo() accept const. I can&#

Re: does cast make an lvalue appear to be an rvalue

2013-10-16 Thread Daniel Davidson
On Wednesday, 16 October 2013 at 17:16:39 UTC, Dicebot wrote: It works as it should. Make a mutable copy of t2 and pass it. Or make foo() accept const. I can't imagine a single legitimate use case for destroying type system in a way you want. How do you propose to make a mutable copy *generi

Re: mutable, const, immutable guidelines

2013-10-16 Thread Daniel Davidson
On Wednesday, 2 October 2013 at 13:09:34 UTC, Daniel Davidson wrote: I'm reviewing Ali's insightful presentation from 2013 DConf. I wonder has he or anyone else followed up on the concepts or formalized some guidelines that could achieve consensus. I definitely agree it would be

does cast make an lvalue appear to be an rvalue

2013-10-16 Thread Daniel Davidson
The code below fails to compile due to the last line. I was hoping casting away immutable would allow the call to foo. I think it is not accepted because of the rval to ref issue. If that is the case, how can foo be called by casting? I'm not a fan of casting but I'm finding cases where it is

Re: this() immutable

2013-10-16 Thread Daniel Davidson
On Thursday, 13 June 2013 at 12:29:57 UTC, Simen Kjaeraas wrote: On Thu, 13 Jun 2013 14:17:22 +0200, Stephan Schiffels wrote: For example, is there a way of instantiating an object normally (i.e. mutable), and then later "freeze" it to immutable via a simple cast or so? In std.exception th

surprised by link error

2013-10-16 Thread Daniel Davidson
The following code runs fine. There is a whole bunch of types imported, so whittling it down to the problem is not too easy. import plus.models.assumption; import pprint.pp; import std.stdio; import std.datetime; void main() { immutable am = AssumptionModel(); writeln(pp(am)); } That code

Re: should chain be pure

2013-10-15 Thread Daniel Davidson
On Tuesday, 15 October 2013 at 13:43:55 UTC, bearophile wrote: Daniel Davidson: I would like to correctly annotate my functions with pure. I've hit a function that is calling chain which breaks purity. Is chain really not pure? Phobos is slowly being annotated with pure/nothrow (and

should chain be pure

2013-10-15 Thread Daniel Davidson
I would like to correctly annotate my functions with pure. I've hit a function that is calling chain which breaks purity. Is chain really not pure? The relevant section of code is: ... auto sortedRage = assumeSorted!("a.when < b.when")(opSlice()); auto trisection = sortedRa

Re: objects as AA keys

2013-10-15 Thread Daniel Davidson
On Tuesday, 15 October 2013 at 05:44:25 UTC, captaindet wrote: hi, i am a bit confused. the official language ref ( http://dlang.org/hash-map.html ) states: " Classes can be used as the KeyType. For this to work, the class definition must override the following member functions of class Ob

Re: mutable, const, immutable guidelines

2013-10-10 Thread Daniel Davidson
On Thursday, 10 October 2013 at 23:12:24 UTC, qznc wrote: The linked page clearly says "It may, however, be changed by another reference to that same data." usually you would think that no one else should change the data while callee runs. but at least with c++ i could imagine running callee

Re: mutable, const, immutable guidelines

2013-10-10 Thread Daniel Davidson
On Thursday, 10 October 2013 at 23:06:23 UTC, qznc wrote: Maybe the fact that D allows this implicit copy to immutable is the problem? If one could require the use of a specific function, this function could be overridden with working behavior. The following code works. Yes - the issue aris

Re: mutable, const, immutable guidelines

2013-10-10 Thread Daniel Davidson
On Wednesday, 9 October 2013 at 23:05:27 UTC, qznc wrote: 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

Re: Can someone explain why i can change this immutable variable please?

2013-10-09 Thread Daniel Davidson
On Wednesday, 9 October 2013 at 15:33:23 UTC, Ali Çehreli wrote: That string is independent from the argument (i.e. Bar.name). They initially share the same characters. Either of those strings can leave this sharing at will, and that is exactly what name="tess" does. 'name' now refers to dif

Re: Can someone explain why i can change this immutable variable please?

2013-10-09 Thread Daniel Davidson
On Wednesday, 9 October 2013 at 15:46:29 UTC, Gary Willoughby wrote: So why does this give me an error i expect: import std.stdio; class Foo { public void change(string[] name) { name[0] = "tess";

Re: mutable, const, immutable guidelines

2013-10-09 Thread Daniel Davidson
On Wednesday, 9 October 2013 at 04:41:35 UTC, Ali Çehreli wrote: On 10/08/2013 03:03 PM, qznc wrote: > 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 im

Re: mutable, const, immutable guidelines

2013-10-09 Thread Daniel Davidson
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 a = T(); >> immutable b =

Re: Creating a "virtual" stdin/stdout/stderr

2013-10-08 Thread Daniel Davidson
On Tuesday, 8 October 2013 at 20:26:49 UTC, Colin Grogan wrote: On Tuesday, 8 October 2013 at 20:25:42 UTC, Colin Grogan wrote: Hi all, I want to create my own File in memory that I can pipe output to and read it in from another part of the program. I dont want to physically write data to dis

Re: potential deadlock spawning process

2013-10-08 Thread Daniel Davidson
On Tuesday, 8 October 2013 at 16:24:50 UTC, Daniel Davidson wrote: This simple script calls out to find (on a Mac). For me this works. If I increase the output by changing maxdepth to 3 it hangs forever. When I run the same find from the shell it is fine. What could cause a deadlock in this

potential deadlock spawning process

2013-10-08 Thread Daniel Davidson
This simple script calls out to find (on a Mac). For me this works. If I increase the output by changing maxdepth to 3 it hangs forever. When I run the same find from the shell it is fine. What could cause a deadlock in this and what is a workaround? http://pastebin.com/ji8dZwAY Thanks Dan

Re: cascade operator or nearest equivalent

2013-10-07 Thread Daniel Davidson
On Thursday, 12 September 2013 at 19:41:49 UTC, bearophile wrote: Daniel Davidson: I am using Dart for code generation but would like to consider D if I can find a convenient replacement for the following declarative style: Replacing Dart with D seems quite strange, such two languages have

Re: mutable, const, immutable guidelines

2013-10-02 Thread Daniel Davidson
On Wednesday, 2 October 2013 at 17:07:55 UTC, Ali Çehreli wrote: On 10/02/2013 06:09 AM, 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 as

mutable, const, immutable guidelines

2013-10-02 Thread Daniel Davidson
I'm reviewing Ali's insightful presentation from 2013 DConf. I wonder has he or anyone else followed up on the concepts or formalized some guidelines that could achieve consensus. I definitely agree it would be helpful to have a 50 Ways To Improve Your D. The first thing I'd like to see is a se

Re: 'pp' for D?

2013-09-30 Thread Daniel Davidson
On Sunday, 29 September 2013 at 14:31:15 UTC, linkrope wrote: I want to pretty-print the representation of a value of a generic type T. In Ruby, I would use 'pp': value = 'hello' pp value # prints "hello" - with quotes! value = 42 pp value # prints 42 Now, value.to!string eli

Re: drone.io for D

2013-09-27 Thread Daniel Davidson
On Friday, 27 September 2013 at 11:52:46 UTC, Dicebot wrote: That is weird. I have used some common CI platforms like Jenkins for D projects with no issues. Those are simply irrelevant to actual language used. There must be something I am missing. Can you give quick summary what drone.io is a

Re: drone.io for D

2013-09-27 Thread Daniel Davidson
On Friday, 27 September 2013 at 11:22:43 UTC, Dicebot wrote: On Thursday, 26 September 2013 at 21:08:31 UTC, Daniel Davidson wrote: Is there an equivalent? Judging by link it looks like yet another continuous integration suite, is there anything more about it you are interested in? CI is

drone.io for D

2013-09-26 Thread Daniel Davidson
Is there an equivalent?

Re: cast(immutable) vs extra variable

2013-09-23 Thread Daniel Davidson
On Sunday, 22 September 2013 at 17:26:01 UTC, Ali Çehreli wrote: You are not alone. I tried to answer some of these questions in my DConf 2013 talk. I think I have only scratched the surface: http://dconf.org/talks/cehreli.html Ali Ali, thank you for providing great feedback and suggestion

Re: const and immutable members

2013-09-23 Thread Daniel Davidson
On Monday, 23 September 2013 at 03:51:41 UTC, Jonathan M Davis wrote: Doesn't using immutable there present the same problem as with the slice? S is no longer assignable. But who would recommend not using immutable in this case if you want aarr to be stable. If you do not use immutable then who

Re: const and immutable members

2013-09-22 Thread Daniel Davidson
On Sunday, 22 September 2013 at 20:17:03 UTC, Jonathan M Davis wrote: If you have struct S { immutable int[] arr; } then arr can never be assigned to, so a variable of type S can never be assigned to. But if you have Yes - it (arr) can never be assigned to. That is the idea. It has alr

const and immutable members

2013-09-22 Thread Daniel Davidson
In this thread (http://forum.dlang.org/thread/uvhwkgljavskqfueq...@forum.dlang.org) I asked this: 3) Also, is storing immutable(STUFF) in a struct in the general case (as opposed to just this one) useful or silly? Johnathan M Davis replied: As soon as you have a const or immutable member i

Re: cast(immutable) vs extra variable

2013-09-19 Thread Daniel Davidson
On Thursday, 19 September 2013 at 20:05:34 UTC, Jonathan M Davis wrote: As soon as you have a const or immutable member in a struct, you can't ever assign anything to it, even if all of its other members are mutable (you could assign the individual, mutable members but not the whole struct). Th

Re: cast(immutable) vs extra variable

2013-09-19 Thread Daniel Davidson
On Thursday, 19 September 2013 at 16:50:32 UTC, Namespace wrote: cast(immutable)data) is not an lvalue, it's a rvalue. ref accepts only lvalues. Thanks... about the other questions?

cast(immutable) vs extra variable

2013-09-19 Thread Daniel Davidson
Multi-part question: 1) Why does the last line fail? If cast to immutable how is it different than z? I know it is related to the ref. I'm using ref because I think it is likely more efficient - so assume the char[16] were really char[1024]. 2) If I got rid of the ref, how many copies of the

cascade operator or nearest equivalent

2013-09-12 Thread Daniel Davidson
Is there any way to simulate the cascade operator (..) of Dart in D? This operator makes fluid initialization simple. I am using Dart for code generation but would like to consider D if I can find a convenient replacement for the following declarative style: var dateRange = struct('date_

debugging on Mac OSX

2013-04-29 Thread Daniel Davidson
Ho do you debug D executables on mac os x in which debug symbols are available (preferably a setup that works in emacs with gdb or gud-gdb)? This thread seems to bring up the issue I am seeing: http://forum.dlang.org/thread/k55tiv$28u3$1...@digitalmars.com but no solution is provided. Also, t