Hi guys,
I'm wrapping some of Google's Apps Script (targets the js backend):
type
SpreadsheetAppObj* = object
Spreadsheet* = object
Sheet* = object
var SpreadsheetApp* {.importcpp, nodecl.}: SpreadsheetAppObj
{.push importcpp.}
proc getActiveSpreadsheet*(ssapp: SpreadsheetAppObj): Spreadsheet
proc getActiveSheet*(ssapp: SpreadsheetAppObj): Sheet
{.pop.}
for var x = SpreadsheetApp.getActiveSpreadsheet, which returns a Spreadsheet object, why does Nim produce an array with the object inside: var x_452984848 = [SpreadsheetApp.getActiveSpreadsheet()]; ?
Why not just return the object itself?
The usage of arrays in this context is to emulate pointers and the codegen sometimes needs pointers so that Nim's semantics can work. Consider:
proc mutate(x: var int) = x = 4
var global: int
mutate(global)
The code generator sometimes does this where it would not be required but it's hard to do better and to ensure correctness at the same time.