Open timotheecour opened 3 years ago
Why not =init(x: var T)
as proposed in #252?. It is more efficient, no extra move/copy operation required
why would it be more efficient? =default
is {.compileTime.}
and affect semantics of var
initializaiton, so that:
var a: Bar
# a is not zero-initialized, it's directly initialized to `=default(Bar)`,
# possibly from ROM
This RFC is stale because it has been open for 1095 days with no activity. Contribute a fix or comment on the issue, or it will be closed in 30 days.
https://github.com/nim-lang/RFCs/issues/252 was already accepted in the form of https://github.com/nim-lang/RFCs/issues/252#issuecomment-705113779
This leaves open another point, which is initialization for non-object types (as was suggested in https://github.com/nim-lang/RFCs/issues/252#issuecomment-718236794)
proposal
allow type bound
=default
operator to overridedefault
andvar
initialization. it must be acompileTime
proc (or at least compiler will only call it at CT).invariant:
var a: T
is always equivalent tovar a = T.default
example 1
example 2
in system.nim, add
so that: