LoginSignup
2
0

More than 5 years have passed since last update.

Common Lispで名前に丸括弧を含む関数を定義する

Posted at

はじめに

Common Lispなら丸括弧も関数名として利用できるんじゃないかと思って調べました。\あるいは|でエスケープすれば可能です。

試す

roswellをインストールして試してみた。

parenthesis.lisp
$ros run
* (defun \(1\) () 1)

|(1)|
* (\(1\))

1
* (defun |(2)| () 2)

|(2)|
* (|(2)|)

2
* (\(2\))

2
* (|(1)|)

1
* (defun \(a () 'a)

|(A|
* (defun |(b| () 'b)

|(b|
* (\(a)

A
* (|(b|)

B

(defun \(a () 'a)では大文字が印字されて、(defun |(b| () 'b)では小文字が印字されるのか、分からないです。

リーダーマクロ

エスケープに利用した、\|はリーダーマクロとして定義してあるようでした。解説はHyperSpecに任せます。

おわりに

エスケープせずに(を使う方法はあるんだろうか。

2
0
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
0