I would be glad to hear some recommendations (2-cents sort of stuff) about the 
right approach when using a C++ library from Nim. I am not talking about the 
wrapping itself. I am more interested on what comes after.

For instance, I have the following from `c2nim`: 
    
    
    type
      gp_Pnt* {.importcpp: "gp_Pnt", header: "gp_Pnt.hxx", bycopy.} = object
    
    proc constructgp_Pnt*(Xp: Standard_Real; Yp: Standard_Real; Zp: 
Standard_Real): gp_Pnt {.
        constructor, importcpp: "gp_Pnt(@)",header: "gp_Pnt.hxx".}
    ...
    proc X*(this: gp_Pnt): Standard_Real {.noSideEffect, importcpp: "X", 
header: "gp_Pnt.hxx".}
    
    
    Run

that I can use from Nim like: 
    
    
    import gp_Pnt
    
    let pnt = constructgp_Pnt( (1.0).Standard_Real,
                               (2.0).Standard_Real,
                               (3.0).Standard_Real)
    let x = pnt.X().float
    
    echo repr x
    
    
    Run

But in order to make it easier to use, I would do the following: 
    
    
    import gp_Pnt
    
    proc Pnt(x,y,z:float):gp_Pnt =
      constructgp_Pnt( x.Standard_Real, y.Standard_Real, z.Standard_Real)
    
    proc x(pnt:gp_Pnt):float =
      pnt.X.float
    
    let pnt = Pnt( 1.0, 2.0,3.0)
    echo pnt.x
    
    
    Run

Given that C++ is OOP, should I use methods or something?

Any advise is welcomed.

Reply via email to