`new_xxx` is more flexible, yet having default parameters for object and 
shortcut notation for object initialisation, shortening `Obj(some_name: 
some_name)` as `Obj(some_name)` would still be useful.

Example:
    
    
    type
      CrawlerRef*[J] = ref object
        id:            string
        version:       int
        jobs:          seq[J]
        data_dir:      string
        
        job_states:    JobStates
        saved_at_sec:  int64
        last_saved:    Option[JobStates]
        job_i:         int               # = -1
    
    
    Run

How the initialisation looks now
    
    
    proc new_crawler*[J: Job](
      id:                    string,
      version:               int,
      jobs:                  seq[J],
      data_dir:              string,
    ): CrawlerRef[J] =
      CrawlerRef[J](
        id:                    id,
        version:               version,
        jobs:                  jobs,
        data_dir:              data_dir,
        
        job_states:            job_states,
        job_i:                 -1
      )
    
    
    Run

How it could look with defaults and shortcuts
    
    
    proc new_crawler*[J: Job](
      id:                    string,
      version:               int,
      jobs:                  seq[J],
      data_dir:              string,
    ): CrawlerRef[J] =
      CrawlerRef[J](id, version, jobs, data_dir, job_states)
    
    
    Run

Reply via email to