SimonNa has quit [Remote host closed the connection]
SimonNa has joined #zig
emptee_ has joined #zig
emptee has quit [Ping timeout: 272 seconds]
craigo has quit [Ping timeout: 240 seconds]
<marler8997>
is there a way to trick Zig into letting me pass null to a non-optional ptr?
<g-w1>
allowzero
<marler8997>
without modifying the type
<marler8997>
the parameter type
<ifreund>
nope, safety checks would catch that afaik
<ifreund>
why would you want to do such a thing?
a_chou has quit [Remote host closed the connection]
<marler8997>
because win32metadata hasn't properly marked all it's optional pointers as optional
<ifreund>
:/
<marler8997>
I could make ALL pointers optional by default for the time being
<marler8997>
but then I won't see where the mistakes are
leah2 has quit [Ping timeout: 272 seconds]
<caolanm>
I'm calling a function that returns []const u8, but I'd like a null-terminated version of the slice for some C API calls - what's the nicest way to turn that into a [:0]const u8?
<ifreund>
caolanm: Allocator.dupeZ()
<caolanm>
ifreund: thank you
leah2 has joined #zig
falsebla1 has joined #zig
falseblah has quit [Ping timeout: 264 seconds]
shirty has joined #zig
emptee_ has quit [Quit: Konversation terminated!]
<zags>
the scoping rules are sometimes mildly annoying. I have a from() function, and also a from: u64 as a parameter in different function... now I have to invent some ugly naming :D What's the common thing to do? Get creative with naming, or doing _ suffixes or?
xackus has joined #zig
ur5us_ has joined #zig
<ifreund>
zags: yeah they can be annoying at times, though not as annoying as the bugs they prevent IMO
<ifreund>
I usually get more creative/descriptive with naming
<zags>
ifreund: yeah I'm not advocating allowing shadowing here, had my shares of such bugs :) Yeah, guess just harder work on naming.
leah2 has quit [Ping timeout: 264 seconds]
tyrion-mx has joined #zig
ur5us_ has quit [Ping timeout: 264 seconds]
xackus has quit [Ping timeout: 246 seconds]
Snetry has quit [Ping timeout: 240 seconds]
n0tekky has joined #zig
Snetry has joined #zig
Snetry has quit [Ping timeout: 240 seconds]
Snetry has joined #zig
Akuli has quit [Quit: Leaving]
Snetry has quit [Ping timeout: 256 seconds]
Snetry has joined #zig
<zags>
auto_hash <3
leah2 has joined #zig
shirty has quit [Ping timeout: 240 seconds]
<zags>
hum, why would `try self.addOne(allocator);` in `ArrayList.append` return 0xaaaaa... ?
<g-w1>
thats what undefined is in debug mode
<zags>
yeah, not sure what's undefined here
<g-w1>
probably realloc
<zags>
hm, this is the first element being added
<g-w1>
what else would the default value be?
<zags>
this is ArrayList#append segfaulting
<zags>
well, ArrayListUnmanaged
<zags>
crashes on "new_item_ptr.* = item;" because new_item_ptr is 0xaaaaa
<g-w1>
oh, misunderstood you. thats weird
<zags>
indeed
<daurnimator>
zags: it suggests you wrote e.g. `var foo: ArrayListUnmanaged(T) = undefined: try foo.addOne(allocator);`
<zags>
well fuck me, it as "mything.deinit();" instead of "defer mything.deinit();"
<daurnimator>
ah, that'll do it too :)
<zags>
haha
<zags>
I need more language hand holding :D
<daurnimator>
the 0xaaaaaa *is* the language hand holding
<daurnimator>
its telling you "you likely set this thing to undefined"
<zags>
i mean statically
<zags>
discovering these things at runtime isn't ideal
<daurnimator>
your reaction after a quick visual inspection might be to put a watchpoint on it in your debugger to see what last set it to undefined.
<zags>
esp in complex/rarely hit code paths
<daurnimator>
that's why you write tests :)
<zags>
that's of course a solution to everything, but I think you get my drift
skuzzymiglet has joined #zig
<daurnimator>
nice compile-time borrow checker when? :) does zorrow even work?