ChanServ changed the topic of #zig to: zig programming language | ziglang.org | be excellent to each other | channel logs: https://irclog.whitequark.org/zig/
Tobba has quit [Ping timeout: 256 seconds]
curtisf has joined #zig
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]
davr0s has joined #zig
davr0s has quit [Client Quit]
curtisf has quit [Quit: Page closed]
<andrewrk> zig tcp server vs node.js tcp server strace: https://gist.github.com/andrewrk/d48c8c9ca0fb67bf6d7c0bed744d82ce
<achambe> andrewrk: beautiful
<achambe> is that the demo you mentioned in your talk about gracefully handling oom ?
<andrewrk> this is a demo of async/await
<achambe> yeah, in a talk you gave, you mentioned you were also doing an http server demo that serves while out of memory
<andrewrk> ah yes, that's what this is
<achambe> awesome
<andrewrk> I mean it's not done yet, but this is an important milestone
<andrewrk> one of the things I want to try is multiplexing coroutines onto kernel threads
<andrewrk> this is single threaded so far
<achambe> syscalls being out of control is one of the big problems with Go too. zig seems like a good solution to that.
<achambe> andrewrk: dunno if you have seen this library: http://libdill.org/
<achambe> perhaps some of the idioms there would match well with the async stuff you are working on
<achambe> tree structuring of coroutines etc.
<andrewrk> I'll have a look, thanks
<achambe> crazy project idea: alternative nix interpreter in zig. (notice your nixos store paths)
<andrewrk> is the current one in c++?
<achambe> yeah
<achambe> using the bhoem gc
<achambe> the language seems simple with few builtins, but perhaps its not a practical project in reality
<achambe> so many other things with higher value
<GitHub82> [zig] andrewrk pushed 7 new commits to master: https://git.io/vx7G0
<GitHub82> zig/master 8f4ad95 Andrew Kelley: update what std tests to run
<GitHub82> zig/master b85ef65 Andrew Kelley: running into the llvm corosplit error again
<GitHub82> zig/master 0d22a00 Andrew Kelley: *WIP* async/await TCP server
davr0s has joined #zig
davr0s has quit [Ping timeout: 276 seconds]
man213 has quit [Quit: Page closed]
_PiGreco_ has joined #zig
<_PiGreco_> hi everyone
<_PiGreco_> no zig in macports? :)
<achambe> sad that capnproto is C++ and not C, zig can't use it :(
_PiGreco_ has left #zig [#zig]
Dodo has joined #zig
<Dodo> Can you make you're own Iterator that works with the 'for' loop?
<Dodo> *your
Hejsil has joined #zig
SimonNa has quit [Quit: Leaving]
<Hejsil> Dodo, you can define a function that returns ?T (where T is your item type) and then do this: https://github.com/Hejsil/fun-with-zig/blob/0717e996f1971c1a31dda222f306d3be2bf93c81/src/iterators.zig#L352
<Hejsil> But, you can't define an iterator that works with for, no
<Dodo> oh well, that looks pretty clean as well :)
<Dodo> talking about 'iterators', what about .map() and .filter()?
<Hejsil> There is nothing like those in the standard library
<Hejsil> Though, you could implement some iterator library with them in it
<Hejsil> Though, if you want lazy, map and filter, then you'll need to be creative
<Dodo> mh, I see that as a challenge ^^
<Hejsil> Have fun :)
<Dodo> but I only downloaded the compiler a few days ago hahaha
<Hejsil> If you have any questions, feel free to ask. The docs do not cover everything
<Dodo> will do
<Dodo> think I'll need it ^^
Dodo has quit [Quit: Page closed]
Tobba has joined #zig
Dodo has joined #zig
<Dodo> if I have a function that returns this: "return union(enum) { Ready: T, Pending: void, };"
<Dodo> how would I switch against it to get T out of it?
<Dodo> or do I make a function for it that returns ?&T to get a reference back, but only if the variant was 'Ready'?
<Dodo> but I dont know the type of the return type, only that its a union
<Dodo> so what should the function take as paramater?
<Dodo> OH
<Dodo> you can just type the function-name, then .<variant>
<Dodo> heh!:D
<Dodo> how do I 'create' a void-type?
<Dodo> or well, a new 'void'
arBmind has joined #zig
<Hejsil> Creating void: void{}
<Hejsil> Switching on union(enum): https://ziglang.org/documentation/master/#union
<Hejsil> Your union looks a lot like a nullable though https://ziglang.org/documentation/master/#Nullables
<Hejsil> :)
<Dodo> I know it looks like a nullable
<Dodo> but somethimes you want to create your own nullable
<Hejsil> Alright
<Dodo> or type that is nullable-like
<Hejsil> Ye, I can imagine having names would give clarity
<Dodo> is ther something like an online playground to show what I've done?
<Hejsil> Nope
<Dodo> Ill use pastebin
<Dodo> could've also returned the union directly I notice now
Braedon has joined #zig
<Braedon> Most iterators also have a '.next()' though so you can always do `var it_next = it.next(); while(it_next) |next| { ... // use next }`
<Braedon> Which is quite like a for loop, though of course yeh we don't have maps/reduce and stuff :)
<Hejsil> Dodo, Was there anything specific you needed comment on in your code? If you're just playing around unions, this seems correct
<andrewrk> Hejsil, you've been busy while I was asleep
<Hejsil> I've overtaken your commit count! >:)
<andrewrk> argh!
<Hejsil> Well, after I got While parsing, nearly all the code was already there for 'for' and 'if'
<Hejsil> comptime, and defer where simple
<Hejsil> So it wasn't really that much work
<Dodo> just wondering if it was the right way indeed Hejsil
<andrewrk> Test 37/39 zig fmt: ...
<andrewrk> wow, so close
<Hejsil> self hosted parser hype!
<Hejsil> This was way more work than expected. All I wanted was to create some small program that generated an index of `std` :(
<andrewrk> that's how it happens. you think "I understand the basics of how this works" and then you get sucked into the details
<Hejsil> Indeed
<Hejsil> I think I'll probably go back to doing some randomizer work when the parser is done. That indexing thing can wait
<andrewrk> I'll get started on analysis in the self hosted compiler!
<Hejsil> Index, as in some html page for easy browsing
<Hejsil> Nice!
<andrewrk> it's all coming together - I was wanting to finish this coroutine proof of concept that I just got done last night because I want to make it use a thread pool and coroutines to parallelize work
<Hejsil> How would zig doc play work? Would it run while the analyzer is running, so it knows which files are imported, or would zig doc just naively iterate over the ast, assuming that all files imported are actually used?
<andrewrk> docs would be a build artifact from the other build modes
<Hejsil> s/zig doc play/zig doc/g
<andrewrk> this is another situation where multiboot is relevant
<andrewrk> *multibuild
<Hejsil> Aaaah, so it'll be the same as the zig json that was worked on
<Hejsil> I remember that now!
<andrewrk> the first pass will be like that
<andrewrk> ideally, a build will simultaneously process code for the multiple comptime branch configurations that can be made - release vs debug, linux vs windows, etc. docs would indicate when something is only available in one context or indicate that something could be a different type
<Hejsil> Make sense
<Hejsil> Anyways, I'm off for a bit
Hejsil has quit [Quit: Page closed]
<andrewrk> take care
Braedon has quit [Ping timeout: 260 seconds]
MajorLag2 has joined #zig
MajorLag has quit [Ping timeout: 276 seconds]
MajorLag2 is now known as MajorLag
<MajorLag> andrewrk: with tagged unions: setting it to "undefined" seems to cause a runtime saftey error if you define it later, "access of inactive union field".
<MajorLag> how would I reset the tag?
<andrewrk> overwrite the entire union
<andrewrk> foo = TypeName { .Blah = whateven }
<andrewrk> that's a great point though, if you set a union to undefined, it should set the safety tag to a special value to note that none of the tags are active
<andrewrk> because I bet right now it would let you write/read with the 0th field
<MajorLag> right, ok, that makes sense.
<MajorLag> actually no, it threw the same error... but maybe the first listed field isn't necessarily the 0th.
<andrewrk> oh right, the most aligned one is
<andrewrk> e.g. the biggest size
<andrewrk> anyway I think this is working as designed, with a potential impromevent to runtime safety to be made
<MajorLag> doesn't seem to work either. probably it is whatever happens to be in the tag value location in memory at the time? but yeah, academic. being able to set to undefined and handle it later would be a minor but welcom convenience.
MajorLag2 has joined #zig
MajorLag has quit [Ping timeout: 276 seconds]
MajorLag2 is now known as MajorLag
isd has joined #zig
MajorLag2 has joined #zig
MajorLag has quit [Ping timeout: 276 seconds]
crimson_penguin has quit [Ping timeout: 265 seconds]
Dodo has quit [Quit: Page closed]
crimson_penguin has joined #zig
crimson_penguin has quit [Changing host]
crimson_penguin has joined #zig
Dodo has joined #zig
noonien has quit [Quit: Connection closed for inactivity]
MajorLag2 is now known as MajorLag
isd has quit [Ping timeout: 265 seconds]
Dodo has quit [Quit: Page closed]
isd has joined #zig
davr0s has joined #zig
isd has quit [Ping timeout: 276 seconds]
isd has joined #zig
Ichorio has joined #zig
arBmind has quit [Quit: Leaving.]
isd has quit [Read error: Connection reset by peer]
isd has joined #zig
stephaneyfx has joined #zig
brannock has joined #zig
brannock has quit [Quit: Page closed]
davr0s has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]