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

2012-10-10 Thread H. S. Teoh
On Wed, Oct 10, 2012 at 10:40:24AM +0200, Don Clugston wrote: > On 10/10/12 09:12, thedeemon wrote: > >On Wednesday, 10 October 2012 at 07:28:55 UTC, Jonathan M Davis wrote: > >>Making sure that the aa has been properly initialized before passing > >>it to a function (which would mean giving it at

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

2012-10-10 Thread Don Clugston
On 10/10/12 09:12, thedeemon wrote: On Wednesday, 10 October 2012 at 07:28:55 UTC, Jonathan M Davis wrote: Making sure that the aa has been properly initialized before passing it to a function (which would mean giving it at least one value) would make the ref completely unnecessary. - Jonathan

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

2012-10-10 Thread thedeemon
On Wednesday, 10 October 2012 at 07:28:55 UTC, Jonathan M Davis wrote: Making sure that the aa has been properly initialized before passing it to a function (which would mean giving it at least one value) would make the ref completely unnecessary. - Jonathan M Davis Ah, thanks a lot! This be

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

2012-10-10 Thread Jonathan M Davis
On Wednesday, October 10, 2012 08:59:54 thedeemon 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/imp

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

2012-10-10 Thread thedeemon
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? Go

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?

"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