带变量的Gforth条件表达式-仅部分正确 [英] Gforth conditional expression with variables - only partly correct
本文介绍了带变量的Gforth条件表达式-仅部分正确的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
简单表达式:
variable x ok
4 x ! ok
3 x < . -1 ok
3 x > . 0 ok
但这似乎是正常且正确的:
This seems normal and correct, however:
variable x ok
3 x ! ok
x 4 < . 0 ok
x 4 > . -1 ok
第二个代码块是错误的.什么是错误的评估?这是什么问题?
The second block of code is wrong. What is evaluating wrongly? What is the problem here?
推荐答案
variable x
创建新变量,但是x
返回地址,而不是值.
variable x
makes a new variable, but x
returns the address, not the value.
您需要这样的东西:
variable x
3 x ! ok
x @ 4 < .
x @ 4 > .
这篇关于带变量的Gforth条件表达式-仅部分正确的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文