Re: DDoc with cross-references

2012-04-02 Thread Jonathan M Davis
On Monday, April 02, 2012 13:52:47 Ary Manzana wrote: On 4/2/12 12:39 PM, Jonathan M Davis wrote: On Monday, April 02, 2012 12:20:31 Ary Manzana wrote: I'm planning to add cross-references to the default ddoc output. At least that's the simplest thing I could do right now that might improve

Re: Add Element to list not Working

2012-04-02 Thread Ali Çehreli
On 04/01/2012 10:45 PM, Chris Pons wrote: I'm trying to add an element to a list with insert but that doesn't seem to do anything at all. If I try using ~= it says that Error: cannot append type Node to type SList!(Node). I'm pretty confused about using ~= because it works fine for arrays but

Re: Add Element to list not Working

2012-04-02 Thread James Miller
On 2 April 2012 17:45, Chris Pons cmp...@gmail.com wrote: I'm trying to add an element to a list with insert but that doesn't seem to do anything at all. If I try using ~= it says that Error: cannot append type Node to type SList!(Node). I'm pretty confused about using ~= because it works fine

Re: DDoc with cross-references

2012-04-02 Thread Ary Manzana
On 4/2/12 2:07 PM, Jonathan M Davis wrote: On Monday, April 02, 2012 13:52:47 Ary Manzana wrote: On 4/2/12 12:39 PM, Jonathan M Davis wrote: On Monday, April 02, 2012 12:20:31 Ary Manzana wrote: I'm planning to add cross-references to the default ddoc output. At least that's the simplest

Re: Add Element to list not Working

2012-04-02 Thread Chris Pons
Thanks. I tried doing this and the list didn't update: void AddToList( SList!int list, int i ) { list.insert( i ); } SList!int intList; AddToList( intList, 42 ); but when I switched to this, it worked: SList!int intList; void AddToList( int i ) { intList.insert( i ); } AddToList(

Re: ref const parameters in functions

2012-04-02 Thread L-MAN
On Monday, 2 April 2012 at 05:03:48 UTC, Jonathan M Davis wrote: On Sunday, April 01, 2012 21:23:50 Jonathan M Davis wrote: On Monday, April 02, 2012 05:46:24 L-MAN wrote: Sure, if you have large structs, making a lot of copies of them can be expensive. But to avoid that, you're going to have

Re: DDoc with cross-references

2012-04-02 Thread Ary Manzana
On 4/2/12 2:16 PM, Ary Manzana wrote: On 4/2/12 2:07 PM, Jonathan M Davis wrote: On Monday, April 02, 2012 13:52:47 Ary Manzana wrote: On 4/2/12 12:39 PM, Jonathan M Davis wrote: On Monday, April 02, 2012 12:20:31 Ary Manzana wrote: I'm planning to add cross-references to the default ddoc

Re: Getting only the data members of a type

2012-04-02 Thread Jacob Carlborg
On 2012-04-02 02:43, Ary Manzana wrote: This is what I don't like about D. It gives you a hammer and everyone tries to solve all problems with that single hammer. Then you get duplicated code for basic stuff, like getting the type of a field, in many projects. It's a waste of time for a

Re: DDoc with cross-references

2012-04-02 Thread Jacob Carlborg
On 2012-04-02 06:20, Ary Manzana wrote: I'm planning to add cross-references to the default ddoc output. At least that's the simplest thing I could do right now that might improve ddoc somehow. That would be so nice to have. -- /Jacob Carlborg

Re: DDoc with cross-references

2012-04-02 Thread Jacob Carlborg
On 2012-04-02 07:52, Ary Manzana wrote: On 4/2/12 12:39 PM, Jonathan M Davis wrote: Phobos' macros are in https://github.com/D-Programming-Language/d-programming- language.org/blob/master/std.ddoc As for linking macros, LREF is used for references within a module. XREF is used for references

Re: std.typecons.Ref(T).opImplicitCastTo()

2012-04-02 Thread Alex Rønne Petersen
On 02-04-2012 07:32, Jonathan M Davis wrote: On Monday, April 02, 2012 07:23:23 Alex Rønne Petersen wrote: On 02-04-2012 06:25, Jonathan M Davis wrote: alias this is not supposed to be restricted such that you can only have one per type. That's a temporary, implementation problem. TDPL

Re: Whats the best way to get a struct/class member type?

2012-04-02 Thread simendsjo
On Mon, 02 Apr 2012 00:04:58 +0200, Simen Kjærås simen.kja...@gmail.com wrote: On Sat, 31 Mar 2012 15:20:42 +0200, simendsjo simend...@gmail.com wrote: Seems __traits doesn't have a __traits(getMemberType, T, name). Now I'm doing the following: T t; // instance to use in getMember alias

Re: Whats the best way to get a struct/class member type?

2012-04-02 Thread Simen Kjaeraas
On Mon, 02 Apr 2012 09:58:18 +0200, simendsjo simend...@gmail.com wrote: On Mon, 02 Apr 2012 00:04:58 +0200, Simen Kjærås simen.kja...@gmail.com wrote: On Sat, 31 Mar 2012 15:20:42 +0200, simendsjo simend...@gmail.com wrote: Seems __traits doesn't have a __traits(getMemberType, T,

Re: Whats the best way to get a struct/class member type?

2012-04-02 Thread simendsjo
On Mon, 02 Apr 2012 10:51:35 +0200, Simen Kjaeraas simen.kja...@gmail.com wrote: On Mon, 02 Apr 2012 09:58:18 +0200, simendsjo simend...@gmail.com wrote: On Mon, 02 Apr 2012 00:04:58 +0200, Simen Kjærås simen.kja...@gmail.com wrote: On Sat, 31 Mar 2012 15:20:42 +0200, simendsjo

Re: Whats the best way to get a struct/class member type?

2012-04-02 Thread simendsjo
On Mon, 02 Apr 2012 10:56:41 +0200, simendsjo simend...@gmail.com wrote: The documentation explicitly says it shouldn't work for other than static members though. http://dlang.org/traits.html#getMember http://d.puremagic.com/issues/show_bug.cgi?id=7809

Re: Whats the best way to get a struct/class member type?

2012-04-02 Thread simendsjo
On Mon, 02 Apr 2012 12:22:16 +0200, Simen Kjaeraas simen.kja...@gmail.com wrote: On Mon, 02 Apr 2012 12:07:38 +0200, simendsjo simend...@gmail.com wrote: On Mon, 02 Apr 2012 10:56:41 +0200, simendsjo simend...@gmail.com wrote: The documentation explicitly says it shouldn't work for

Re: DDoc with cross-references

2012-04-02 Thread Adam D. Ruppe
On Monday, 2 April 2012 at 04:20:16 UTC, Ary Manzana wrote: (in fact, now I notice it's flawed, because they are not fully-qualified). I have a dmd pull request waiting for a few fixes from me that will help with this. It adds fully qualified names to one of the outputs so we can do anchors

Re: Add Element to list not Working

2012-04-02 Thread Ali Çehreli
On 04/01/2012 11:18 PM, Chris Pons wrote: Thanks. I tried doing this and the list didn't update: void AddToList( SList!int list, int i ) { list.insert( i ); } Oh, that has nothing to do with SList. SList is a struct and as a fundamental rule of D, structs are copied to functions. SList

Help with C++

2012-04-02 Thread Ary Manzana
Hi, I'm trying to make some additions to DMD. First I want to add a virtual function: virtual void emitLink(OutBuffer *buf) to the struct Type. I did that. Then on doc.c I implement it empty: void Type::emitLink(OutBuffer *buf) { } Then I use it somewhere, like in

Re: std.typecons.Ref(T).opImplicitCastTo()

2012-04-02 Thread Jonathan M Davis
On Monday, April 02, 2012 09:37:04 Alex Rønne Petersen wrote: On 02-04-2012 07:32, Jonathan M Davis wrote: On Monday, April 02, 2012 07:23:23 Alex Rønne Petersen wrote: On 02-04-2012 06:25, Jonathan M Davis wrote: alias this is not supposed to be restricted such that you can only have one

Re: Add Element to list not Working

2012-04-02 Thread Chris Pons
Ah, thank you. I didn't realize taht SList is a struct and that it used value semantics. That clears this up. On Monday, 2 April 2012 at 14:22:25 UTC, Ali Çehreli wrote: On 04/01/2012 11:18 PM, Chris Pons wrote: Thanks. I tried doing this and the list didn't update: void AddToList(

Re: Add Element to list not Working

2012-04-02 Thread Jonathan M Davis
On Monday, April 02, 2012 20:27:18 Chris Pons wrote: Ah, thank you. I didn't realize taht SList is a struct and that it used value semantics. That clears this up. It really shouldn't be using value semantics (though it wouldn't surprise me if it is - I haven't used it). std.container's

Re: Help with C++

2012-04-02 Thread Dmitry Olshansky
On 02.04.2012 18:27, Ary Manzana wrote: Hi, I'm trying to make some additions to DMD. First I want to add a virtual function: virtual void emitLink(OutBuffer *buf) to the struct Type. I did that. Then on doc.c I implement it empty: void Type::emitLink(OutBuffer *buf) { } Then I use it

Length of an SLIst ?

2012-04-02 Thread Chris Pons
I'm trying to find the length of a Slist. I've tried using the built in .length function but it generates this error: Error: no property 'length' for type 'SList!(Node)'. Are there any other built in ways to find the length?

Re: Length of an SLIst ?

2012-04-02 Thread Justin Whear
On Mon, 02 Apr 2012 22:42:23 +0200, Chris Pons wrote: I'm trying to find the length of a Slist. I've tried using the built in .length function but it generates this error: Error: no property 'length' for type 'SList!(Node)'. Are there any other built in ways to find the length? Classic

Re: ref const parameters in functions

2012-04-02 Thread Steven Schveighoffer
On Mon, 02 Apr 2012 00:23:50 -0400, Jonathan M Davis jmdavisp...@gmx.com wrote: No. It's not. It's a temporary, and temporaries are almost always rvalues. The sole (and very bizarre) exception is struct literals (e.g. ABC(20) is currently considered an lvalue). It results in the bizarre

Re: Length of an SLIst ?

2012-04-02 Thread Andrej Mitrovic
On 4/2/12, Justin Whear jus...@economicmodeling.com wrote: Classic singly-linked lists must be iterated to determine length, so use std.range.walkLength on it. Specifically call it on its range. You can get a range by slicing the slist, e.g.: import std.range; import std.container; void

Re: Length of an SLIst ?

2012-04-02 Thread Andrej Mitrovic
On 4/2/12, Justin Whear jus...@economicmodeling.com wrote: Classic singly-linked lists must be iterated to determine length I'm no algorithms buff, but I don't understand the benefit of not storing the length in the SList. What does it cost to maintain an extra variable? It's a single

Re: Length of an SLIst ?

2012-04-02 Thread Ali Çehreli
On 04/02/2012 02:10 PM, Andrej Mitrovic wrote: On 4/2/12, Justin Whearjus...@economicmodeling.com wrote: Classic singly-linked lists must be iterated to determine length I'm no algorithms buff, but I don't understand the benefit of not storing the length in the SList. What does it cost to

Re: Length of an SLIst ?

2012-04-02 Thread Steven Schveighoffer
On Mon, 02 Apr 2012 17:10:40 -0400, Andrej Mitrovic andrej.mitrov...@gmail.com wrote: On 4/2/12, Justin Whear jus...@economicmodeling.com wrote: Classic singly-linked lists must be iterated to determine length I'm no algorithms buff, but I don't understand the benefit of not storing the

Re: Length of an SLIst ?

2012-04-02 Thread Justin Whear
On Mon, 02 Apr 2012 23:10:40 +0200, Andrej Mitrovic wrote: On 4/2/12, Justin Whear jus...@economicmodeling.com wrote: Classic singly-linked lists must be iterated to determine length I'm no algorithms buff, but I don't understand the benefit of not storing the length in the SList. What does

Re: Length of an SLIst ?

2012-04-02 Thread Andrej Mitrovic
On 4/2/12, Steven Schveighoffer schvei...@yahoo.com wrote: (i.e. sublists are also valid SLists) I haven't thought of that, good point. :)

Re: Length of an SLIst ?

2012-04-02 Thread bearophile
Steven Schveighoffer: It all depends on how you model the data. If the data is contained/owned by a single instance, then you can store the length inside that instance. If it's not owned (i.e. sublists are also valid SLists) then you cannot do that. Let me add something to your answer.

Re: ref const parameters in functions

2012-04-02 Thread Timon Gehr
On 04/02/2012 06:23 AM, Jonathan M Davis wrote: No. It's not. It's a temporary, and temporaries are almost always rvalues. The sole (and very bizarre) exception is struct literals (e.g. ABC(20) is currently considered an lvalue). DMD 2.059head treats struct literals as rvalues.

Re: ref const parameters in functions

2012-04-02 Thread Jonathan M Davis
On Tuesday, April 03, 2012 00:28:03 Timon Gehr wrote: On 04/02/2012 06:23 AM, Jonathan M Davis wrote: No. It's not. It's a temporary, and temporaries are almost always rvalues. The sole (and very bizarre) exception is struct literals (e.g. ABC(20) is currently considered an lvalue). DMD

Min-Heap and Hash Table help

2012-04-02 Thread Chris Pons
I'm trying to work with and implement and priority queue( min-heap ) and a hash table. This is the first time I've worked with these data structures so I looked up some information about them to gain an understanding. From what I read, a min-heap is a binary tree that is sorted by a

Re: Min-Heap and Hash Table help

2012-04-02 Thread Justin Whear
On Tue, 03 Apr 2012 00:47:56 +0200, Chris Pons wrote: I'm trying to work with and implement and priority queue( min-heap ) and a hash table. This is the first time I've worked with these data structures so I looked up some information about them to gain an understanding. From what I read,

Re: Min-Heap and Hash Table help

2012-04-02 Thread Chris Pons
Yes, I did see that. How would I set the predicate to sort by fScore? An integer in my struct. On Monday, 2 April 2012 at 22:53:55 UTC, Justin Whear wrote: On Tue, 03 Apr 2012 00:47:56 +0200, Chris Pons wrote: I'm trying to work with and implement and priority queue( min-heap ) and a hash

Re: Min-Heap and Hash Table help

2012-04-02 Thread Justin Whear
On Tue, 03 Apr 2012 01:06:54 +0200, Chris Pons wrote: Yes, I did see that. How would I set the predicate to sort by fScore? An integer in my struct. auto myHeap = BinaryHeap!`a.fScore b.fScore`( rangeOfNodes );

Re: Min-Heap and Hash Table help

2012-04-02 Thread Chris Pons
On Monday, 2 April 2012 at 23:30:38 UTC, Justin Whear wrote: On Tue, 03 Apr 2012 01:06:54 +0200, Chris Pons wrote: Yes, I did see that. How would I set the predicate to sort by fScore? An integer in my struct. auto myHeap = BinaryHeap!`a.fScore b.fScore`( rangeOfNodes ); Ok, makes

Equivalents to policy classes in D

2012-04-02 Thread Joseph Rushton Wakeling
Hello all, I'm coming to D from a background programming in C and C++, though I wouldn't describe myself as an expert in either. One of the C++ techniques I picked up over the last couple of years was the use of policy classes, and I'm wondering how D addresses this issue of combining

Re: Equivalents to policy classes in D

2012-04-02 Thread Cristi Cobzarenco
Mixins templates would be the answer: import std.exception; mixin template UncheckedIndices( T ) { ref T opIndex( int i ) { return this.get_( i ); } } mixin template CheckedIndices( T ) { ref T opIndex( int i ) { enforce( i 0 i this.size ); return this.get_( i ); } }

Re: Help with C++

2012-04-02 Thread Ary Manzana
On 4/3/12 4:01 AM, Dmitry Olshansky wrote: On 02.04.2012 18:27, Ary Manzana wrote: Hi, I'm trying to make some additions to DMD. First I want to add a virtual function: virtual void emitLink(OutBuffer *buf) to the struct Type. I did that. Then on doc.c I implement it empty: void

Re: Equivalents to policy classes in D

2012-04-02 Thread James Miller
On 3 April 2012 12:24, Cristi Cobzarenco cristi.cobzare...@gmail.com wrote: Mixins templates would be the answer: import std.exception; mixin template UncheckedIndices( T ) {   ref T opIndex( int i ) {     return this.get_( i );   } } mixin template CheckedIndices( T ) {   ref T

Re: Min-Heap and Hash Table help

2012-04-02 Thread Henry Robbins Gouk
On Monday, 2 April 2012 at 23:42:45 UTC, Chris Pons wrote: On Monday, 2 April 2012 at 23:30:38 UTC, Justin Whear wrote: On Tue, 03 Apr 2012 01:06:54 +0200, Chris Pons wrote: Yes, I did see that. How would I set the predicate to sort by fScore? An integer in my struct. auto myHeap =

Re: Min-Heap and Hash Table help

2012-04-02 Thread Henry Robbins Gouk
each child node is another heap in heap order. That should be: each child node is the root node of another heap in heap order.

Re: Equivalents to policy classes in D

2012-04-02 Thread Henry Robbins Gouk
I'm not all that familiar with policy classes but, if I understand what you are asking correctly, you can provide implementations in interfaces if the methods are final or static. Is this the sort of thing you mean? import std.stdio; interface Foo { final string foo() {

Re: Min-Heap and Hash Table help

2012-04-02 Thread Chris Pons
I'm still having troubles with the min-heap. Node[] a; auto b = BinaryHeap!a.fScore b.fScore( a[] ); Error 1 Error: template instance BinaryHeap!(a.fScore b.fScore) BinaryHeap!(a.fScore b.fScore) does not match template declaration BinaryHeap(Store,alias less = a b) if

Custom Allocators

2012-04-02 Thread James Miller
I've been doing some reading on dlang.org and the newsgroup archives and have seen talk about allocators and things around the garbage collector. I have a few questions about the entire thing: - I understand that allocators are all about memory management, but how does this affect D and the way

parallel unzip in progress

2012-04-02 Thread Jay Norwood
I'm working on a parallel unzip. I started with phobos std.zip, but found that to be too monolithic. I needed to separate out the tasks that get the directory entries, create the directory tree, get the compressed data, expand the data and create the uncompressed files on disk. It currently