Mat Harden, its not pedantically, its precisely. I think being precise with 
terms and words is very important especialy in IT, where new technologies 
are emerging everyday. IT world has already too much confusion about 
wording, definitions and so on. Giving precise answer with proper context 
speeds up learning process, especially for newcomers. I think it's worth to 
keep that in mind, in the end by answering someone's question we want to be 
helpful not make someone confused. 

czwartek, 26 czerwca 2014 o 20:16:35 UTC+2 Matt Harden napisał(a):

> More pedantically, it does copy the slice, but the slice is internally 
> just a pointer, length and capacity. Just as copying a pointer doesn't copy 
> the data pointed to, copying a slice doesn't copy the data pointed to 
> either.
>
>
> On Tue, Jun 24, 2014 at 4:00 AM, roger peppe <rogp...@gmail.com> wrote:
>
>> You're creating the slice each time around the loop,
>> so you will be ok, assuming you don't modify
>> the contents of the slice after sending it.
>>
>> But in general, passing a slice over
>> a channel does not copy the entire slice - it passes a
>> reference to the items in the slice.
>>
>>
>> On 24 June 2014 09:03, Abhijit Kadam <abhij...@gmail.com> wrote:
>> > From one routine if I create slice and pass it to other routine through
>> > channel then before the other routine reads the slice data (array slice 
>> is
>> > pointed to), if I set the slice to another location then will the other
>> > routine still read the old slice data always consistently? I assume it
>> > should as I am copying the slice, so it is copy of the reference which
>> > points to the array data.
>> >
>> > http://play.golang.org/p/l90Tk7wQOl
>> >
>> > datach := make(chan []string)
>> >
>> > routine 1:
>> > for {
>> > // create a slice
>> > str := make([]string,0)
>> >
>> > //fill it with values
>> > str = append(str, "value " + strconv.Itoa(i))
>> >
>> > //Send the slice to channel so that other routine reads
>> > datach <- str
>> > //***continue the loop and the same slice reference will point to new 
>> array
>> > location
>> > }
>> >
>> > Another routine 2:
>> > for {
>> > strc := <-datach
>> > }
>> >
>> > once the str is copied over channel then is it safe to point to another
>> > location without the previous data not getting garbage collected or
>> > overwritten?
>> >
>> > --
>> > 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...@googlegroups.com.
>> > For more options, visit https://groups.google.com/d/optout.
>>
>> --
>> 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...@googlegroups.com.
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/e1f52bc9-2e7b-493e-9984-b5afeffd6bfan%40googlegroups.com.

Reply via email to