博客
关于我
不好!我中了美人计!
阅读量:582 次
发布时间:2019-03-11

本文共 444 字,大约阅读时间需要 1 分钟。

后记:这篇是上一篇《》的续集,继JavaScript的原型法之后,又介绍了一下Go语言面向对象的实现。Go语言在面向对象这一块儿比较有趣,结构体和方法分开,没有继承,只有组合,有一种看起来很像DuckTyping的多态,我想Ken Thompson和Rob Pike等人在设计Go语言的时候,肯定经过了深思熟虑,精心考量。 

在Go语言的官网上,对Go语言是不是面向对象的语言做了答复:是也不是。虽然Go语言有类型和方法,并且允许面向对象风格的编程,但是并没有类型的继承,Go语言中“接口”的概念提供了一种不同的方式,我们认为在它更容易使用,更加通用。

Go语言通过在一个类型中嵌入另外一个类型来支持子类化(虽然并不完全等同)的概念。除此之外,Go语言中的方法比C++和Java更加通用,程序员可以在任何数据类型上定义方法,甚至是内置的类型:如Integer, 方法并不局限在structs(classes)上。 同样,没有类型继承使得Go语言中的对象用起来比C++或者Java更加轻量级。

转载地址:http://kevvz.baihongyu.com/

你可能感兴趣的文章
nmon_x86_64_centos7工具如何使用
查看>>
NN&DL4.1 Deep L-layer neural network简介
查看>>
NN&DL4.3 Getting your matrix dimensions right
查看>>
NN&DL4.7 Parameters vs Hyperparameters
查看>>
NN&DL4.8 What does this have to do with the brain?
查看>>
nnU-Net 终极指南
查看>>
No 'Access-Control-Allow-Origin' header is present on the requested resource.
查看>>
No 'Access-Control-Allow-Origin' header is present on the requested resource.
查看>>
NO 157 去掉禅道访问地址中的zentao
查看>>
no available service ‘default‘ found, please make sure registry config corre seata
查看>>
No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK?
查看>>
no connection could be made because the target machine actively refused it.问题解决
查看>>
No Datastore Session bound to thread, and configuration does not allow creation of non-transactional
查看>>
No fallbackFactory instance of type class com.ruoyi---SpringCloud Alibaba_若依微服务框架改造---工作笔记005
查看>>
No Feign Client for loadBalancing defined. Did you forget to include spring-cloud-starter-loadbalanc
查看>>