我目前正在学习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)
有人能帮助我,告诉我我遇到了什么错误吗?
答案 0 :(得分:3)
内嵌评论必须以分号开头:
} ;#* _DRIVER_ * #
^
就目前而言,您好像在itcl::class driver { ... } #* _DRIVER_ * #
做#* _DRIVER_ * #
是4个额外参数(#*
,_DRIVER_
,*
和{ {1}}。
详细了解Tcl在wiki上的评论。