Skip to content

Instantly share code, notes, and snippets.

@sunho
Created January 13, 2018 21:31
Show Gist options
  • Select an option

  • Save sunho/a349a69eb6e790e380687731ce88250f to your computer and use it in GitHub Desktop.

Select an option

Save sunho/a349a69eb6e790e380687731ce88250f to your computer and use it in GitHub Desktop.
func (vm *VM) newThread() *thread {
s := &stack{RWMutex: new(sync.RWMutex)}
cfs := &callFrameStack{callFrames: []callFrame{}}
t := &thread{stack: s, callFrameStack: cfs, sp: 0, cfp: 0}
s.thread = t
cfs.thread = t
t.vm = vm
return t
}
@sunho
Copy link
Author

sunho commented Jan 13, 2018

t := &thread{stack: s, callFrameStack: cfs, sp: 0, cfp: 0}
s.thread = t
cfs.thread = t
mutually referring objects like this is not a bad design

@sunho
Copy link
Author

sunho commented Jan 13, 2018

mySlice1 := make([]int, 0)
mySlice2 := []int{}
are equivalent

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment