Re: #define trouble

2012-11-27 Thread dnewbie
On Tuesday, 27 November 2012 at 06:27:49 UTC, Ali Çehreli wrote: On 11/26/2012 10:05 PM, dnewbie wrote: I have the following C struct from ldap.h typedef struct ldapmod { int mod_op; char *mod_type; union mod_vals_u { char **modv_strvals; struct berval **modv_bvals; } mod_vals; #define

Re: Segfault with std.container.Array but not regular dynamic array

2012-11-27 Thread Joseph Rushton Wakeling
On 11/26/2012 11:42 PM, Dan wrote: Ok, now I really want to know why it crashes. I've narrowed it down to an example below. It seems there is a problem with RefCounted being used as value in a map. I don't have the expertise to understand the assembly, but just to note that even with all the

Re: type determination

2012-11-27 Thread dsmith
On Tuesday, 27 November 2012 at 07:28:34 UTC, Jacob Carlborg wrote: On 2012-11-27 06:03, dsmith wrote: How can I make something like the following work without Error: cannot append type double to type string[] ? T[] some_function(T[] var) { T[] var2; double a = 12.34; string b = hello;

Re: type determination

2012-11-27 Thread Jonathan M Davis
On Tuesday, November 27, 2012 11:30:31 dsmith wrote: Oh, the static if ... for compile time evaluation; seems unintuitive (no?) since data is encountered at run time. But the types are known at compile time. If you're doing anything with types, it has to be done at compile time. - Jonathan M

Re: What to use instead of array.join if RHS is not a range?

2012-11-27 Thread Andrej Mitrovic
On 11/27/12, H. S. Teoh hst...@quickfur.ath.cx wrote: What about std.algorithm.joiner? Same problem. Anyway here's a quick lazy (pun intended) implementation: import std.array; import std.stdio; struct MyJoiner(T) { T[] array; T sep; @property bool empty() { return array.empty; }

Re: What to use instead of array.join if RHS is not a range?

2012-11-27 Thread Jonathan M Davis
On Tuesday, November 27, 2012 02:33:00 Andrej Mitrovic wrote: This is what I want: struct S { int x; } void main() { S[] arr = [S(2), S(4), S(6)]; S s = S(0); arr.join(s); // fails here assert(arr == [S(2), S(0), S(4), S(0), S(6)]); } Calling join like that fails,

Re: type determination

2012-11-27 Thread dsmith
On Tuesday, 27 November 2012 at 10:45:19 UTC, Jonathan M Davis wrote: On Tuesday, November 27, 2012 11:30:31 dsmith wrote: Oh, the static if ... for compile time evaluation; seems unintuitive (no?) since data is encountered at run time. But the types are known at compile time. If you're doing

Re: Calls to struct methods and immutable

2012-11-27 Thread Joseph Rushton Wakeling
On 11/16/2012 05:51 AM, Ali Çehreli wrote: If makeFoo() were not pure, and in general, Foo may need to provide an .idup member function: I've been trying this out and ran into some problems with the to!()() conversion. Here's a concrete example. Suppose I have a couple of structs which are

Re: Calls to struct methods and immutable

2012-11-27 Thread Joseph Rushton Wakeling
On 11/27/2012 01:16 PM, Joseph Rushton Wakeling wrote: immutable(Node) idup() pure const @property { auto linkCopy = to!(Link[])(links); immutable ilinks = assumeUnique(linkCopy); return immutable(Node)(id, ilinks); } Actually I'm

Re: Calls to struct methods and immutable

2012-11-27 Thread Dan
On Tuesday, 27 November 2012 at 14:05:37 UTC, Joseph Rushton Wakeling wrote: On 11/27/2012 01:16 PM, Joseph Rushton Wakeling wrote: ... so the real issue here seems to be that there's no canonical way (that I can find) to idup an _associative_ array. I'm using a custom gdup that recursively

Re: Segfault with std.container.Array but not regular dynamic array

2012-11-27 Thread Maxim Fomin
On Monday, 26 November 2012 at 22:42:53 UTC, Dan wrote: On Monday, 26 November 2012 at 19:14:09 UTC, Joseph Rushton Wakeling wrote: On 11/26/2012 04:07 PM, Joseph Rushton Wakeling wrote: Ok, now I really want to know why it crashes. I've narrowed it down to an example below. It seems there

Re: Segfault with std.container.Array but not regular dynamic array

2012-11-27 Thread Ali Çehreli
On 11/27/2012 10:04 AM, Maxim Fomin wrote: On Monday, 26 November 2012 at 22:42:53 UTC, Dan wrote: On Monday, 26 November 2012 at 19:14:09 UTC, Joseph Rushton Wakeling wrote: On 11/26/2012 04:07 PM, Joseph Rushton Wakeling wrote: Ok, now I really want to know why it crashes. I've narrowed it

Re: Segfault with std.container.Array but not regular dynamic array

2012-11-27 Thread Maxim Fomin
On Tuesday, 27 November 2012 at 18:30:07 UTC, Ali Çehreli wrote: Same problem under Linux. Somebody, please file this bug! Thank you! :) Ali http://d.puremagic.com/issues/show_bug.cgi?id=9084

Re: SList/DList ranges

2012-11-27 Thread Zhenya
On Tuesday, 27 November 2012 at 07:51:16 UTC, Jonathan M Davis wrote: On Monday, November 26, 2012 19:49:51 Zhenya wrote: Hi! I read the spec,but I didn't find any function,that removes concrete element from list.I am not familiar with D's ranges,so could you help me please? What do you mean

path matching problem

2012-11-27 Thread Charles Hixson
Is there a better way to do this? (I want to find files that match any of some extensions and don't match any of several other strings, or are not in some directories.): import std.file; ... string exts = *.{txt,utf8,utf-8,TXT,UTF8,UTF-8}; string[] exclude = [/template/,

Re: telnet and D

2012-11-27 Thread maarten van damme
Haven't looked at vibe.d yet because it looked more like a library for writing web apps and normal sockets should be enough. Didn't know about Tango, I'll try deciphering the original d1 module.

Re: path matching problem

2012-11-27 Thread Joshua Niehus
On Tuesday, 27 November 2012 at 19:40:56 UTC, Charles Hixson wrote: Is there a better way to do this? (I want to find files that match any of some extensions and don't match any of several other strings, or are not in some directories.): import std.file; ... string exts =

Re: path matching problem

2012-11-27 Thread jerro
On Tuesday, 27 November 2012 at 19:40:56 UTC, Charles Hixson wrote: Is there a better way to do this? (I want to find files that match any of some extensions and don't match any of several other strings, or are not in some directories.): import std.file; ... string exts =

Re: What to use instead of array.join if RHS is not a range?

2012-11-27 Thread Jonathan M Davis
On Tuesday, November 27, 2012 13:05:12 Andrej Mitrovic wrote: On 11/27/12, Jonathan M Davis jmdavisp...@gmx.com wrote: All you need to do is put it in an array. arr.join([s]); Still doesn't work. S[1] s = void; s[0] = S(0); arr.join(s[]); Neither does that.

auto ref and arrays

2012-11-27 Thread Jack Applegame
I don't understand why auto ref doesn't work with arrays. void test1(T)(auto ref const T[] val) {} void test2(T)(auto ref const T val) {} void main() { int b; test2(b); // OK string a; test1(a); // Error: cast(const(char[]))a is not an lvalue } Since a is mutable itself, compiler uses

Re: What to use instead of array.join if RHS is not a range?

2012-11-27 Thread Andrej Mitrovic
On 11/27/12, Jonathan M Davis jmdavisp...@gmx.com wrote: Rather, you're asking it to insert an element between every element in range, which is similar but not the same. In that case, which function to use? Because it already behaves in this way for strings.

Re: auto ref and arrays

2012-11-27 Thread Ali Çehreli
On 11/27/2012 02:09 PM, Jack Applegame wrote: I don't understand why auto ref doesn't work with arrays. void test1(T)(auto ref const T[] val) {} void test2(T)(auto ref const T val) {} void main() { int b; test2(b); // OK string a; test1(a); // Error: cast(const(char[]))a is not an lvalue }

Re: auto ref and arrays

2012-11-27 Thread Jonathan M Davis
On Tuesday, November 27, 2012 14:44:51 Ali Çehreli wrote: On 11/27/2012 02:09 PM, Jack Applegame wrote: I don't understand why auto ref doesn't work with arrays. void test1(T)(auto ref const T[] val) {} void test2(T)(auto ref const T val) {} void main() { int b; test2(b); // OK

Re: auto ref and arrays

2012-11-27 Thread Artur Skawina
On 11/27/12 23:44, Ali Çehreli wrote: On 11/27/2012 02:09 PM, Jack Applegame wrote: I don't understand why auto ref doesn't work with arrays. void test1(T)(auto ref const T[] val) {} void test2(T)(auto ref const T val) {} void main() { int b; test2(b); // OK string a; test1(a); // Error:

Re: telnet and D

2012-11-27 Thread maarten van damme
IIRC, telnet is simple, so it shouldn't be too difficult.. Turns out it indeed was simple. My option negotiation had a bug :D my (primitive) telnet client works now :)

Re: path matching problem

2012-11-27 Thread Charles Hixson
On 11/27/2012 01:31 PM, Joshua Niehus wrote: On Tuesday, 27 November 2012 at 19:40:56 UTC, Charles Hixson wrote: Is there a better way to do this? (I want to find files that match any of some extensions and don't match any of several other strings, or are not in some directories.): import

Re: path matching problem

2012-11-27 Thread Joshua Niehus
On Tuesday, 27 November 2012 at 23:43:43 UTC, Charles Hixson wrote: But why the chained filters, rather than using the option provided by dirEntries for one of them? Is it faster? Just the way you usually do things? (Which I accept as a legitimate answer. I can see that that approach would

Re: path matching problem

2012-11-27 Thread Charles Hixson
On 11/27/2012 01:34 PM, jerro wrote: On Tuesday, 27 November 2012 at 19:40:56 UTC, Charles Hixson wrote: Is there a better way to do this? (I want to find files that match any of some extensions and don't match any of several other strings, or are not in some directories.): import std.file;

Re: What to use instead of array.join if RHS is not a range?

2012-11-27 Thread jerro
won't. You seem to be looking for a function which will insert an element between every element in a range rather than one that joins ranges, and I'm not aware of any function in Phobos which will do that. There may be a way to get one to do what you want, but I can't think of how at the

Re: path matching problem

2012-11-27 Thread jerro
You could replace the inner loop with somehting like: bool excl = exclude.any!(part = name.canFind(part)); std.algorithm seems to generally be running the match in the opposite direction, if I'm understanding it properly. (Dealing with D template is always confusing to me.) OTOH, I

safety of move

2012-11-27 Thread Ellery Newcomer
I find myself using [abusing?] move lately: import std.algorithm; import std.stdio; struct A { const(int) i; int j; int k; } void main() { A* a = new A(); // pretend this is malloc or something // *a = A(1) A a2 = A(1); move(a2, *a); A[] arr = new A[](2);

Re: auto ref and arrays

2012-11-27 Thread Jack Applegame
http://d.puremagic.com/issues/show_bug.cgi?id=9090