[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [bep] learning lisp: if, and, cond
- To: bep@argv.org
- Subject: Re: [bep] learning lisp: if, and, cond
- From: Koichi INOUE <inoue@argv.org>
- Date: 19 Jun 2001 13:37:51 +0900
- Delivered-To: mailing list bep@argv.org
- Mailing-List: contact bep-help@argv.org; run by ezmlm
- Organization: Accessibility Research Group for the Visually Impaired(ARGV)
- User-Agent: T-gnus/6.15.4 (based on Oort Gnus v0.04) (revision 01) SEMI/1.14.3 (Ushinoya) FLIM/1.14.2 (Yagi-Nishiguchi) APEL/10.3 Emacs/21.0.103 (i686-pc-linux-gnu) MULE/5.0 (SAKAKI)
井上です。
TAKAHASHI Naoto <ntakahas@...> writes:
> 「if 内で最後に評価された式の値が nil なので if の値も nil」、つまり
> 「if 全体の値は if の中で評価された最後のS式の値と同じ」という理屈です
> か。んー、たしかにそういう考え方もできますね。
>
> 私は (if 条件 S式) という短い形の if は、「条件」が成立しなければアプ
> リオリに nil を返すものだと考えていました。結果的には同じですけど。
あ、ifのヘルプにきちんと仕様が明記されていますね。
------
if is a special form.
(if COND THEN ELSE...)
If COND yields non-nil, do THEN, else do ELSE...
Returns the value of THEN or the value of the last of the ELSE's.
THEN must be one expression, but ELSE... can be zero or more expressions.
If COND yields nil, and there are no ELSE's, the value is nil.
------
最後に評価された式という話ではなく、そういうもののようです。
> 最近では、else 部分が必要ないときは if ではなくて when を使うように
> 心がけています。
whenはCにはないタイプのspecial formなのでどうも直感的に使えませんでし
た。今後はそうします。
--
Koichi Inoue, ARGV
E-Mail: inoue@...
ICQ UIN: 74900690