You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In this issue we'll discuss some unexpected differences that arise when you switch between procs and templates in the presence of multiple modules and private helper procs. Consider the following multi-module program:
The code will now fail with undeclared field: 'baseAddr'. To fix it, you can turn the template into a proc.
Both problems will manifest only when rangeBeginAddr is used from another module. Local usages will be compiled correctly. Since templates are otherwise allowed to mediate access to private symbols, the expected behavior here is that there won't be any differences in the behavior of procs and templates and the local vs non-local usages of a template.
The text was updated successfully, but these errors were encountered:
In this issue we'll discuss some unexpected differences that arise when you switch between procs and templates in the presence of multiple modules and private helper procs. Consider the following multi-module program:
ptr_arith.nim:
ranges.nim
usage.nim
The code above compiles and runs fine, but it will fail to compile if we make any of the following innocent changes:
Replace
r.ibegin
withr.privateProc
The error will be "undeclared field: 'privateProc'"
To fix the code, you can either turn the template into a proc or you can turn
r.privateProc
toprivateProc(r)
while still using a template.Rewrite
rangeBeginAddr
using the dot syntaxThe code will now fail with undeclared field: 'baseAddr'. To fix it, you can turn the template into a proc.
Both problems will manifest only when
rangeBeginAddr
is used from another module. Local usages will be compiled correctly. Since templates are otherwise allowed to mediate access to private symbols, the expected behavior here is that there won't be any differences in the behavior of procs and templates and the local vs non-local usages of a template.The text was updated successfully, but these errors were encountered: