type A {.inheritable.} = object
type B = object of A
type C = object of RootObj
const r = RootObj()
const a = A()
#const b = B() # Error: invalid type: 'B' for const
#const c = C() # Error: invalid type: 'C' for const
it works with https://github.com/nim-lang/Nim/pull/15528 which should've been merged long ago, IMO
when defined case2:
type A {.inheritable.} = object
a0: int
type B = object of A
b0: int
type C = object of RootObj
c0: int
const r = RootObj()
const a = A(a0: 1)
const b = B(a0: 2, b0: 3)
const c = C(c0: 4)
echo a
echo b
echo c
const z1 = (b.b0, b.a0)
let z2 = (b.b0, b.a0)
echo (z1, z2)
(a0: 1)
(b0: 3, a0: 2)
(c0: 4)
((3, 2), (3, 2))
https://github.com/nim-lang/RFCs/issues/257
2. Currently consts in particular const arrays are copied in each compilation unit that access them at runtime
I see your point.
I'm looking for way to reduce start up time, prevent introduce once while initializing and keep semantic of object accessing.