ChanServ changed the topic of #zig to: zig programming language | ziglang.org | be excellent to each other | channel logs: https://irclog.whitequark.org/zig/
aiwakura has quit [Quit: The Lounge - https://thelounge.github.io]
aiwakura has joined #zig
steveno has quit [Ping timeout: 260 seconds]
davr0s has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
davr0s has joined #zig
davr0s has quit [Client Quit]
davr0s has joined #zig
davr0s has quit [Client Quit]
porky11 has quit [Quit: Leaving]
ducktype has joined #zig
<ducktype> hi
<ducktype> error: expected error union type, found '?NextError![]u8'
<ducktype> how to use try and typeinference with union and nullable oprional return?
<ducktype> var first_arg = try args.next(allocator);
ducktype has quit [Quit: Page closed]
errpr has quit [Quit: Leaving]
jjido has quit [Remote host closed the connection]
Zaab1t has joined #zig
Zaabtop has joined #zig
Zaab1t has quit [Ping timeout: 268 seconds]
Zaabtop is now known as Zaab1t
Zaab1t has quit [Ping timeout: 268 seconds]
porky11 has joined #zig
davr0s has joined #zig
Zaab1t has joined #zig
very-mediocre has joined #zig
davr0s has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
davr0s has joined #zig
Zaab1t has quit [Quit: bye bye friends]
steveno has joined #zig
Zaab1t has joined #zig
hio has joined #zig
qazo has quit [Ping timeout: 244 seconds]
steveno_ has joined #zig
steveno has quit [Ping timeout: 268 seconds]
davr0s has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
steveno_ has quit [Quit: Leaving]
davr0s has joined #zig
qazo has joined #zig
Sahnvour has joined #zig
porky11 has quit [Read error: No route to host]
Zaab1t has quit [Quit: bye bye friends]
hio has quit []
Zaab1t has joined #zig
porky11 has joined #zig
fsateler has quit [Ping timeout: 240 seconds]
fsateler has joined #zig
fsateler has quit [Read error: Connection reset by peer]
ducktype has joined #zig
<ducktype> hi
<ducktype> how to pass a null pointer to syscalls? which is the sytntax for a literal null pointer?
fsateler has joined #zig
<ducktype> found: @intToPtr([*]const u8,0)
<ducktype> a quick way to convert ArgIterator to []const []const u8 ?
<andrewrk> ducktype, sounds like you want std.os.argsAlloc() rather than the iterator API
<ducktype> ty better
dtz has quit [Remote host closed the connection]
<andrewrk> ducktype, you can use `null` for pointers when your pointer type has a ? in front of it
<andrewrk> if a function can accept a null pointer then the pointer type should be, e.g. ptr: ?[*]const u8
<andrewrk> and you can use @ptrToInt(ptr) on that type, and it will give you 0
<ducktype> so most of pub fn mount(special: [*]const u8, dir: [*]const u8, fstype: [*]const u8, flags: u32, data: usize) usize { this arguments in the signature should be optional i think
<andrewrk> that sounds correct
<andrewrk> ducktype, are you referring to this? "An existing mount may be remounted by specifying MS_REMOUNT... The source and filesystemtype arguments are ignored."
dtz has joined #zig
<andrewrk> if an argument is sometimes ignored, but otherwise should be a valid pointer, then it is still best to leave it as non-optional. and then when the argument would be ignored, pass `undefined`
<ducktype> i'm checking with strace to see that the unshare and mount commands in util-linux do
<ducktype> and aften nulls are passed along
<ducktype> there are many cases
<ducktype> i think
<andrewrk> if the only values that can be passed are valid pointers and sometimes the value is ignored, then undefined is your friend
<ducktype> i'm not sure how much the kernel ignores these args, and because i'm not getting the same result and unshare/mount commands i'm betting on this, i want to do exactly the same call they are doing
<ducktype> the same results AS unshare/mount commands
<andrewrk> in this case, I agree, these arguments should be optional
<andrewrk> I suggest to file an issue, or send a patch, and then in the meantime use a workaround of copy-pasting the function into your own project, and editing the signature
<ducktype> :)
<ducktype> var exec_argv = []const []const u8 {shell}; //exec_argvs becomes of type [1][]const u8
<ducktype> but i want exec_argv to be a "generic" [][] u8
<ducktype> it's good? how to do that? i'm confused
<andrewrk> it's an array and you want a slice, so you need to either slice it, or take the address of it
very-mediocre has quit [Ping timeout: 256 seconds]
<andrewrk> const exec_argv: []const []const u8 = [][]const u8{shell};
<andrewrk> or if it's const you can implicit cast it like this
jjido has joined #zig
<ducktype> not const
<ducktype> var exec_argv =[][]u8{shell_path}[0..];
<andrewrk> are you sure it's not const?
<ducktype> i want to change it depending on some condition
<ducktype> var exec_argv = ([][]u8{"arg1"})[0..]; if(true) { exec_argv = (try std.os.argsAlloc(allocator))[1..]; }
<ducktype> i want to initialize some default arguments, but if someone passed to my program something i will replace with my current args excluding the first
wootehfoot has joined #zig
<ducktype> line 131
<ducktype> error: expected type '[][]u8', found '[]const []u8'
<jjido> you probably need to give the type before "="
<andrewrk> ducktype, the compiler is correct - you can't do that because it could modify const data
<andrewrk> probably here: var exec_argv = ([][]u8{shell_path})[0..]; // you want []const []u8
<andrewrk> oops
<andrewrk> var exec_argv: []const []u8 = [][]u8{shell_path};
<andrewrk> then the assignment later will work
<ducktype> ty yes
<ducktype> works
<andrewrk> does it make sense?
<andrewrk> there are 3 different memory locations that each have const or not. (1) the exec_argv varibale (2) the list of arguments (3) each argument
<ducktype> var exec_argv = ([]const []u8{shell_path})[0..];
<ducktype> i don't understad why this not work
<andrewrk> []T{...} is syntax for an array literal
<andrewrk> []const T{...} is nonsense; it should be a syntax error
<ducktype> clear
<andrewrk> maybe syntax for array literal, with inferred number of items, should look different, like this: [_]T{...}
<andrewrk> so that it looks different than a slice
<ducktype> yes is confusing
<ducktype> []T{...} is syntax for an array literal so T in my case is []u8 ?
<andrewrk> yes
<ducktype> ty
<ducktype> could not be implicit T{}
<ducktype> there are already {} to indicate an array
<ducktype> literal
<ducktype> ?
jjido has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<andrewrk> ducktype, I created https://github.com/ziglang/zig/issues/1797
davr0s has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
dtz has quit [Remote host closed the connection]
davr0s has joined #zig
Zaab1t has quit [Ping timeout: 246 seconds]
dtz has joined #zig
Sahnvour has quit [Remote host closed the connection]
jjido has joined #zig
jjido has quit [Client Quit]
jjido has joined #zig
<benjikun> 
<benjikun> don't know how I sent that, ignore it
wootehfoot has quit [Read error: Connection reset by peer]
jjido has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]