# Make ArgIterator.init\(\) a compile error in WASI · gitcafe/zig

[View on GitCafe](https://git.cafe/gitcafe/zig/commit/6f48842ddb2d8ca8fec639dc11a47753058ae325)

Repository: [gitcafe/zig](https://git.cafe/gitcafe/zig)

Visibility: public

Requested revision: 6f48842ddb2d8ca8fec639dc11a47753058ae325

Requested commit: 6f48842ddb2d8ca8fec639dc11a47753058ae325

Commit: 6f48842ddb2d8ca8fec639dc11a47753058ae325

Tree: eb029f7190abb21b1e048e84750ddb0a68008935

Author: Jakub Konka

Committer: Jakub Konka

## Message

```
Make ArgIterator.init() a compile error in WASI

Given that the previous design would require the use of a default
allocator to have `ArgIterator.init()` work in WASI, and since in
Zig we're trying to avoid default allocators, I've changed the design
slightly in that now `init()` is a compile error in WASI, and instead
in its message it points to `initWithAllocator(*mem.Allocator)`.
The latter by virtue of requiring an allocator as an argument can
safely be used in WASI as well as on other OSes (where the allocator
argument is simply unused). When using `initWithAllocator` it is then
natural to remember to call `deinit()` after being done with the
iterator. Also, to make use of this, I've also added `argsWithAllocator`
function which is equivalent to `args` minus the requirement of supplying
an allocator and being fallible.

Finally, I've also modified the WASI only test `process.ArgWasiIterator`
to test all OSes.

```

## Parents

- [f1a4e1a70f4ecefbae7813d7170f465234c03273](https://git.cafe/gitcafe/zig/commit/f1a4e1a70f4ecefbae7813d7170f465234c03273?format=markdown)

[Source at this commit](https://git.cafe/gitcafe/zig/tree/6f48842ddb2d8ca8fec639dc11a47753058ae325?format=markdown)
