In freebasic, for code 
    
    
    #macro DeclareEx(_name_)
    declare function _name_##ExNew(byval x as long, byval y as long, byval w as 
long, byval h as long, byval title as const zstring ptr=0) as _name_##Ex ptr
    declare sub      _name_##ExDelete         (byref ex as _name_##Ex ptr)
    #endmacro
    
    
    Run

if we call DeclareEx(Fl_Button) then we get the 2 procedure 
    
    
    declare function Fl_ButtonExNew(byval x as long, byval y as long, byval w 
as long, byval h as long, byval title as const zstring ptr=0) as Fl_Button ptr
    declare sub      Fl_ButtonExDelete         (byref ex as Fl_ButtonEx ptr)
    
    
    Run

how can we do that in nim? I have tried template and macro.
    
    
    template Kitten*(name: string)  =
      var name_1 = "Mike"
    
    
    Kitten("q")
    echo q_1
    
    
    Run

says 
    
    
    a.nim(6, 6) Error: undeclared identifier: 'q_1'
    
    
    Run

at same time 
    
    
    macro Kitten*(name: string) : untyped  =
      var name_1 = "Mike"
    
    
    Kitten("q")
    echo q_1
    
    
    Run

says 
    
    
    a.nim(2, 7) Hint: 'name_1' is declared but not used [XDeclaredButNotUsed]
    a.nim(6, 6) Error: undeclared identifier: 'q_1'
    
    
    
    Run

thnaks

Reply via email to