Re: "Best" way of passing in a big struct to a function?

2012-10-09 Thread Jonathan M Davis
On Wednesday, October 10, 2012 06:51:50 Val Markovic wrote: > So if I don't need to support accepting rvalues, is there an > argument for "in ref" over "const ref"? "in ref" looks superior: > it's more descriptive and from what the docs say, it gives even > more guarantees about the behavior of the

Re: "Best" way of passing in a big struct to a function?

2012-10-09 Thread Val Markovic
This whole topic is a bit of a thorny one in that D's design is trying to avoid some of the problems that allowing const T& to take rvalues in C++ causes, but it makes a situation like what you're trying to do annoying to handle. And auto ref doesn't really fix it (even though that's whole the

Re: "Best" way of passing in a big struct to a function?

2012-10-09 Thread Jonathan M Davis
On Wednesday, October 10, 2012 06:39:51 Val Markovic wrote: > On Wednesday, 10 October 2012 at 04:55:48 UTC, Val Markovic wrote: > > Oh, and a related question: what is the best way to pass in an > > associative array like CustomStruct[string]? I can't say I'm > > too clear on how AA's are managed/

Re: "Best" way of passing in a big struct to a function?

2012-10-09 Thread Jonathan M Davis
On Wednesday, October 10, 2012 06:27:52 Val Markovic wrote: > TL;DR: what should I use if I need C++'s const& for a param? > > Long version: I have a big struct provided by a library and I'm > trying to pass instances of it to a function that will never need > to modify the passed in value. Natura

Re: "Best" way of passing in a big struct to a function?

2012-10-09 Thread Val Markovic
On Wednesday, 10 October 2012 at 04:55:48 UTC, Val Markovic wrote: Oh, and a related question: what is the best way to pass in an associative array like CustomStruct[string]? I can't say I'm too clear on how AA's are managed/implemented. Do they have value semantics or reference semantics? What

Re: "Best" way of passing in a big struct to a function?

2012-10-09 Thread Val Markovic
Oh, and a related question: what is the best way to pass in an associative array like CustomStruct[string]? I can't say I'm too clear on how AA's are managed/implemented. Do they have value semantics or reference semantics? What about lists?

Re: Detect if running 32 bit program on 64 bit Windows OS

2012-10-09 Thread Simen Kjaeraas
On 2012-01-10 02:10, Josh wrote: Is there a way to do that? I've tried getenv("PROCESSOR_ARCHITECTURE") and shell("echo %PROCESSOR_ARCHITECTURE%"), and both of them return "x86" instead of "AMD64" like cmd. I want to use this to run a 64 bit version of an external program if the OS is 64 b

"Best" way of passing in a big struct to a function?

2012-10-09 Thread Val Markovic
TL;DR: what should I use if I need C++'s const& for a param? Long version: I have a big struct provided by a library and I'm trying to pass instances of it to a function that will never need to modify the passed in value. Naturally I want to pass it efficiently, without incurring a copy. I kno

Re: Splitting a string on multiple tokens

2012-10-09 Thread jerro
On Wednesday, 10 October 2012 at 00:18:17 UTC, ixid wrote: Is there an effective way of splitting a string with a set of tokens? Splitter feels rather limited and multiple passes gives you an array of arrays of strings rather than an array of strings. I'm not sure if I'm missing an obvious appl

Detect if running 32 bit program on 64 bit Windows OS

2012-10-09 Thread Josh
Is there a way to do that? I've tried getenv("PROCESSOR_ARCHITECTURE") and shell("echo %PROCESSOR_ARCHITECTURE%"), and both of them return "x86" instead of "AMD64" like cmd. I want to use this to run a 64 bit version of an external program if the OS is 64 bit, and the 32 bit version if not.

Splitting a string on multiple tokens

2012-10-09 Thread ixid
Is there an effective way of splitting a string with a set of tokens? Splitter feels rather limited and multiple passes gives you an array of arrays of strings rather than an array of strings. I'm not sure if I'm missing an obvious application of library methods or if this is absent.

Re: not expected pointers for struct members from foreach

2012-10-09 Thread bearophile
deed: Meaning struct pointers are unusable or at least highly unreliable? Struct pointers are useful and reliable, but before using them you need to know the difference between heap and stack, what a stack frame is, and how structs are handled when they are on the stack. Learning the basics

Re: not expected pointers for struct members from foreach

2012-10-09 Thread H. S. Teoh
On Wed, Oct 10, 2012 at 12:59:08AM +0200, deed wrote: > On Tuesday, 9 October 2012 at 16:21:47 UTC, bearophile wrote: > >deed: > > > >> // Again, why are the three last adresses the same? > > > >The D language and its compiler is acting correctly here, so the > >output you see is correct. All

Re: not expected pointers for struct members from foreach

2012-10-09 Thread deed
On Tuesday, 9 October 2012 at 16:21:47 UTC, bearophile wrote: deed: // Again, why are the three last adresses the same? The D language and its compiler is acting correctly here, so the output you see is correct. All those structs are allocated on the stack. The first three Test are a

Re: Unexpected OPTLINK termination

2012-10-09 Thread Faux Amis
On 09/10/2012 22:30, Andrei Alexandrescu wrote: On 10/9/12 12:30 PM, Faux Amis wrote: On a side-note, why is rdmd picky about argument order? >dmd test.d -I..\include Because anything after the program is considered an argument to the program. Andrei My bad, should have read the spec bett

Re: Unexpected OPTLINK termination

2012-10-09 Thread Andrej Mitrovic
On 10/9/12, Andrei Alexandrescu wrote: > I'd be bummed because that's quite a logical decision, and how other > interpreters do it. On second thought my solution wouldn't work. --args would still have to be passed before the D file, and people would have to remember that or it wouldn't work, same

Re: Unexpected OPTLINK termination

2012-10-09 Thread Andrei Alexandrescu
On 10/9/12 4:38 PM, Andrej Mitrovic wrote: On 10/9/12, Andrei Alexandrescu wrote: On 10/9/12 12:30 PM, Faux Amis wrote: On a side-note, why is rdmd picky about argument order? >dmd test.d -I..\include Because anything after the program is considered an argument to the program. Andrei

Re: Unexpected OPTLINK termination

2012-10-09 Thread Andrej Mitrovic
On 10/9/12, Andrei Alexandrescu wrote: > On 10/9/12 12:30 PM, Faux Amis wrote: >> On a side-note, why is rdmd picky about argument order? >> >> >dmd test.d -I..\include > > Because anything after the program is considered an argument to the > program. > > Andrei > I think this is a fairly common

Re: Unexpected OPTLINK termination

2012-10-09 Thread Andrei Alexandrescu
On 10/9/12 12:30 PM, Faux Amis wrote: On a side-note, why is rdmd picky about argument order? >dmd test.d -I..\include Because anything after the program is considered an argument to the program. Andrei

Re: this() in struct

2012-10-09 Thread Zhenya
On Tuesday, 9 October 2012 at 19:04:40 UTC, Jonathan M Davis wrote: On Tuesday, October 09, 2012 20:09:56 Zhenya wrote: Ok.Then can I do my own .init property that can be executed in compile-time? No. You directly initialize the member variables to what you want them to be, and that's the val

Re: How can I know that all child thread are gone out?

2012-10-09 Thread Sean Kelly
On Oct 9, 2012, at 8:44 AM, Druzhinin Alexandr wrote: > Hello > I spawn several threads and now I need to know if they has finished their > job. Before I do it by means of messages from child threads to the main one > to inform about finishing. But I'm sure this isn't good enough, because a >

Re: this() in struct

2012-10-09 Thread Jonathan M Davis
On Tuesday, October 09, 2012 20:09:56 Zhenya wrote: > Ok.Then can I do my own .init property that can be executed in > compile-time? No. You directly initialize the member variables to what you want them to be, and that's the values that they have in the init property. You can't have anything li

Re: this() in struct

2012-10-09 Thread Zhenya
On Tuesday, 9 October 2012 at 18:29:18 UTC, Jonathan M Davis wrote: On Tuesday, October 09, 2012 19:08:35 Zhenya wrote: On Tuesday, 9 October 2012 at 17:21:47 UTC, Zhenya wrote: > Hi! > I'm sorry,maybe this topic already was discussed,but could > anybody explain me > why default constructor was

Re: Remove element from DList

2012-10-09 Thread Steven Schveighoffer
On Tue, 09 Oct 2012 13:51:09 -0400, Jonathan M Davis wrote: On Tuesday, October 09, 2012 10:29:46 Steven Schveighoffer wrote: dcollections does not have singly-linked lists. My mistake. I thought that you had said that it did in previous discussions on this topic. I decided early on t

Re: this() in struct

2012-10-09 Thread H. S. Teoh
On Tue, Oct 09, 2012 at 07:08:35PM +0200, Zhenya wrote: > On Tuesday, 9 October 2012 at 17:21:47 UTC, Zhenya wrote: > >Hi! > >I'm sorry,maybe this topic already was discussed,but could anybody > >explain me why default constructor was disallowed in structs? > > And if I have to do some initializat

Re: this() in struct

2012-10-09 Thread Zhenya
On Tuesday, 9 October 2012 at 18:29:18 UTC, Jonathan M Davis wrote: On Tuesday, October 09, 2012 19:08:35 Zhenya wrote: On Tuesday, 9 October 2012 at 17:21:47 UTC, Zhenya wrote: > Hi! > I'm sorry,maybe this topic already was discussed,but could > anybody explain me > why default constructor was

Re: this() in struct

2012-10-09 Thread Jonathan M Davis
On Tuesday, October 09, 2012 19:08:35 Zhenya wrote: > On Tuesday, 9 October 2012 at 17:21:47 UTC, Zhenya wrote: > > Hi! > > I'm sorry,maybe this topic already was discussed,but could > > anybody explain me > > why default constructor was disallowed in structs? > > And if I have to do some initiali

Re: this() in struct

2012-10-09 Thread Ali Çehreli
On 10/09/2012 10:08 AM, Zhenya wrote: On Tuesday, 9 October 2012 at 17:21:47 UTC, Zhenya wrote: Hi! I'm sorry,maybe this topic already was discussed,but could anybody explain me why default constructor was disallowed in structs? And if I have to do some initialization of data members,what is t

Re: this() in struct

2012-10-09 Thread Maxim Fomin
On Tuesday, 9 October 2012 at 17:32:35 UTC, Zhenya wrote: On Tuesday, 9 October 2012 at 17:21:47 UTC, Zhenya wrote: Hi! I'm sorry,maybe this topic already was discussed,but could anybody explain me why default constructor was disallowed in structs? And if I have to do some initialization of

Re: Remove element from DList

2012-10-09 Thread Jonathan M Davis
On Tuesday, October 09, 2012 10:29:46 Steven Schveighoffer wrote: > dcollections does not have singly-linked lists. My mistake. I thought that you had said that it did in previous discussions on this topic. - Jonathan M Davis

Error: function wgdb.to_string is not accessible from module wgdb

2012-10-09 Thread Charles Hixson
What does the following error mean? wgdb.d(24): Error: function wgdb.to_string is not accessible from module wgdb The function in question is the pretty simple: package string to_string(const char *zString) { int i; for (i = 0; zString[i] != 0; ++i) {}; return to!string(zS

Re: bigger then size_t

2012-10-09 Thread Dmitry Olshansky
On 09-Oct-12 19:35, Adam D. Ruppe wrote: On Tuesday, 9 October 2012 at 15:56:15 UTC, maarten van damme wrote: Wouldn't a user then be able to launch that program followed by the contents of a big file of say 5 gig. The operating system won't allow that. There's a limit on argument sizes enforc

Re: this() in struct

2012-10-09 Thread Zhenya
On Tuesday, 9 October 2012 at 17:21:47 UTC, Zhenya wrote: Hi! I'm sorry,maybe this topic already was discussed,but could anybody explain me why default constructor was disallowed in structs? And if I have to do some initialization of data members,what is the way to do it?

Re: bigger then size_t

2012-10-09 Thread Dmitry Olshansky
On 09-Oct-12 20:36, maarten van damme wrote: Another quick question. When I know an array is going to have an length smaller then 255, can I use bytes as index or do I have to use size_t to make it portable across 64 bit platforms? The real question is why you need that? Byte is not faster (if

this() in struct

2012-10-09 Thread Zhenya
Hi! I'm sorry,maybe this topic already was discussed,but could anybody explain me why default constructor was disallowed in structs?

Re: bigger then size_t

2012-10-09 Thread maarten van damme
Another quick question. When I know an array is going to have an length smaller then 255, can I use bytes as index or do I have to use size_t to make it portable across 64 bit platforms?

Unexpected OPTLINK termination

2012-10-09 Thread Faux Amis
I get an unexpected OPTLINK termination when I run the lovely thing below, any advice (dmd 2.060)? rdmd --chatty --force --build-only ..\lib\libcairo-2.lib -I..\include ..\lib\libcairod.lib ..\lib\dmd_win32_x32.lib -version=Unicode -version=WIN32_WINNT_ONLY -version=WindowsNTonly -version=Wi

Re: bigger then size_t

2012-10-09 Thread maarten van damme
Ok, that solves it. Thank you.

Re: not expected pointers for struct members from foreach

2012-10-09 Thread bearophile
deed: // Again, why are the three last adresses the same? The D language and its compiler is acting correctly here, so the output you see is correct. All those structs are allocated on the stack. The first three Test are allocated on the stack. In the loop it allocates the first str

Re: How can I know that all child thread are gone out?

2012-10-09 Thread Druzhinin Alexandr
On 09.10.2012 22:44, Druzhinin Alexandr wrote: Hello I spawn several threads and now I need to know if they has finished their job. Before I do it by means of messages from child threads to the main one to inform about finishing. But I'm sure this isn't good enough, because a child thread may fai

How can I know that all child thread are gone out?

2012-10-09 Thread Druzhinin Alexandr
Hello I spawn several threads and now I need to know if they has finished their job. Before I do it by means of messages from child threads to the main one to inform about finishing. But I'm sure this isn't good enough, because a child thread may fail before sending the exit message to the mai

Re: bigger then size_t

2012-10-09 Thread Adam D. Ruppe
On Tuesday, 9 October 2012 at 15:56:15 UTC, maarten van damme wrote: Wouldn't a user then be able to launch that program followed by the contents of a big file of say 5 gig. The operating system won't allow that. There's a limit on argument sizes enforced before the program actually runs.

not expected pointers for struct members from foreach

2012-10-09 Thread deed
import std.stdio; struct Test { static Test[] objects; static Test*[] psObject; static int[] ints; static int*[] psInt; int a; int b; int* pa; this(int a) { this.a = a; this.pa = &this.a; this.b = 2 * a;

Re: Any sample for DFL library?

2012-10-09 Thread thedeemon
On Sunday, 7 October 2012 at 19:23:36 UTC, Lubos Pintes wrote: Does someone have any samples for DFL? Here's a recent project of mine which uses DFL: https://bitbucket.org/infognition/bsort/

Re: bigger then size_t

2012-10-09 Thread Dmitry Olshansky
On 09-Oct-12 18:46, maarten van damme wrote: What happens when args[1].length is bigger then size_t? Can I detect this? Then size_t.max? It can't as it has type size_t. Equal or even close? Nope. As it there would not be enough of even _virtual_ memory to fit array of size_t.max and something

Re: Remove element from DList

2012-10-09 Thread Steven Schveighoffer
On Sun, 07 Oct 2012 05:15:05 -0400, Jonathan M Davis wrote: On Sunday, October 07, 2012 10:09:06 Russel Winder wrote: Removal from a singly-linked list can be O(1) as well, it depends whether you are deleting using an iterator in progress. IIRC that dcollections' singly-linked list is like

Re: Struct polymorphism?

2012-10-09 Thread Era Scarecrow
On Tuesday, 9 October 2012 at 06:53:54 UTC, Jacob Carlborg wrote: As far as I understand it, opDispatch needs a receiver, I.e. this.foo() or obj.foo(). I asked the same question a while ago and got that answer, it's by design. I've also tried adding a opDispatch in the same struct and the er