您不能从Scheme中的函数返回任何内容吗? [英] Can you return nothing from a function in Scheme?

查看:85
本文介绍了您不能从Scheme中的函数返回任何内容吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在编写一个方案解释器,对于if语句,例如:

I'm writing a scheme interpreter, and in the case of an if statement such as:

(if (< 1 0) 'true)

我尝试过的所有解释器都将返回一个新提示.但是,当我对此进行编码时,对于是否存在替代表达式,我会有一个if.如果什么都没打印出来,我该怎么办?

Any interpreter I've tried just returns a new prompt. But when I coded this, I had an if for whether there was an alternative expression. What can I return in the if such that nothing gets printed?

(if (has-alternative if-expr)
  (eval (alternative if-expr))
  #f) ;; what do I return here?

推荐答案

根据

如果< test>产生#f而没有< alternate> 指定后,则结果 表达式未指定.

If <test> yields #f and no <alternate> is specified, then the result of the expression is unspecified.

因此,疯狂,退回任何您想要的东西!尽管#f或'()是我个人期望的结果.

So go wild, return anything you want! Although #f or '() are what I, personally, would expect.

这篇关于您不能从Scheme中的函数返回任何内容吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆