[英]Get current stack size in FORTH
How can I get the number of elements currently held in the stack in Forth? 如何获得Forth中当前保存在堆栈中的元素数量?
I ask this because I want to make a function that prints out all the elements of the stack, something like: 我问这个是因为我想创建一个打印出堆栈所有元素的函数,例如:
: pop_all 0 do . loop ;
1 5 10 4 5
5 pop_all
But now I need to manually specify the stack size when I call it. 但是现在我需要在调用它时手动指定堆栈大小。
大多数FORTH系统都有一个.S
命令,可以完全按照您的要求编写。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.