7 ms·
Nim, in particular, has rather terse but elegant ways to package abstractions so that use is "obviously" locally scoped. Just as one example (more fully elabor
by cb321 6y ago
Nim, in particular, has rather terse but elegant ways to package abstractions so that use is "obviously" locally scoped.
Just as one example (more fully elaborated here [1]), there is no pointer arithmetic by default, but one can write a tiny little template to add those operators and then invoke it in a local scope like:
...surrounding code...
ptrMath:
let address = base + offset
...surrounding code...
In this way many different & arbitrary "generally unsafe but also sometimes very convenient" constructs can still be used at an author's discretion, but be used in a way to make a reader (perhaps) pay better attention in a way that is more specific than some "generically 'unsafe'" block.
This is, of course, just the tip of a meta-programming iceberg.
[1] https://forum.nim-lang.org/t/1188#7366 https://forum.nim-lang.org/t/1188#7366