LoginSignup
0
0

More than 1 year has passed since last update.

【CommonLisp】letで定義できる変数は外部の変数と同名でも破壊しない

Posted at

前書き

上級Lisperが得るものは何一つない記事です

ソース

defparameterで定義する変数はアスタリスクで囲むのが一般的です
以下の例は単純に動作が見たい & お遊びコードのためアスタリスクで囲っていません

(defparameter tikuwa 1000)

(defun hoge (takosu)
  (let ((takosu (+ takosu 2))
        (tikuwa (+ tikuwa 20)))
    (format t "let takosu: ~a~%" takosu)
    (format t "let tikuwa: ~a~%" tikuwa))
  (format t "takosu: ~a~%" takosu)
  (format t "tikuwa: ~a~%" tikuwa))

(defun main ()
  (hoge 100))

出力結果

let takosu: 102
let tikuwa: 1020
takosu: 100
tikuwa: 1000

感想

察してくれるCommonLispは素敵

0
0
2

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
0
0