This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
echo("Hey") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import macros | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
echo("testing... it!") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
echo "hi" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import macros | |
macro connect(a: untyped): untyped = | |
let data = a.toStrLit.strVal & "_widget" | |
let ident = !data | |
result = quote do: | |
const `ident` = "hello" | |
connect(hi) |