语法唐

本文介绍了“语法糖”的概念及其由来,解释了它如何使编程语言更易于人类使用,而不改变语言的基本功能。

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

语法糖,直译自“syntactic sugar”,原指“语法中的糖分”。 
Beginning Regular Expression的译者李松峰先生有专文讨论: 

含糖语法,是由Peter J. Landin创造的一个术语,指的是为一门计算机语言的语法中添加的附加物或附加成分,它不会影响语言的功能,但却能使人类使用起该语言来”更甜美”一些。含糖语法为编程人员(对计算机规范语言来说,是设计人员)提供了一种编写程序(编写规范)的替代方式,这种方式更具有实用性、更有助于形成较好的程序设计风格,或者使代码读起来更自然。但是,它不会影响形式上的可表达性,也不会让语言拥有某种新功能。 

Syntactic sugar is a term coined by Peter J. Landin for additions to the syntax of a computer language that do not affect its functionality but make it “sweeter” for humans to use. Syntactic sugar gives the programmer (designer, in the case of specification computer languages) an alternative way of coding (specifying) that is often more practical, more conducive to a better programming style, or more natural to read. However, it does not typically affect the expressiveness of the formalism or permit the language to do something new. 

看来程序员还这会给自己解闷,呵呵
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值