<tgschultz>
keveman: see issue #1291. Unfortunately this is not possible at this time.
keveman has joined #zig
<keveman>
tgschultz: thanks.. I guess I was asking for getNextGloballyIncrementingInteger
<tgschultz>
I'm not sure where we are on that. I think andrew is still mulling over if its a good idea or not, but it has come up a few times.
<keveman>
I didn't quite follow the point about opaquetype on that issue, though
<tgschultz>
oh, so the problem is that the evaluation of a comptime function with a set of parameters will be cached, and so the next time it is called with those same parameters the cached result will be used. so const `x = comptimeAlloc([40]u8)` and `const y = comtpimeAlloc([40]u8)` would point to the same memory. So we need a way to keep the function result from being cached, hence a unique parameter. What Hejsil is saying is that
<tgschultz>
@OpaqueType() provides a new unique type every time it is called, so `comptimeAlloc([40]u8, @OpaqueType())` would be effective in ensuring that the cached result isn't reused.
<tgschultz>
That probably doesn't have any relevance to your usecase if you actually need a counter though.
<keveman>
Got it, thanks for the explanation
keveman has quit [Ping timeout: 256 seconds]
<tgschultz>
well andrewrk, you can officially drop that mic
<scientes>
how far is comptime going to go? what about being able to call the LLVM bindings at comptime?
hobo has joined #zig
scientes has quit [Ping timeout: 255 seconds]
hio has quit [Quit: Connection closed for inactivity]
redj has joined #zig
hobo has quit [Quit: Page closed]
m3t4synt4ct1c has joined #zig
<m3t4synt4ct1c>
what would the idiomatically zig way of @embedFile'ing a CSV that has two columns, a string and a u16 and converting that into a const HashMap at compiletime == is that possible?
_whitelogger has joined #zig
bheads____ has quit [Ping timeout: 246 seconds]
m3t4synt4ct1c has quit [Ping timeout: 256 seconds]
<hryx>
I'm having trouble with an error: "runtime cast to union 'blah' which has non-void fields"
<forgot-password>
I missed a .* where I set the instance to undefined, but that's just a copy-paste mistake
<very-mediocre>
to guarantee that the result of S.getValue() is not null, you could throw an error
<very-mediocre>
in case it is null
<very-mediocre>
before returning, that is
<very-mediocre>
i.e. return an error, to use zig terms
<very-mediocre>
there's no such concept as setting something to "not null," it has to be something
<forgot-password>
I meant to basically mark the optional as not null, with the rest of the data being uninitialized
<forgot-password>
I guess I could do a memset, no?
<very-mediocre>
well you're returning instance.? which evaluates to instance orelse unreachable
<very-mediocre>
if you unwrap instance before returning it, then in the calling scope whatever is returned is known as not being null
slugm has quit [Ping timeout: 268 seconds]
slugm has joined #zig
<very-mediocre>
either way it works out to handling the case of the item being null in the body of the S.getValue() function
scientes has quit [Remote host closed the connection]
scientes has joined #zig
scientes has quit [Remote host closed the connection]
scientes has joined #zig
<forgot-password>
Okay, so there's no way to tell Zig "Hey, this thing actually contains data and is not null". I assumed there's just a flag attached to the data which says whether said data is null or not.
<very-mediocre>
zig knows it's not null after you've unwrapped it
<forgot-password>
Which I thought I confirmed by `@sizeOf(?u0) == @sizeOf(u0) + 1`
<forgot-password>
But how does it determine that?
<very-mediocre>
compile-time control flow analysis