FAQ
Looks like the race detector does not work with 32bit Windows which I'm
currently running. I think I've run out of possibilities with malusing data
types so I will turn to concurrency now although I was very careful to
avoid race conditions and have checked the code so many times now.
On Friday, November 1, 2013 8:37:29 AM UTC, bobco...@gmail.com wrote:

Hi

I think I must be misunderstanding something.

I have 2 buffers to double buffer data.
They are created with zero length and capacity to hold the data that will
be written to them.
buf_1 = make ([]float64, 0, n)
buf_2 = make ([]float64, 0, n)

I then select which buffer to use by assigning it to a local variable.
var curr_buffer []float64 = buf_1
var next_buffer []float64 = buf_2

Now as I understand it I have a copy of the reference but the same
underlying data.

If I now append to say buf_1.
curr_buffer = append(curr_buffer, data...)

After the append the length of curr_buffer is len(data) but the length of
buf_1 is zero.
As the capacity was sufficient to hold the data I didn't expect a
reassignment.

I also tried this without the local variables by splitting the function
and passing the references - same result.

I then tried pointers to references which worked, but that was expected.

Can someone enlighten me on the mechanism going on here please.

Thanks
bob
--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Search Discussions

Discussion Posts

Previous

Follow ups

Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 10 of 12 | next ›
Discussion Overview
groupgolang-nuts @
categoriesgo
postedNov 1, '13 at 12:29p
activeNov 3, '13 at 5:22p
posts12
users7
websitegolang.org

People

Translate

site design / logo © 2022 Grokbase