英文:
Is there move semantics in Go
问题
我猜测从函数返回的对象(类似于New()风格的构造函数)会被隐式地移动到外部。
在Go语言中,已经存在指针和隐式引用语义(如切片、映射、通道和闭包捕获),除了copy之外,移动语义是另一种在特定内存上操作的方式,这在C++和Rust中用于内存效率。
英文:
I guess an object returned from a function (like New() style constructors) is moved outside, which is done by compiler implicitly.
There are already pointers and implicit reference semantics (slice, map, chan, and closure capture) in Go, except copy, and move semantics is another way to operate on some specific memory, which exists in C++ and Rust for memory efficiency.
答案1
得分: 2
Go语言中没有移动语义。
英文:
> Is there move semantic in Go [?]
No.
答案2
得分: 0
根据Go官方文档,没有明确的移动操作语法。如果有的话,那将由编译器实现定义,而不是语言规范。
英文:
According to Go official document, there is no explicit syntax for move operation. If there is any, that would be defined by the compiler implementation, not language specification.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。


评论