" DO"宏变量定义没有绑定

时间:2017-09-14 19:35:30

标签: common-lisp

我使用DO宏编写了一个函数(使用Peter Seibel的书作为参考)但出于某种原因,当我编译我的函数时:

WARNING: in TEST in lines 1..10 : N is neither declared nor bound,
         it will be treated as if it were declared SPECIAL. 
WARNING: in TEST in lines 1..10 : M is neither declared nor bound,
         it will be treated as if it were declared SPECIAL. 
WARNING: in TEST in lines 1..10 : N is neither declared nor bound,
         it will be treated as if it were declared SPECIAL. 
WARNING: in TEST in lines 1..10 : M is neither declared nor bound,
         it will be treated as if it were declared SPECIAL.

我收到以下警告信息:

test

当我尝试执行n时,它说import React from 'react'; import ReactDOM from 'react-dom'; import App from './component/App'; import { AppContainer } from 'react-hot-loader'; import { overrideComponentTypeChecker } from 'react-toolbox'; import background from './component/Styles.css'; import { Router, hashHistory as history } from 'react-router'; const rootEl = document.getElementById('app'); document.body.style.backgroundColor = '#49c0f0'; const render = () => { ReactDOM.render( <AppContainer> <App /> </AppContainer>, rootEl ); }; if (process.env.NODE_ENV !== 'production') { overrideComponentTypeChecker((classType, reactElement) => ( reactElement && ( reactElement.type === classType || reactElement.type.name === classType.displayName ) )); if (module.hot) { module.hot.accept('./component/App', render); } } render(); 没有价值。

我的印象是绑定的顺序并不重要,但我尝试重新排列它仍然收到相同的结果。

我在这里缺少什么?

我正在使用CLISP 2.49

1 个答案:

答案 0 :(得分:3)

---Creating records with cte as(Select Cast('01-01-2000' as Date) as startDate,1 as countD union all Select Cast('02-01-2000' as Date) as startDate,3 as countD union all Select Cast('10-01-2000' as Date) as startDate,1 as countD) Select * into #Temp from cte; --Creating temp table to hold results create table #Result( startDate Date, ) --Using cursor to insert records DECLARE @startDate Date, @count int; DECLARE db_cursor CURSOR FOR SELECT startDate , countD FROM #Temp OPEN db_cursor FETCH NEXT FROM db_cursor INTO @startDate , @count WHILE @@FETCH_STATUS = 0 BEGIN WHILE @count> 0 BEGIN set @count = @count-1; set @startDate = DATEADD(DAY, @count, cast (@startDate as date)); INSERT INTO #Result Select @startDate; END FETCH NEXT FROM db_cursor INTO @startDate , @count END CLOSE db_cursor DEALLOCATE db_cursor Select * from #Result 在创建任何变量绑定之前评估变量的所有init-forms。这意味着绑定对同一DO中的init-forms不可见。

代码应该使用DO代替,但输出不是很有趣,因为DO*AB永远不会改变。

C

(defun test () (do* ((n 2 (1+ n)) (m 1 (1+ m)) (a (1+ n)) (b (1+ m)) (c (+ n m))) ((= n 10) (* a b c)) (print (* a b c)))) (test) ; 18 ; 18 ; 18 ; 18 ; 18 ; 18 ; 18 ;=> 18 DO*相同,但它逐个评估并建立绑定,因此您可以在init-forms中引用先前的变量。使用步骤形式更新变量时也是如此。