zoukankan      html  css  js  c++  java
  • 关于first-class object的解释

    关于first-class object的解释

    定义,什么是编程语言的第一等公民?

    In computer science, a programming language is said to have first-class functions if it treats functions as first-class citizens。

    解释:

    In programming language design, a first-class citizen (also type, object, entity, or value) in a given programming language is an entity which supports all the operations generally available to other entities. These operations typically include being passed as an argument, returned from a function, modified, and assigned to a variable.

    一个一等公民(即类型、对象、实体、或值等等)在一门特定的编程语言中能够支持其他大多数实体所支持的操作。

    例子Ruby。

    Ruby是在Python之前风靡世界的高级面向对象编程语言。

    Ruby是单类继承关系,一切都继承自Class类。所以说Class类是第一公民。

    Classes in Ruby are first-class objects, each is an instance of class Class.

    BasicObject继承Class类,Object类继承BasicObject。

    Object is the default root of all Ruby objects.

    例子,类Object的类是Class类。

    2.6.2 :019 > Object.class
     => Class

    Python

    在Python,函数是第一类对象。In Python, functions are first class object (first class citizen too!).

  • 相关阅读:
    电话号码组合 hash表
    合并区间
    最小路径和 动态规划
    计数排序
    插入排序
    选择排序
    归并排序
    C#中不同程序集(dll)存在相同的命名空间
    生成otp token 脚本
    MySQL 组合索引、唯一组合索引的原理
  • 原文地址:https://www.cnblogs.com/chentianwei/p/11865101.html
Copyright © 2011-2022 走看看