Skip to content

Instantly share code, notes, and snippets.

View zacharycarter's full-sized avatar
👋

Tail Wag Games zacharycarter

👋
View GitHub Profile
import macros
proc getProcDef(fromProc: NimNode): NimNode =
let procDef = copyNimTree(fromProc)
# Strip proc of its "body", not sure if there is a better way to do this
var indexOfBody = 0
for item in fromProc:
if item.kind() == nnkStmtList: break
indexOfBody += 1
import macros
proc getProcDef(fromProc: NimNode): NimNode =
let procDef = copyNimTree(fromProc)
# Strip proc of its "body", not sure if there is a better way to do this
var indexOfBody = 0
for item in fromProc:
if item.kind() == nnkStmtList: break
indexOfBody += 1
import macros
proc getProcDef(fromProc: NimNode): NimNode =
let procDef = copyNimTree(fromProc)
# Strip proc of its "body", not sure if there is a better way to do this
var indexOfBody = 0
for item in fromProc:
if item.kind() == nnkStmtList: break
indexOfBody += 1
type
Vector3G*[T] = object
x*, y*, z*: T
let vec1 = Vector3G[float64](x: 0.5, y: 0.0, z: 0.5)
let vec2 = Vector3G[float64](x: 0.5, y: 0.0, z: -0.5)
echo("testing... it!")
proc mike(data: string | seq, data_size: int) =
var buffer: array[2, int]
when data is seq:
buffer[0] = data[0]
else:
buffer[0] = ord(data[0])
mike("abc", 3)
mike(@[97,98,99], 3)
import macros
macro connect(a: untyped): untyped =
let data = a.toStrLit.strVal & "_widget"
let ident = !data
result = quote do:
const `ident` = "hello"
connect(hi)