61a_scip_python_01

本文介绍了编程语言的基础思想,包括信息表示、逻辑规范及复杂性管理的抽象设计。详细阐述了强大的编程语言所需的三种机制:原始表达式与语句、组合手段及抽象手段,并解释了表达式与语句的区别及环境的概念。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Fundamental ideas:

  1. represent information
  2. specify logic to process it
  3. design abstractions that manage the complexity of that logic

 

Three mechanisms of powerful language:

  1. primitive expression and statements: represent the simplest building blocks that the language provides
  2. means of combination: compound elements are built from simpler ones
  3. means of abstraction: compound elements can benamed and manipulated as units

 

Statements and Expressions:

  1. statements typically describe actions
  2. expressions typically describe computations

 

Expressions:

'''

value: the amount represented by  a letter or synbol  数值  数

computation: an act or the process of calculating sth 计算  计算过程

evaluation: to form an opinion of the amount, value or quality of sth

operator: a symbol or function which represents an operation in mathematics 算子

operand: the number on which an operation is to be done 运算数

'''

  • an expression describe a computation and evaluate to value
  • all expression can use function call notation
  • primitive expressions:
    • number: the expression you type consists of the numerals that represent the number in base 10
    • names 
    • string

 

Call expressions:

  • structure:    operator(operand,operand...)  max(1,2)
  • operator and operand are also expressions. name or numbers or subexpressions?
  • evaluation procedure for call expressions:
    • evaluate the operator to get function and then operand subexpression to get arguments
    • apply the fuction that is the value of the the operator subexpression to the arguments that are the values of the operand subexpressions
  • evaluate nested expressions: use expression tree
    mul(add(4,mul(4,6)),add(3,5))

 

Names:

  • use names to refer to computational objects
  • if a value has been given a name, we say that name binds to the value
  • how to bind:
    • assigment statement: (name = expression) evaluate expression and bind it to the name
    • import statement: just built-in names
    • def statement: def a fuction
  • names are often called variable names or variables because they can be bound to different values but just bind one
  • change the value of one name does not affect other name because after evaluation just value to be bound to the name
    x=2
    y=x+1
    x=3
    print(y)

     but the function

    def f(a):
        return a+1
    
    x=2
    y= f(x)
    print(y)
    x=3
    print(y)

     

   because return statement, it get re-revaluated everytime it's called

  • environment:
    • environments are real things, they're the way in which an interpreter for programming language keeps track of what names mean, so it's sort of menory that keeps track of the bindings between names and values

 

    

转载于:https://www.cnblogs.com/lxjlucoding/p/6395124.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值