I think it's OK.  The slice is never indexed with the negative i; the next
statement is a continue.  It is then incremented by the loop (making it
zero).  As you pointed out, the size of the slice will be zero too, so the
loop will exit.

Anyway, it didn't panic for me, and I did play with the case of just the
last sound completing.

We need to design a way to test this stuff.
On Jul 13, 2013 8:43 AM, "Steve McCoy" <notifications@github.com> wrote:

> In audiocallback.go:
>
> > +import "C"
> > +
> > +import (
> > +	"unsafe"
> > +)
> > +
> > +//export audioCallback
> > +func audioCallback(_ unsafe.Pointer, dst *C.Uint8, sz C.int) {
> > +	C.SDL_memset(unsafe.Pointer(dst), C.int(openedSpec.silence), C.size_t(sz))
> > +
> > +	for i := 0; i < len(playing); i++ {
> > +		if playing[i].done() {
> > +			playing[i] = playing[len(playing)-1]
> > +			playing[len(playing)-1] = nil
> > +			playing = playing[:len(playing)-1]
> > +			i--
>
> Am I just confused, or will this result in a panic? E.g. len(playing) = 1,
> i = 0, and playing[i].done() is true. Then, len(playing) = 0 and i = -1,
> playing[i] causes an OOB panic.
>
> —
> Reply to this email directly or view it on GitHub<https://github.com/velour/ui/pull/3/files#r5179282>
> .
>