Thanks, the ref intent seems to work. I had somehow got the wrong impression 
that ref intent weren't yet well implemented and hence didn't even try it... I 
managed to write a simple ring buffer class, however I should still write some 
tests.

In the ring buffer class I have const field describing size of the buffer, 
passed my user in the constructor. I'd like to write optimized functions for 
the case when size==2 . Are there any elegant ways to achieve this?

Also, if anyone is interested in seeing the code of the ring buffer class, just 
let me know, I can post it under some open source license.

23.02.2015, 15:57, "Michael Ferguson" <[email protected]>:
> On 2/22/15, 1:19 PM, "John MacFrenz" <[email protected]> wrote:
>> I was thinking of the latter approach. Also a generic ring buffer
>> implementation would be useful in cases like this. I almost started
>> writing one, storing in array N elements of type T. However, I couldn't
>> figure a way to write a method getCurrent(), which would return current
>> element in buffer, so that it would always return a reference. Or any
>> other clever way so user could always modify the current element in ring
>> buffer.
>
> Does the ref return intent work for you?
> As in this example program (which I've verified compiles and runs):
>
> var A = [1,2,3,4,5];
>
> proc element(i:int) ref
> {
>   return A[i];
> }
>
> writeln(A);
> element(1) = 10;
> writeln(A);
>
> Or is there some reason that the ref return intent does not
> solve the problem?
>
> Best,
>
> -michael

------------------------------------------------------------------------------
Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
from Actuate! Instantly Supercharge Your Business Reports and Dashboards
with Interactivity, Sharing, Native Excel Exports, App Integration & more
Get technology previously reserved for billion-dollar corporations, FREE
http://pubads.g.doubleclick.net/gampad/clk?id=190641631&iu=/4140/ostg.clktrk
_______________________________________________
Chapel-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/chapel-users

Reply via email to