这个方案错误告诉我什么?

时间:2013-01-08 22:30:00

标签: scheme guile meep

存在一种名为meep的电磁模拟器,它以诡计解释器的形式提供前端。模拟器由一堆方案宏组成。

我试图找出以下错误的含义。代码来自教程。当我在一个过程中包装教程时,我得到一个运行时错误,我不确定解释器(guile)告诉我什么。

不工作代码

(define diffthick
  (lambda (n) ; n doesn nothing
    (
     (set! geometry-lattice (make lattice (size 16 8 no-size)))
     (set! geometry (list
                      (make block (center 0 0) (size infinity 1 infinity)
                            (material (make dielectric (epsilon 12))))))
     (set! sources (list
                     (make source
                           (src (make continuous-src (frequency 0.15)))
                           (component Ez)
                           (center -7 0))))
     (set! pml-layers (list (make pml (thickness 1.0))))
     (set! resolution 10)
     (run-until 200
                (at-beginning output-epsilon)
                (at-end output-efield-z))
     )
    )
  )
(diffthick 3)

工作代码(不含程序)

(set! geometry-lattice (make lattice (size 16 8 no-size)))
(set! geometry (list
                (make block (center 0 0) (size infinity 1 infinity)
                      (material (make dielectric (epsilon 12))))))
(set! sources (list
               (make source
                 (src (make continuous-src (frequency 0.15)))
                 (component Ez)
                 (center -7 0))))

(set! pml-layers (list (make pml (thickness 1.0))))
(set! resolution 10)
(run-until 200
           (at-beginning output-epsilon)
           (at-end output-efield-z))

错误

creating output file "./eps-000000.00.h5"...
creating output file "./ez-000200.00.h5"...
run 0 finished at t = 200.0 (4000 timesteps)

Backtrace:
In standard input:
  21: 0* [diffthick 3]
   3: 1  [#<unspecified> #<unspecified> #<unspecified> ...]

standard input:3:5: In expression ((set! geometry-lattice #) (set! geometry #) (set! sources #) ...):
standard input:3:5: Wrong type to apply: #<unspecified>
ABORT: (misc-error)

工作

-----------
creating output file "./eps-000000.00.h5"...
creating output file "./ez-000200.00.h5"...
run 0 finished at t = 200.0 (4000 timesteps)

在一天结束时,我觉得有些事情正在被评估两次。但我不确定那是什么。

1 个答案:

答案 0 :(得分:5)

错误表示代码正在尝试应用(set! geometry-lattice #)的结果,就像它是一个函数一样,但set!会导致#<unspecified>。发生这种情况是因为set!系列被包裹在parens中。

你可能正在寻找

(begin
  (set! geometry-lattice ...)
  ...
  (run-until ...))

或者只是摆脱那对额外的parens,因为lambda body隐含地包裹在begin中。