wangjicheng886的个人空间 https://blog.eetop.cn/1774723 [收藏] [复制] [分享] [RSS]

空间首页 动态 记录 日志 相册 主题 分享 留言板 个人资料

日志

skill language user guide 46--48

已有 238 次阅读| 2023-6-19 22:45 |系统分类:芯片设计

Logical Operators 

SKILL considers nil as FALSE and any other value as TRUE. The and (&&) and or (||)  operators only evaluate their second argument if they need to determine the return result.

SKILL将nil视为假(FALSE),而将其他任何值视为真(TRUE)。而逻辑与(&&)和逻辑或(||)运算符只在需要确定返回结果时才评估它们的第二个参数。

Sample Logical Operators

Operator    Arguments     Function       Example      Return Value

&&                general             and                  3 && 5           5

                                                                      5 && 3           3

                                                                      t && nil          nil

                                                                      nil&&t            nil

||                  general              or                     3||5                3

                                                                      5||3                5

                                                                      t||nil             t

                                                                      nil||t                t     


The && and || operators return the value last computed. Consequently, both && and ||  operators can be used to avoid cumbersome if or when expressions. 

"&&" 和 "||" 运算符返回最后计算的值。因此,"&&" 和 "||" 运算符可以用来避免冗长的 if 或 when 表达式

consequently  [ˈkɒnsɪkwəntli]  adv  因此; 所以;

avoid  [əˈvɔɪd]  vt  避免; 防止; 回避; 避开; 躲避; 

If possible,you want to avoid alcohol.

cumbersome [ˈkʌmbəsəm]  adj  大而笨重的; 累赘的; 难以携带的; 缓慢复杂的; 冗长的; 复杂的;


Using &&

When SKILL creates a variable, it gives the variable a value of unbound to indicate that the  variable has not been 

initialized yet.     当 SKILL 创建一个变量时,它将变量的值设置为 "unbound",表示该变量尚未初始化。

Use the boundp function to determine whether a variable  is bound. The boundp function

可以使用 boundp 函数来判断变量是否已绑定。boundp 函数具有以下行为:

Returns t if the variable is bound to a value.  

Returns nil if it is not bound to a value.

Suppose you want to return the value of a variable trMessages. If trMessages is  unbound, retrieving the value causes an error. Instead, use the expression 

假设您想要返回变量 trMessages 的值。如果 trMessages 是未绑定状态,获取其值会导致错误。取而代之,可以使用下面的表达式:

boundp( 'trMessages ) && trMessages


Using ||  

Suppose you have a default name, such as noName. Suppose you have a variable, such as  userName. To use the default name if userName is nil, use the following expression  

假设您有一个默认名称,比如 noName。假设您有一个变量 userName。如果要在 userName 为 nil 的情况下使用默认名称,请使用以下表达式:

userName || "noName"







点赞

评论 (0 个评论)

facelist

您需要登录后才可以评论 登录 | 注册

  • 关注TA
  • 加好友
  • 联系TA
  • 0

    周排名
  • 0

    月排名
  • 0

    总排名
  • 0

    关注
  • 28

    粉丝
  • 7

    好友
  • 19

    获赞
  • 8

    评论
  • 128

    访问数
关闭

站长推荐 上一条 /1 下一条

小黑屋| 关于我们| 联系我们| 在线咨询| 隐私声明| EETOP 创芯网
( 京ICP备:10050787号 京公网安备:11010502037710 )

GMT+8, 2024-5-18 10:19 , Processed in 0.018387 second(s), 8 queries , Gzip On, Redis On.

eetop公众号 创芯大讲堂 创芯人才网
返回顶部