tclitcl

tcl/Itcl error: wrong # args: should be "itcl::class name { definition }"


I am currently learning Itcl language (based on tcl language) and I wrote the following script.
the script is implementing a driver that should get 4 parameters and store them inside the private variables of the instance of the class

#!/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

when I am trying to run it I get the following error :

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)

can anyone help me and tell me what I did wrong that I am getting this error?


Solution

  • Inline comments have to begin with a semi-colon:

    } ;#* _DRIVER_ * #
      ^
    

    As it is right now, it looks like you are doing itcl::class driver { ... } #* _DRIVER_ * # with #* _DRIVER_ * # being 4 extra arguments (#*, _DRIVER_, * and #).

    Read more about Tcl commenting on the wiki.