ChanServ changed the topic of #zig to: zig programming language | https://ziglang.org | be excellent to each other | channel logs: https://irclog.whitequark.org/zig/
Vinski has quit [Ping timeout: 244 seconds]
keveman has quit [Ping timeout: 256 seconds]
<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"
<hryx> Anyone know a way around this?
ManDeJan has joined #zig
<ManDeJan> andrewrk, Nice work on on this PR!
<ManDeJan> Sahnvour, Thanks for the PR on my zig-wyhash implementation :), very appreciated
hio has joined #zig
ltriant has quit [Quit: leaving]
bketelsen has joined #zig
adrusi has left #zig [#zig]
jjido has joined #zig
<hryx> I found a workaround for my last question, but it feels hacky so I might post an issue
<hryx> Scratch that, this one answers my question: https://github.com/ziglang/zig/issues/2289
wilsonk|2 has quit [Read error: Connection reset by peer]
slugm has joined #zig
neceve has joined #zig
very-mediocre has joined #zig
jjido has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
jjido has joined #zig
scientes has joined #zig
neceve has quit [Remote host closed the connection]
neceve has joined #zig
mouldysammich has joined #zig
slugm_ has joined #zig
slugm has quit [Read error: Connection reset by peer]
jjido has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
MajorLag has joined #zig
tgschultz has quit [Ping timeout: 244 seconds]
MajorLag is now known as tgschultz
slugm_ has quit [Ping timeout: 246 seconds]
slugm has joined #zig
slugm has quit [Remote host closed the connection]
slugm has joined #zig
Ichorio has joined #zig
slugm has quit [Remote host closed the connection]
slugm has joined #zig
forgot-password has joined #zig
<forgot-password> Is it possible to set an optional as not null without also setting its data?
<very-mediocre> I think what you want is `= undefined`
<ManDeJan> Technically you could set it to undefined
<ManDeJan> But there is no way to tell if a value is undefined
<very-mediocre> indeed you're probably better off setting it as null
<forgot-password> very-mediocre: That's exactly opposite of what I'm trying to do :P
<forgot-password> ManDeJan: That's what I tried, but it still says that I'm trying to unwrap null
<very-mediocre> Could you give an example of what you're trying to do?
<very-mediocre> why don't you want the optional to be null?
<forgot-password> Sure, give me a minute to prepare an example :)
<forgot-password> Do you know a good paste website which supports zig syntax?
<very-mediocre> gist.github.com
<forgot-password> I need to be logged in for that, don't I?
<very-mediocre> yes, but it's the only one i know of with zig syntax support
<very-mediocre> actually you could misuse https://godbolt.org/ I guess
<forgot-password> Here's a link https://pastebin.com/raw/RM2HiXie
<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
eubn has joined #zig
<forgot-password> Alright, thank you :)
<very-mediocre> 👍
halosghost has joined #zig
ljmccarthy has joined #zig
<ljmccarthy> comptime eval in zig: https://www.godbolt.org/z/tVrsh-
<ljmccarthy> pretty neat I think
<ljmccarthy> zig would be a good language to embed other languages in
<ljmccarthy> myexpr could be generated by comptime parsing @embedFile'd code in a separate file
<very-mediocre> that's cool!
<ljmccarthy> I was amazed it actually worked, and compiled the evaluation of a structured expression tree to a single instruction
<ljmccarthy> even optimised 42*x*x to 84*x
<ljmccarthy> of course it's only a toy example
<very-mediocre> this seems pretty nice for DSLs
<ljmccarthy> oops I meant 42*(x+x)
<ljmccarthy> yes you could implement DSLs very easily without having to worry about backend
<ljmccarthy> easy as writing a AST interpreter
<very-mediocre> server blocks come to mind but I haven't thought it through
scientes has quit [Remote host closed the connection]
scientes has joined #zig
ManDeJan has quit [Ping timeout: 246 seconds]
forgot-password has quit [Quit: leaving]
Akuli has joined #zig
scientes has quit [Remote host closed the connection]
scientes has joined #zig
<eubn> I think I tried asking this a while back, but I'll try again: what's the canonical way to learn zig right now?
<very-mediocre> eubn: learning materials are currently limited, what I did was just go through the docs: https://ziglang.org/documentation/master/#Hello-World
<very-mediocre> the language is probably not ready for production just yet
<very-mediocre> although in my experience it's really solid
scientes has quit [Remote host closed the connection]
scientes has joined #zig
<eubn> very-mediocre: Thanks, I'll start from there. If I'm not mistaken the standard library's documentation not there?
<very-mediocre> you are correct
very-mediocre_ has joined #zig
<very-mediocre_> the stdlib is pretty readable btw, a far cry from C++
<very-mediocre_> i usually copy the zig/std folder into my project so I can easily browse / search-in-files
very-mediocre has quit [Ping timeout: 256 seconds]
very-mediocre_ is now known as very-mediocre
<scientes> why?
<scientes> just checkout zig in git, and use git grep
shritesh has joined #zig
<ljmccarthy> I'm learning mainly by reading the standard library and reference doc
ljmccarthy has quit [Quit: Page closed]
wilsonk|2 has joined #zig
Akuli has quit [Ping timeout: 240 seconds]
<bketelsen> got some decent interop js<->wasm going by mimicing rust's wasm-bindgen
fengb_ has joined #zig
<shritesh> bketelsen: That's great!!!
<bketelsen> sritesh: the next step is to figure out how to generate the things that need to be generated.
<shritesh> I've been trying to figure out how to interact with strings.
<bketelsen> I have the recipe!
<bketelsen> I'll update the repo shortly with a string example
<shritesh> Perfect
eubn has quit [Ping timeout: 256 seconds]
<fengb_> Would anyone be interested if I try porting the Zig compiler to the browser?
<fengb_> Something like https://www.typescriptlang.org/play/, but do zig => wat
* shritesh raises hands and says "me me me"
<fengb_> Alright cool, I'll probably have more details later tonight. Just wanted to make sure I'm not just scratching a personal itch
keveman has joined #zig
keveman has quit [Ping timeout: 256 seconds]
<very-mediocre> scientes: because i use vscode and it has excellent file content search
dembones has quit [Quit: leaving]
<scientes> I guess i'm old-school not using an IDE
<scientes> i would like "go to define" feature however
<scientes> I just find that IDEs are too slow
<very-mediocre> I agree, I only use lightweight(ish) code editors
<very-mediocre> vscode is awesome despite being electron-based
_whitelogger has quit [Ping timeout: 240 seconds]
return0e has quit [Read error: Connection reset by peer]