当前位置:网站首页>C Expert Programming Chapter 1 C: Through the Fog of Time and Space 1.4 K&R C
C Expert Programming Chapter 1 C: Through the Fog of Time and Space 1.4 K&R C
2022-08-01 21:09:00 【weixin_Guest time】
/*When: 1978
*Who: Steve Johnson
*Event: Writing pcc, a portable C compiler
*Influence: Formed the basis of a generation of C compilers.
*/
/*The evolution of the C language is shown in Figure 1-2.
*1973-3 (early C)--->1976-9 (K&R C)--->1983-9 (ANSI C)(1)
*--->1967 (Simula 67)(2)
*1983 (Ada) (3)
*(1)(2)(3) together form 1985-9 (C++)
*/
/* Software Creed
*An unusual bug
The C language inherited a feature from Algol-68, the compound assignment operator, which allows a recurring operation to be written only once instead of twice, and gives the code generator a hint,That is, operand addressing can be so compact. The original way of writing the compound assignment operator is to write the assignment operator first, and then write the operator. There is a trick in the lexical analyzer of the B language that makes the implementation of =op more efficient than the op= form currently used.Simpler but confusing in this form, it's easy to add
b=-3; //subtract 3 from b
and
b= -3; //assign -3 to b
Confused.
Therefore, this feature has been modified to the form currently in use.As part of the modification, the code formatter program indent
was also modified to determine the obsolete form of the compound assignment operator, and to swap the two to convert it to the corresponding standard
form.This is a very bad decision.
No formatter should modify anything other than whitespace in the program.Unpleasantly, this approach introduces a bug where just about anything (as long as it's not a variable) swaps places with the assignment operator if it appears after the assignment operator.
*/
/* This bug may cause syntax errors, such as
*epsilon=.0001;
*will be replaced with
*epsilon.=0001;
*thisIf the statement fails to pass the compiler, you will immediately find the error
*value=!open; //value is set to the logical inverse of open
*will be silently exchanged to
*value!=open; //Compare unequal value with open
*This statement will compile without changing the value of value
*/
#include
int main() {
int b = 5;
b =- 3; /*从b中减去3*/
printf("b = %d\n",b);
b= -3; /*Assign -3 to b*/
printf("b = %d\n", b);
double epsilon=.0001;
printf("epsilon = %f\n", epsilon);
//can't pass the compiliation
//epsilon.=0001;
printf("epsilon = %f\n", epsilon);
int value = 3, open = 4;
bool result = value =! open; /*value is set to the logical inverse of open*/
printf("!open = %d\n", !open);
printf("result = %d\n", result);
result = value != open; /*value compares unequally with open*/
printf("result = %d\n", result);
return 0;
}
/* output:

*/ /*It seems that the previous problem does not exist now*/
边栏推荐
- 使用百度EasyDL实现厂区工人抽烟行为识别
- Jmeter实战 | 同用户重复并发多次抢红包
- Suggestions and answer 8.1 C traps and defect chapter 8
- C专家编程 第1章 C:穿越时空的迷雾 1.4 K&R C
- Pytorch框架学校记录11——搭建小实战完整细节
- PyTorch笔记 - Attention Is All You Need (2)
- Realize the superposition display analysis of DWG drawing with CAD in Cesium
- 和我一起写一个音乐播放器,听一首最伟大的作品
- P7215 [JOISC2020] 首都 题解
- JSD - 2204 - Knife4j framework - processing - Day07 response results
猜你喜欢
随机推荐
Review Set/Map basics with these two hooks
磷酸化甘露糖苷修饰白蛋白纳米粒/卵白蛋白-葡聚糖纳米凝胶的
那些关于DOM的常见Hook封装(二)
图的邻接矩阵存储
C专家编程 第1章 C:穿越时空的迷雾 1.3 标准I/O库和C预处理器
Jmeter实战 | 同用户重复并发多次抢红包
Classification interface, Taobao classification details API
C陷阱与缺陷 第7章 可移植性缺陷 7.9 大小写转换
测试的意义并不是能找到全部的缺陷
响应式织梦模板美容整形类网站
LeetCode·每日一题·1374.生成每种字符都是奇数个的字符串·模拟
R语言 数据的关系探索
SkiaSharp 之 WPF 自绘 五环弹动球(案例版)
Pytorch学习记录(八):生成对抗网络GAN
1374. 生成每种字符都是奇数个的字符串 : 简单构造模拟题
C陷阱与缺陷 第7章 可移植性缺陷 7.8 随机数的大小
记录第一次给开源项目提 PR
【接口测试】JMeter调用JS文件实现RSA加密
扣减库存方案
正则表达式









