Apparently `{.pure.}` _can_ be attached to an object type, but the manual 
explains its purpose very poorly. Essentially it is only used for inheritance, 
specifically when you create a type and attach the `{.inheritable.}` pragma to 
it. This makes an object which can be inherited from, similar to `RootObj` from 
the standard library, but now you have two such roots. To provide runtime type 
information in Nim each inheritable objects adds a hidden field holding the 
type of the object. This can be queried with `of` so you can do `if myVar of 
InheritedObjectType`. If you don't need runtime type information, and you'd 
rather not have Nim generate this field for you, then you should use the 
`{.pure.}` pragma. Otherwise it does nothing (not even throw an error). This 
seems to be most commonly used for [interoperability with C++ 
code](https://nim-lang.org/docs/manual.html#exception-handling-imported-exceptions)
 to mark a type which can be inherited from.

Reply via email to