No description
Find a file
2022-06-25 15:00:10 +08:00
src added many files 2022-05-31 17:12:48 +08:00
tests added many files 2022-05-31 17:12:48 +08:00
autoderef.nimble changed a word 2022-05-31 17:27:11 +08:00
LICENSE added many files 2022-05-31 17:12:48 +08:00
README.md made a comment in the example to make it more clear 2022-06-25 15:00:10 +08:00

Auto-deref

This implements a syntax sugar for the Nim programming language. With this module imported, ptr and ref variables will be dereferenced automatically. What it does is very similar to the effect of {.experimental: "implicitDeref".}.

Example

import autoderef

type Foo = object
  a: int

proc get(self: var Foo): int =
  inc(self.a)
  return self.a

var f: ref Foo = new Foo
echo f.get() #instead of (f[]).get()

Note

  • Please ensure that the variable to be auto-dereferenced does not point to nil.