我目前正在学习 Itcl 语言(基于 tcl 语言),并编写了以下脚本。
该脚本正在实现一个驱动程序,该驱动程序应该获取 4 个参数并将它们存储在类实例的私有变量中
#!/bin/tclsh
package require Itcl
itcl::class driver {
# private variables
private variable bundle_id ""
private variable scope ""
private variable isSimulationModel ""
private variable isX ""
private method set_data_field {data_field_flag data_value} {
switch -- $data_field_flag {
-bundle {
set bundle_id $data_value
catch {unset bundle_id}
return
}
-scope {
set scope $data_value
catch {unset scope}
return
}
-isSimulationModel {
set isSimulationModel $data_value
catch {unset isSimulationModel}
return
}
-isX{
set isX $data_value
catch {unset isX}
return
}
}
return
}
constructor {bundle hdl_path is_simulation_model is_x} {
set_data_field -bundle $bundle
set_data_field -scope $hdl_path
set_data_field -isSimulationModel $is_simulation_model
set_data_field -isX $is_x
}
destructor {}
} #* _DRIVER_ * #
driver d 1 2 3 4
当我尝试运行它时,出现以下错误:
wrong # args: should be "itcl::class name { definition }"
while executing "itcl::class driver {
# private variables
private variable bundle_id ""
private variable scope ""
private variable isSimulationModel ""
private v..."
(file "./driver.itcl" line 5)
谁能帮助我并告诉我我做错了什么,我得到了这个错误?