# I haven't learned how to write my own macros yet in nim, but I found a need to # use one for a learning project involving nim -> wasm. I copied this macro from # to enable exporting procs to # wasm: macro exportWasm(def: untyped): untyped = result = def result[^3] = nnkPragma.newTree( ident("exportc"), nnkExprColonExpr.newTree( ident("codegenDecl"), newStrLitNode("attribute((export_name(\"$2\"))) $1 $2$3") # Add something to exported name to ensure unique definition ) ) # However, I have many overloaded procs such as: proc getAdjacentHorLocValues(locValue: uint8): seq[uint8] {.exportWasm} = let horLocs = getAllHorizontalLocValues(locValue) result = getAdjacentIndexes(locValue, horLocs) proc getAdjacentHorLocValues(locA: string): seq[uint8] {.exportWasm} = let locValue: uint8 = locationMapping.getOrDefault(locA) result = getAdjacentHorLocValues(locValue) # And as a result, when trying to compile it fails due to reusing the same # declared name: c:148:93: error: conflicting types for 'getAdjacentHorLocValues' 148 | attribute((export_name("getAdjacentHorLocValues"))) tySequence6H5Oh5UUvVCLiakt9aTwtUQ getAdjacentHorLocValues(NimStringV2 locA_p0); | ^ c:145:93: note: previous declaration is here 145 | attribute((export_name("getAdjacentHorLocValues"))) tySequence6H5Oh5UUvVCLiakt9aTwtUQ getAdjacentHorLocValues(NU8 locValue_p0); # How difficult would it be to modify the macro to ensure that each overloaded # function is unique? Can the macro use information about the function to create # unique definitions (param types)?