首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >tcl/Itcl错误:错误# args:应该是"itcl::class name { definition }“

tcl/Itcl错误:错误# args:应该是"itcl::class name { definition }“
EN

Stack Overflow用户
提问于 2018-07-31 12:19:05
回答 1查看 149关注 0票数 0

我目前正在学习Itcl语言(基于tcl语言),我编写了以下脚本。

脚本正在实现一个驱动程序,该驱动程序应该获取4个参数,并将它们存储在类实例的私有变量中。

代码语言:javascript
复制
#!/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

当我试图运行它时,我会得到以下错误:

代码语言:javascript
复制
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)

有人能帮我,告诉我我做错了什么,我得到了这个错误吗?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2018-07-31 12:25:15

内联注释必须以分号开头:

代码语言:javascript
复制
} ;#* _DRIVER_ * #
  ^

现在看来,您正在执行itcl::class driver { ... } #* _DRIVER_ * ##* _DRIVER_ * #是4个额外的参数(#*_DRIVER_*#)。

阅读更多关于Tcl评论维基的信息。

票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/51613246

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档