title: Constructor reference classes
body: <p>I like to change the the folowing src in that way, that the initialize function looks like certain contructors. I would like to change the folowing example</p>
  
  <pre><code>    Part.initialize&lt;-function(...){
    args&lt;-list(...)
    if(all(class(args[[1]])==c("XMLInternalElementNode", "XMLInternalNode", "XMLAbstractNode"))){
      attr&lt;-xmlAttrs(node)
      .self$var1 &lt;- if(is.na(attr["var1"])) vector() else attr["var1"]
      .self$var2 &lt;- if(is.na(attr["var2"])) character() else as.character(attr["var2"])
    }else{
      .self$var1 &lt;- if(is.null(args[["var1"]])) vector() else args[["var1"]]
      .self$var2 &lt;- if(is.null(args[["var2"]])) character() else as.character(args[["var2"]])
    }
    .self
  }
  
  Part&lt;-setRefClass(Class = "Part"
                   ,fields = c(var1 = "ANY", var2 = "character")
                   ,methods = list(initialize=Part.initialize))
  
  txt = "&lt;doc&gt; &lt;part var2=\"abc\"/&gt; &lt;/doc&gt;"
  
  tree &lt;- xmlTreeParse(txt, useInternalNodes = TRUE)
  node&lt;-xpathSApply(tree, "//part")[[1]]
  part &lt;- Part$new(node)
  </code></pre>
  
  <p>to something like:</p>
  
  <pre><code> Part.initialize&lt;-function(XMLNode){
          do something
     }
     Part.initialize&lt;-function(var1=c(),var2=character()){
          do something
     }
  </code></pre>
  
  <p>Besides how to handle default value for type ANY? Till now I use vector().   </p>