I encountered this while trying to understand the internals of fidgetty. Please 
note that I'm a newbie when it comes to understanding macros and AST processing.

Apologies for the long post - I am trying to give full context for my question.

First the context.

A couple of types from the cssgrid package are used by fidgetty: `GridDir` and 
`Constraint`.

In gridtypes.nim:
    
    
    type
      GridDir* = enum
        dcol
        drow
    
    
    Run

and in constraints.nim (the definition of `Constraint` is what matters):
    
    
    ConstraintSizes* = enum
      UiFrac
      UiPerc
      UiFixed
    
    ConstraintSize* = object
      case kind*: ConstraintSizes
      of UiFrac:
        frac*: UiScalar
      of UiPerc:
        perc*: UiScalar
      of UiFixed:
        coord*: UiScalar
    
    Constraints* = enum
      UiNone
      UiValue
      UiAuto
      UiMin
      UiMax
      UiSum
      UiMinMax
      UiEnd
    
    Constraint* = object
      case kind*: Constraints
      of UiNone:
        discard
      of UiValue:
        value*: ConstraintSize
      of UiAuto:
        discard
      of UiMin:
        lmin, rmin*: ConstraintSize
      of UiMax:
        lmax, rmax*: ConstraintSize
      of UiSum:
        lsum, rsum*: ConstraintSize
      of UiMinMax:
        lmm, rmm*: ConstraintSize
      of UiEnd:
        discard
    
    
    Run

In fidgetty, fidget_dev/common.nim defines a `CounterAxisSizingMode` enum and a 
`Node` class:
    
    
    CounterAxisSizingMode* = enum
      csAuto
      csFixed
    # ...
    Node* = ref object
      # ...
      cxSize*: array[GridDir, Constraint]
      # ...
    
    
    Run

Note the enumeration symbol `csAuto` above.

Finally, the matter at hand.

In a number of places of fidgetty I see code like the last line in the 
following excerpt (from fidgetty/fidget_dev.nim). Note that `current` is a 
global `Node` object:
    
    
    template node(kind: NodeKind, id: static string, inner, setup: untyped): 
untyped =
      ## Base template for node, frame, rectangle...
      preNode(kind, atom(id))
      setup
      inner
      postNode()
    # ...
    template frame*(id: static string, inner: untyped): untyped =
      ## Starts a new frame.
      node(nkFrame, id, inner):
        # boxSizeOf parent
        current.cxSize = [csAuto(), csAuto()]
    
    
    Run

My question is about that last line. In the fidgetty code:

  * I could not find any definition of `csAuto` other than in the enum.
  * I could not find any definition of `csAuto()` \- no proc, template or 
whatever.
  * I could not find any definition of a `()` operator.



In the Nim Manual:

  * I could not find any mention of the use of `()` in the section dealing with 
enumerations.
  * I could not find any usage of `()` that was similar to the above in the 
section dealing with macros - at least, that I could recognize.



So it is a mystery to me what the expression `csAuto()` means.

Could someone please enlighten me?

Reply via email to