Skip to content

Instantly share code, notes, and snippets.

@stisa
Last active March 22, 2017 14:52
Show Gist options
  • Save stisa/207dbaa726a4dfb49007890b93016990 to your computer and use it in GitHub Desktop.
Save stisa/207dbaa726a4dfb49007890b93016990 to your computer and use it in GitHub Desktop.
repr test
a | 0
b | 0
c | 0.0
d | '\0'
e | eA
f | 0000000000000010""
g | {}
h | {}
i | [nil, nil, nil]
j | nil
k | 0
l | [a = nil,
b = nil]
m | nil
n | nil
o | [Field0 = [a = nil,
b = nil],
Field1 = nil]
p | [Field0 = nil,
Field1 = nil]
q | nil
a | 12
b | 1
c | 1.2
d | '\0'
e | eC
f | 000000000018F0B8"hello"
g | {'A'}
h | {2}
i | [000000000018F0E0"hello", 000000000018F108"world", 000000000018F130"array"]
j | 0000000000190058[000000000018F158"hello", 000000000018F180"world", 000000000018F1A8"seq"]
k | -1
l | [a = 000000000018F1D0"inner",
b = 000000000018F1E8['o', 'b', 'j']]
m | ref 0000000000191058 --> [a = 000000000018F220"inner",
b = 000000000018F238['o', 'b', 'j']]
n | ref 0000000000439280 --> [a = 000000000018F068"inner",
b = 000000000018F080['o', 'b', 'j']]
o | [Field0 = [a = 000000000018F270"inner",
b = 000000000018F288['o', 'b', 'j']],
Field1 = 000000000018F2C0"tuple!"]
p | [Field0 = 0000000000401885,
Field1 = nil]
q | 000000000042C41C"cstringtest"
[a = 0,
b = 0,
c = 0.0,
d = '\0',
e = eA,
f = nil,
g = {},
h = {},
i = [nil, nil, nil],
j = nil,
k = 0,
l = [a = nil,
b = nil],
m = nil,
n = nil,
o = [Field0 = [a = nil,
b = nil],
Field1 = nil],
p = [Field0 = nil,
Field1 = nil],
q = nil]
[a = 12,
b = 1,
c = 1.2,
d = '\0',
e = eC,
f = 000000000018F0B8"hello",
g = {'A'},
h = {2},
i = [000000000018F0E0"hello", 000000000018F108"world", 000000000018F130"array"],
j = 0000000000190058[000000000018F158"hello", 000000000018F180"world", 000000000018F1A8"seq"],
k = -1,
l = [a = 000000000018F1D0"inner",
b = 000000000018F1E8['o', 'b', 'j']],
m = ref 0000000000191058 --> [a = 000000000018F220"inner",
b = 000000000018F238['o', 'b', 'j']],
n = ref 0000000000439280 --> [a = 000000000018F068"inner",
b = 000000000018F080['o', 'b', 'j']],
o = [Field0 = [a = 000000000018F270"inner",
b = 000000000018F288['o', 'b', 'j']],
Field1 = 000000000018F2C0"tuple!"],
p = [Field0 = 0000000000401885,
Field1 = nil],
q = 000000000042C41C"cstringtest"]
a | 0
b | 0
c | 0.0
d | '\0'
e | eA
f | nil
g | {}
h | {}
i | [nil, nil, nil]
j | nil
k | 0
l | [a = nil,
b = nil]
m | nil
n | nil
o | [Field0 = [a = nil,
b = nil],
Field1 = nil]
p | nil
q | nil
a | 12
b | 1
c | 1.2
d | '\0'
e | eC
f | "hello"
g | {'A'}
h | {2}
i | ["hello", "world", "array"]
j | @["hello", "world", "seq"]
k | -1
l | [a = "inner",
b = @['o', 'b', 'j']]
m | ref 0 --> [a = "inner",
b = @['o', 'b', 'j']]
n | ref 0 --> [a = "inner",
b = @['o', 'b', 'j']]
o | [Field0 = [a = "inner",
b = @['o', 'b', 'j']],
Field1 = "tuple!"]
p | 0
q | "cstringtest"
[a = 0,
b = 0,
c = 0.0,
d = '\0',
e = eA,
f = nil,
g = {},
h = {},
i = [nil, nil, nil],
j = nil,
k = 0,
l = [a = nil,
b = nil],
m = nil,
n = nil,
o = [Field0 = [a = nil,
b = nil],
Field1 = nil],
p = nil,
q = nil]
[a = 12,
b = 1,
c = 1.2,
d = '\0',
e = eC,
f = "hello",
g = {'A'},
h = {2},
i = ["hello", "world", "array"],
j = @["hello", "world", "seq"],
k = -1,
l = [a = "inner",
b = @['o', 'b', 'j']],
m = ref 0 --> [a = "inner",
b = @['o', 'b', 'j']],
n = ref 0 --> [a = "inner",
b = @['o', 'b', 'j']],
o = [Field0 = [a = "inner",
b = @['o', 'b', 'j']],
Field1 = "tuple!"],
p = 0,
q = "cstringtest"]
type
AnEnum = enum
eA,eB,eC
B = object
a: string
b: seq[char]
A = object
a : uint32
b: int
c: float
d: char
e: AnEnum
f: string
g: set[char]
h: set[int16]
i: array[3,string]
j: seq[string]
k: range[-12..12]
l: B
m: ref B
n: ptr B
o: tuple[ x: B, y: string]
p: proc(b:B):ref B
q: cstring
proc refB(b:B):ref B =
new result
result[] = b
var
aa : A
bb : B = B( a: "inner", b: @['o','b','j'])
cc : A = A( a:12, b:1, c:1.2, d:'\0', e:eC,
f:"hello", g:{'A'}, h: {2'i16},
i: ["hello","world","array"],
j: @["hello","world","seq"], k: -1,
l:bb, m: refB(bb), n: addr bb,
o: (bb, "tuple!"), p: refB, q: "cstringtest" )
for key,val in aa.fieldPairs:
var v = repr val
echo key," | ",v
for key,val in cc.fieldPairs:
var v = repr val
echo key," | ",v
echo repr aa
echo repr cc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment