ChanServ changed the topic of #zig to: zig programming language | ziglang.org | be excellent to each other | channel logs: https://irclog.whitequark.org/zig/
steveno has joined #zig
emekoi has quit [Quit: Page closed]
steveno has quit [Quit: Leaving]
<c15ade4> its cool how you can watch the livestreams a bit later
<c15ade4> semi live stream
davr0s has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
<c15ade4> andrewrk: just a warning, i think you made a slight mistake at the beginning
<c15ade4> Im not sure you intended the camera to be active while the countdown was on
rlr has quit [Quit: quitting]
return0e has quit [Read error: Connection reset by peer]
return0e has joined #zig
wilsonk has joined #zig
<daurnimator> Where are std lib docs?
<daurnimator> andrewrk: watching your stream now
<daurnimator> andrewrk: clone2 is just fork with extra flags.
<daurnimator> andrewrk: newer platforms don't have a fork syscall. you're meant to use the clone2 syscall instead.
<andrewrk> daurnimator, that's really good to know, thanks
<andrewrk> std lib docs don't exist yet https://github.com/ziglang/zig/issues/21
<daurnimator> andrewrk: there are many syscalls that have gained an extra flags argument as time goes on. newer arches don't get the old syscall without the flags argument.
<daurnimator> andrewrk: note the actual kernel implementation of fork: https://elixir.bootlin.com/linux/latest/source/kernel/fork.c#L2230
<daurnimator> andrewrk: also I wanted to get a bit more about zig's coroutine feature and perhaps share some of what I hope for
<daurnimator> andrewrk: IMO a good coroutine implementation needs to avoid the "red function/blue function" issue (http://journal.stuffwithstuff.com/2015/02/01/what-color-is-your-function/)
<daurnimator> which is essentially that a non-async function needs to be able to call an async function
<daurnimator> --> what is zig's current status/thinking on that?
<andrewrk> daurnimator, how would that work with needing to suspend? would functions secretly be generated as coroutines?
<andrewrk> most coroutines need access to an event loop object
<daurnimator> andrewrk: so there's a few approaches:
<andrewrk> I have a lot of bones to pick with this red/blue function article
<daurnimator> 1. if you try and yield() and you're called from an non-async function. it throws an error instead.
<andrewrk> also - this conversation is interesting to me but I have some household duties at the moment. I hope you stop by during the day soon when I can give you more attention
<daurnimator> this can be helpful if you can write a function like so: async fn foo(x) { if (x > 42) { suspend wait(); } else { return compute() } }
<daurnimator> i.e. a function that only *sometimes* needs to do async work
<daurnimator> that can be helped along by a function `is_suspendable`
<daurnimator> 2. construct an event loop *inside* of the current function call so that the async function is resumed multiple times from the sync() call site.
<andrewrk> I have a lot of thoughts on this
<daurnimator> 2. can be combined with 1.: fn foo() { looptype loop; if (@isSuspendable()) { loop = mainloop } else { loop = newLoop(); } loop.addJob(fooJob); if (!@isSuspendable()) { loop.runUntilEmpty(); } }
<daurnimator> (sorry for pseudo-syntax. I don't know zig much yet so I'm sort of combining all sorts of things together)
<andrewrk> check the logs tomorrow and I'll have a thoughtful response for you
<daurnimator> andrewrk: k :)
<daurnimator> andrewrk: our time zones don't match up very well
<diltsman> Given this code: const vector_table align(4) section(".vector") = VectorTable.{.initial_sp_value = 0x20100000,.reset = _start};
<diltsman> I get this in the binary: 82b00846 01910090
<diltsman> Any ideas?
<diltsman> This is the struct definition: const VectorTable = packed struct.{initial_sp_value: U32,reset: fn () void};
<diltsman> Why wouldn't I see some bytes that look vaguely like 0x20100000?
_whitelogger has joined #zig
tolitius has quit [Client Quit]
tolitius has joined #zig
rlr has joined #zig
rlr has left #zig ["WeeChat 2.3"]
<andrewrk> diltsman, that output looks surprising to me
<hryx> andrewrk, just watched (and enjoyed) the stream video. I didn't know you're doing weekly streams!
return0e has quit [Remote host closed the connection]
return0e has joined #zig
<andrewrk> hryx, yep, I have the older ones saved here: https://www.youtube.com/playlist?list=PLviMr_WImMhHA_yCD2-VfUSB_j4qSQ8pf
<andrewrk> some are better than others
<andrewrk> I recommend: * Allocators & Memory Management * Compile Time Code Execution * "Hello World" x86 Kernel
<hryx> rad. I'm looking forward to those
tolitius has quit [Quit: zzz...]
tolitius has joined #zig
tolitius has quit [Client Quit]
tolitius has joined #zig
tolitius has quit [Client Quit]
tolitius has joined #zig
tolitius has quit [Client Quit]
tolitius has joined #zig
tolitius has quit [Client Quit]
tolitius has joined #zig
tolitius has quit [Client Quit]
tolitius has joined #zig
tolitius has quit [Client Quit]
davr0s has joined #zig
davr0s has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
jjido has joined #zig
presiden has joined #zig
jjido has quit [Ping timeout: 245 seconds]
jjido has joined #zig
jjido has quit [Ping timeout: 246 seconds]
jjido has joined #zig
porky11 has joined #zig
very-mediocre has joined #zig
m4ge123 has quit [Read error: Connection reset by peer]
m4ge123 has joined #zig
davr0s has joined #zig
davr0s has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
return0e has quit [Remote host closed the connection]
return0e has joined #zig
davr0s has joined #zig
DutchGh0st has joined #zig
<DutchGh0st> does the compiler run on arm?
<DutchGh0st> I downloaded the LInux 0.3 compiler, on my raspberry, but it cant run it..
<nbjoerg> pre-built is x86_64 only
<DutchGh0st> mhh okey, how do I build for arm then?
<nbjoerg> build from source?
<DutchGh0st> I guess
<DutchGh0st> mh, bad luck at first try: " llvm-c/Core.h: No such file or directory",
davr0s has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
<DutchGh0st> I have gcc 8.2.0 and clang 7.0.0 installed, but I dont know how this all works ^^
jjido has quit [Ping timeout: 264 seconds]
davr0s has joined #zig
steveno has joined #zig
<diltsman> andrewrk, it looks odd to me, too. The only other thing that the linker puts in that section is a while(true) loop for _start. It appears mostly correct (bn. 8000e in there twice...)
<diltsman> Dumping .text seems to think that the symbol at 00080000 is <panic>, though I don't know where that is coming from.
<euantor> DutchGh0st: Probably best to read the CI script for Linux: https://github.com/ziglang/zig/blob/master/ci/azure/linux_script#L8
<DutchGh0st> is there a String implementation in stdlib?
<euantor> It installs all the dependencies required to build on x86_64 and then builds, you will need the same dependencies for ARM
<DutchGh0st> Im making one currently...
<daurnimator> DutchGh0st: "String implementation"?
<DutchGh0st> dynamic String's
<daurnimator> DutchGh0st: how is a string more than a slice of u8?
<DutchGh0st> well, you cant push onto a []const u8
<DutchGh0st> or []u8
<diltsman> andrewrk, I had to export the vector_table symbol. I wouldn't think that would be necessary, since the .vector section is like this in the linker script: KEEP(*(.vector))
<MajorLag> DutchGh0st, ArrayList(u8) is basically what you're describing.
Hejsil has joined #zig
<DutchGh0st> I suppose hahahaha
<diltsman> andrewrk, it seems to be working now. The issue was that the vector_table symbol was not being exported (not certain why I needed to declare it export). I declared it export, had to change the types of the vector table entries to be C ABI compatible, then recompiled. It had been placing the panic handler at the location of vector_table. Still not certain why I had to export it even though the section has KEEP in the linker script.
<daurnimator> DutchGh0st: I'm used to languages with immutable strings, so I wouldn't even expect that as part of a string library!
<DutchGh0st> Immutable Strings...mhh
<DutchGh0st> I think extend() and push() are essential to a String
<DutchGh0st> why? well, if the capacity is large enough, why would't you be able to just push and extend? creating a new string, allocating enough space AND then copying everything over seems really expensive
<daurnimator> DutchGh0st: because with immutable strings you can reference count them. as well as storing other data along side such as hashes, utf8 validity, etc.
<DutchGh0st> now, sure, I also need to do that, but a *good* implementation only needs to do that a 'couple of times to be able to hold huge number of characters
<DutchGh0st> Just put reference counted struct around a mutable String
<DutchGh0st> and provide acces to it using like "getRef()" or "getMut()", which would bump the refcount
<Hejsil> DutchGh0st, Immutable string uses a different data structure from mutable ones, so they don't require a copy on append
<Hejsil> Normally they do at least
<Hejsil> "append"
<daurnimator> DutchGh0st: immutable strings can also more easily use data in the data section of your executable etc.
<daurnimator> anyway. different strokes for different folks
<Hejsil> It really depends on the problem
<DutchGh0st> oh it more keeps track of the little strings, but all those little strings may on different places in memory, Hejsil?
<Hejsil> I'm not 100% sure on the datastructure. It tends to be some kind of tree of cache sized blocks i think
<daurnimator> DutchGh0st: now you're talking about a rope...
<Hejsil> But yea, you'll get memory in different places
<DutchGh0st> heh ^^
<Hejsil> But an allocator could fix a lot of cache issues with such a data structure
<DutchGh0st> How did you read my mind haha
<DutchGh0st> I just wanted to ask "but what if you Iterate, don't you get lots of cache misses"?
<Hejsil> :)
<Hejsil> Different tools for different problems. Sometimes you don't want shared strings, and the copy would cost more than the cache miss
<Hejsil> shared mutable strings*
<daurnimator> and now you're asking about gap buffers. possibly without realising it
<Hejsil> If you're asking me, then I'm not
<Hejsil> I
<Hejsil> I've*
<DutchGh0st> No, but the triangle thingy makes sense actually
<DutchGh0st> so daurnimator, what language(s) do you come from ?
<daurnimator> DutchGh0st: Lua, C, JS, Haxe, (going back a while:) Actionscript
<DutchGh0st> mh, the correct way to get an iterator of *T and *const T out of an ArrayList(T), is trough list.toSlice() ?
<DutchGh0st> and then using `for(..) |item| {}` on the slice?
DutchGh0st has quit [Quit: http://www.kiwiirc.com/ - A hand crafted IRC client]
Hejsil has quit [Quit: Page closed]
tolitius has joined #zig
<presiden> speaking of gap buffer, https://nullprogram.com/img/gap-buffer/intro.gif
tolitius has quit [Quit: zzz...]
tolitius has joined #zig
DutchGh0st has joined #zig
davr0s has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
<andrewrk> DutchGh0st, you might have better luck cross compiling for arm rather than trying to build zig on arm
<DutchGh0st> I figured
<DutchGh0st> but that is sad, because I like the vim colorscheme I have on my raspberry, its nice than the one I currently have in vscode...
<DutchGh0st> so I wanted to use vim to write in haha
<andrewrk> diltsman, ah right. if you don't export something, it doesn't go into the object file
<andrewrk> unless you (directly or indirectly) depend on it by something that is exported
davr0s has joined #zig
tolitius has quit [Quit: zzz...]
wink_ has joined #zig
tolitius has joined #zig
tolitius has quit [Quit: zzz...]
<andrewrk> diltsman, I do think that it should be possible to export a packed struct. I'll open an issue for that
<andrewrk> or rather, export a variable whose type is a packed struct
<andrewrk> wait, that already works
<andrewrk> diltsman, I just tried your example, the only change being to add `export` in front of `var` and it compiles for me
DutchGh0st has quit [Quit: http://www.kiwiirc.com/ - A hand crafted IRC client]
tolitius has joined #zig
tolitius has quit [Ping timeout: 264 seconds]
davr0s has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
davr0s has joined #zig
MajorLag has quit [Ping timeout: 246 seconds]
tolitius has joined #zig
very-mediocre has quit [Quit: Page closed]
davr0s has quit [Quit: Textual IRC Client: www.textualapp.com]
shmibs has joined #zig
porky11 has quit [Quit: Leaving]
<presiden> how do you declare an array which size is calculated from a function that can be computed at compile time?
<presiden> let say, I have fn foo(n: u32) u32 { n+42 /* or some complex calculation */ }
<presiden> and I want var arr: [foo(10)]bool = undefined; for example
tolitius has quit [Quit: zzz...]
jjido has joined #zig
jjido has quit [Ping timeout: 240 seconds]