@OderWat Thank you for your suggestion. Still, I feel that this is 
inconvenient. The reason are that:

  * one loses the default constructor
  * fields have to be initialized one by one (that is, one cannot write 
everything as a single expression)
  * complexity is shifted to the client, that is, I would prefer to be able to 
declare this when writing the type, not when using it



Fox context: I am trying to write a wrapper around 
[React](https://facebook.github.io/react/) and there are holder objects for 
HTML attributes and CSS styles. An example of usage is 
[here](https://github.com/andreaferretti/react.nim/blob/master/example/app.nim#L66)
    
    
    proc renderComponent(s: TopLevel): auto =
      section(
        section(Attrs(className: "row", key: "search"),
          section(Attrs(className: "col-md-4"),
            React.createElement(search, ValueLink(
              value: s.state.query,
              handler: proc(q: string) = s.setState(Filter(query: q))
            ))
          )
        ),
        section(Attrs(className: "row", key: "list"),
          React.createElement(items, ItemFilter(
            countries: s.props.countries,
            query: s.state.query
          ))
        )
      )
    

For the usability of the DSL, it is critical that one should be able to write 
the attributes inline.

I can think of a few ways to overcome this: one is to write myself a procedure 
that has a `nil` default for all fields and then initializes the object as 
OderWat suggest, but only for values that are not nil.

But this becomes rapidly very taxing, and I would rather find some more 
convenient alternative

Reply via email to