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/
earnestly has quit [Ping timeout: 244 seconds]
earnestly has joined #zig
_whitelogger has joined #zig
<andrewrk> Tetralux, search std lib for @fieldParentPtr
waleee-cl has quit [Quit: Connection closed for inactivity]
<Tetralux> andrewrk: Ah yeah - I'm guessing that's how you avoid the alignment errors with ptrCast.
<Tetralux> That can get you to the subtype from the supertype right?
<andrewrk> yes, given that the supertype is a struct field of the subtype
<andrewrk> it's planned to have runtime safety as well
<Tetralux> I like the sound of that :)
kristoff_it has joined #zig
chemist69_ has joined #zig
laaron has quit [Remote host closed the connection]
chemist69 has quit [Ping timeout: 246 seconds]
laaron has joined #zig
kristoff_it has quit [Ping timeout: 246 seconds]
<andrewrk> I don't have std.dumpCurrentStackTrace working when std.io.mode == .evented but the zig-window example code is actually working
<andrewrk> I think we're extremely close
<andrewrk> I bet we could have a single threaded networking client/server test now, taking advantage of evented I/O
Tetralux has quit [Ping timeout: 268 seconds]
eddyb has quit [Ping timeout: 264 seconds]
jzelinskie has quit [Ping timeout: 252 seconds]
eddyb has joined #zig
jzelinskie has joined #zig
<stratact> So I'm referencing a static struct from a C library, how does one use a static C struct in Zig?
<andrewrk> what's a static struct?
<andrewrk> I'm not being facetious; I've never heard of that
<stratact> There was no offense taken :) I'm not sure either, but reading online, people are saying that a static struct is a struct with all fields being static
<andrewrk> so the struct is empty?
<stratact> Not necessarily. Here is example of what I'm trying to do in Zig but it's written in C: https://github.com/cjd/mtpfs/blob/master/mtpfs.c#L1632-L1648
<andrewrk> stratact, that static is not describing the struct - it's describing the variable mtpfs_oper
<andrewrk> that means mtpfs_oper is not accessible outside this file
<andrewrk> in C everything should be static except for whatever is in your .h file
<stratact> Gotcha, I wasn't sure what it meant
<stratact> ...Today I learned how to declare struct variables in C... (or maybe have forgotten it, who knows)
<stratact> So I can just reference it and use it as a normal Zig struct, I'm assuming
<andrewrk> yes
<stratact> 👍
stratact has quit [Ping timeout: 240 seconds]
stratact has joined #zig
<stratact> Hmm, I want to use an ArrayList and it seems like ArenaAllocator is the only allocator I should use if I want something like a C++/Rust Vector, since I don't want a fixed sized allocation and continue to grow as needed.
<stratact> and HeapAllocator is not supported on FreeBSD yet
<shachaf> ArenaAllocator doesn't make much sense with that kind of dynamic array, does it?
<shachaf> I guess you could still do it but it seems like an odd use since you can't free the old memory when you reallocate.
<stratact> Ah I see
<stratact> shachaf: so would the best strategy be to use FixedBufferAllocator and whenever I need a larger buffer, I just make a new one with a larger size?
mahmudov has quit [Ping timeout: 246 seconds]
<stratact> Oh I see how it works now. I'm an idiot.
<shachaf> Maybe? Depends on what you're doing.
abbiya has joined #zig
laaron has quit [Remote host closed the connection]
laaron has joined #zig
laaron has quit [Remote host closed the connection]
laaron has joined #zig
laaron has quit [Remote host closed the connection]
kristoff_it has joined #zig
laaron has joined #zig
kristoff_it has quit [Ping timeout: 245 seconds]
eddyb is now known as eddyb[legacy]
avoidr has quit [Quit: leaving]
daurnimator has quit [Quit: WeeChat 2.5]
samtebbs has joined #zig
daurnimator has joined #zig
kristoff_it has joined #zig
ky1ko has quit [Ping timeout: 245 seconds]
mahmudov has joined #zig
abbiya has quit [Quit: abbiya]
laaron has quit [Remote host closed the connection]
ky1ko has joined #zig
laaron has joined #zig
ky1ko has quit [Remote host closed the connection]
ky1ko has joined #zig
samtebbs has quit [Quit: Lost terminal]
earnestly has quit [Ping timeout: 240 seconds]
earnestly has joined #zig
kristoff_it has quit [Ping timeout: 246 seconds]
samtebbs has joined #zig
dimenus_ has joined #zig
frmdstryr has joined #zig
<frmdstryr> Are there any examples of using sockets?
halosghost has joined #zig
<fengb> Not up to date. We're rewriting async layer so that'll stabilize soon™ probably after 0.5.0 release
<fengb> Er, async has recently been redone in the language, but the userland primitives are still being worked on so that's still in flux
<frmdstryr> Ok, thanks! Will wait some more, looking good so far!
<dimenus_> did the default behavior of debug info change recently in zig?
<dimenus_> eg, now I'm getting 'debug info stripped' when a build fails
dimenus_ is now known as rsdimenus
vegax87 has quit [Ping timeout: 250 seconds]
laaron has quit [Quit: ZNC 1.7.1 - https://znc.in]
laaron has joined #zig
laaron has quit [Quit: ZNC 1.7.1 - https://znc.in]
laaron has joined #zig
frmdstryr has quit [Quit: Konversation terminated!]
mahmudov has quit [Ping timeout: 245 seconds]
waleee-cl has joined #zig
kristoff_it has joined #zig
<kristoff_it> > <andrewrk> I bet we could have a single threaded networking client/server test now, taking advantage of evented I/O
porky11 has joined #zig
<kristoff_it> I'm very interested in working on that. I got my redis client working with simple blocking I/O and I was waiting for async/await to improve :)
<kristoff_it> I've read the commit that adds async support to the stdlib, but I'm wondering what I need to do precisely inside my client implementation to make sure concurrent requests are juggled the right way
<andrewrk> kristoff_it, this is still "experimental" until it's covered by a lot more stress tests, but for starters you can try this in your example programs: https://github.com/andrewrk/zig-window/blob/7c7bd70dec7fd16d75ca21bd607e5c5a57f7f31c/example/nox.zig#L4-L29
<andrewrk> with no changes to the library code, in this example I linked, if you change `evented` to `blocking` on line 4 the program has the same behavior, but much different strace
<rsdimenus> andrewrk: I'm not sure what happened there, I reset to head and it works fine now
<rsdimenus> no, I'm working on latest master
<andrewrk> kristoff_it, the beginOneEvent/finishOneEvent is a hack workaround, shouldn't be necessary. that's one of the loose ends i'm looking into
<andrewrk> and then finally only std.os.read is hooked up, not std.os.write yet.
<rsdimenus> should we emit dwarf for mingw builds?
<kristoff_it> andrewrk: ok thanks, I'll play around with it
<Yardanico> I feel like V author is a bit strange - he's asking the twitter users opinion even for changes like these - https://twitter.com/v_language/status/1171812858352586752
<Yardanico> btw, we talked about OpenMandriva, and I installed it yesterday :D
<andrewrk> Yardanico, off topic, no random trash talking plz
<andrewrk> kristoff_it, the main difference between evented and blocking is that if you use `async` to call a function, in blocking mode it finishes before the async call completes. in evented mode, async call will return right away and the answer can be collected later with await
<andrewrk> kristoff_it, there's also a segfault happening in the panic handler when trying to dump a stack trace, with evented I/O enabled. I haven't figured that out. so that will make your experimentations a bit annoying. if you run into any trouble I'd suggest waiting another week-ish :)
<kristoff_it> andrewrk: yes, my question is more about making sure that each full request gets written correctly, which I guess means I need to do some task scheduling by myself, otherwise I assume the event loop will just have multiple async functions write pieces of their respective request all over the place
<kristoff_it> andrewrk: as you can see it's a pretty noobish concern :)
<andrewrk> kristoff_it, have a look at std.event.Lock
<andrewrk> this is essentially a mutex, except instead of blocking a kernel thread, it does a suspend. which means that provided there is any other work to do, kernel threads will all still be doing work
Tetralux has joined #zig
<Tetralux> I never knew that you could do `{ .f1 = v1 }` in C.
<Tetralux> Curious.
<earnestly> Tetralux: C99
<earnestly> Also struct foo bar = {0}; to zero initialise
<earnestly> (Not in C++)
donaldallen has joined #zig
<Tetralux> Indeed - C++ made it {} instead.
<earnestly> Well, C++ is a very different kettle of fish
<earnestly> {} may do that, it may not
<Tetralux> You mean only certain compilers have that zero?
<earnestly> It depends on the type and what {} means to it
<earnestly> "default initialisation" iirc
<Tetralux> POD struct
<Sahnvour> *insert gif about all the initialization types in C++ here*
<donaldallen> Doc question: in the master docs, in the section on tagged unions, the construct "ComplexTypeTag(c)" is used in an assert, where c is a variable holding a variant of ComplexTypeTag. Where is this construct documented? It is certainly possible I missed it, but if I didn't and it isn't documented, I'd like to point that out so the docs can be fixed.
<donaldallen> Thnx.
<andrewrk> that is where it is documented
<andrewrk> oh, you're talking about implicit casts
<donaldallen> andrewrk: ComplexTypeTag is an enum and it is being used here in what looks syntactically like a function call. I can understand from the context what it does, but I believe this is the first instance of it in the doc, with no explanation.
<donaldallen> I looked at the link you provided and not clear to me that what I'm referring to is a case of that. Is it? If so, how?
<andrewrk> "implicit cast - invoke a type as a function"
<Tetralux> It is kinda weird to me that an _implicit_ cast, is used explicitly... xD
<Tetralux> You'd think T(x) would count as explicit.
<donaldallen> andrewrk: got it. Thnx.
<Tetralux> But yeah - it only compiles if the cast can be done implicitly.
<stratact> After sleeping on it and just waking up, I still can't decide if I want to use an ArrayList or a TailQueue
<fengb> Do you need to remove from the middle?
kristoff_it has quit [Ping timeout: 246 seconds]
<fengb> Or appending to the middle
<fengb> If not, ArrayList is probably faster
kristoff_it has joined #zig
earnestly has quit [Ping timeout: 276 seconds]
earnestly has joined #zig
<donaldallen> andrewrk: I would add that the implicit cast examples occur after the tagged union examples, so a forward reference. I'd suggest some sort of reference in the tagged union section to the implicit cast stuff so that people who go through the doc sequentially won't be baffled, as I was.
<stratact> fengb: TailQueue it is. One more question, how I can I `deinit` it completely without binding all the nodes to individual variables?
<stratact> Just looking from the test examples
<waleee-cl> kristoff_it: why did you remove your zig blogpost? (of course you can do whatever you want with your blog, just curious since it was well written)
<waleee-cl> nvm, I'm f*cking blind
<kristoff_it> waleee-cl: :) I guess that counts as feedback that the home page doesn't have perfect UX
* Tetralux grins
<waleee-cl> no, the UI/UX is fine, I for some reason had the wrong title remembered ("Comptime .... ") and only glanced at the overview
<kristoff_it> waleee-cl: I see, I thought that my rant on go vs rust that now has the top spot in the home page made you think the old post was not available anymore
<companion_cube> what blog post? :)
<waleee-cl> kristoff_it: well, yeah that too, but I actually went to /blog-also, and didn't register it in the list
<kristoff_it> waleee-cl: I'll work on that, for now, I'm happy to have implemented dark mode support
<fengb> But the real answer to Go vs Rust is Zig :P
<companion_cube> or crystal? 🤔
<kristoff_it> fengb: don't spoil the end of the new blog post :D (although in all seriousness, I think each has its own place. Boring answer I know, but what can I do)
<kristoff_it> anyway, writing about async/await in Zig is going to be an interesting challenge
<donpdonp> companion_cube: or nim? :)
<companion_cube> heh, who knows
<companion_cube> I do prefer crystal's syntax, though, by far :s
<donpdonp> going from ruby to crytal was amazing. helped sell me on strong typing.
<companion_cube> anyway I feel like it's actually more of a complement to zig/rust/C
<companion_cube> something a bit higher level for writing code more quickly
<stratact> donpdonp: you mean strong static typing? Ruby is also strongly typed, just dynamic.
<fengb> Oh you mention Zig ;P
Akuli has joined #zig
donaldallen has left #zig [#zig]
<waleee-cl> ... isn't ruby unityped like python?
lunamn_ has joined #zig
<kristoff_it> fengb: yeah :)
<fengb> Oh I spoiled because I had lag on my phone lol
<kristoff_it> waleee-cl: you're probably referring to dynamic typing. a truly untyped language wouldn't you let use `type()`, which can be used in python, for example
<companion_cube> it's just badly named ;)
<companion_cube> type() should be runtimetag() ;)
lunamn has quit [Ping timeout: 245 seconds]
<waleee-cl> ah, right. My memory about the difference was a bit fuzzy
<fengb> Truly untyped would be something like assembly :P
<fengb> Add pointers? Index by floats? Sure!
<waleee-cl> but I'm fairly sure that I have seen a elixir/phoenix-framework overview that mentions unityping, and that language do the same thing
<companion_cube> python does let you index by float
<companion_cube> it'll just fail at runtime :D
<companion_cube> funny how in this blog post I want to replace "go" with "crystal" now
<kristoff_it> companion_cube: I think you can define a custom __getitem__ that accepts floats
<companion_cube> 😂
<companion_cube> unittyped indeed…
qazo has quit [Quit: ...]
avoidr has joined #zig
mahmudov has joined #zig
kristoff_it has quit [Remote host closed the connection]
kristoff_it has joined #zig
kristoff_it has quit [Ping timeout: 244 seconds]
dingenskirchen1 has joined #zig
dingenskirchen has quit [Disconnected by services]
dingenskirchen1 is now known as dingenskirchen
dingenskirchen_ has joined #zig
dingenskirchen_ has quit [Client Quit]
laaron has quit [Remote host closed the connection]
laaron has joined #zig
return0e_ has quit [Read error: Connection reset by peer]
return0e has joined #zig
return0e has quit [Read error: Connection reset by peer]
return0e has joined #zig
donaldallen has joined #zig
donaldallen has quit [Remote host closed the connection]
laaron has quit [Remote host closed the connection]
laaron has joined #zig
drazan has quit [Remote host closed the connection]
lunamn_ has quit [Quit: leaving]
drazan has joined #zig
porky11 has quit [Quit: Leaving]
Ichorio has joined #zig
Akuli has quit [Quit: Leaving]
Tetralux has quit [Ping timeout: 240 seconds]
Tetralux has joined #zig
<scientes> I'm trying to read to the alignment resolution code and i just keep going in circles and can't find any actual data/tables
kristoff_it has joined #zig
lunamn has joined #zig
kristoff_it has quit [Ping timeout: 245 seconds]
halosghost has quit [Quit: WeeChat 2.6]
kristoff_it has joined #zig
kristoff_it has quit [Ping timeout: 245 seconds]
waleee-cl has quit [Quit: Connection closed for inactivity]
earnestly has quit [Ping timeout: 245 seconds]
earnestly has joined #zig
rsdimenus has quit [Quit: Leaving]
<Sahnvour> andrewrk: how would I have a build.zig copy a file (a package's dll) next to the built executable ? addInstallFile ?
HelloThere54321 has joined #zig
<HelloThere54321> I am trying to use inline assembly to read the GDT using the sgdt instruction. My current attempt is: table = asm volatile ("sgdt %[tab]" : [tab] "=m" (-> GDT_PTR_struct)); Im not sure if zig supports this
kristoff_it has joined #zig
Ichorio has quit [Ping timeout: 264 seconds]
qazo has joined #zig
<kristoff_it> so.... A very simple example that uses async I/O seems to be working first try :D
<mikdusan> --> scientes: ... going in circles and can't find any actual data/tables
<mikdusan> were you able to find it?
<scientes> actually rebasing on master fixed it
earnestly has quit [Ping timeout: 240 seconds]
earnestly has joined #zig
kristoff_it has quit [Remote host closed the connection]
HelloThere54321 has quit [Remote host closed the connection]
kristoff_it has joined #zig
earnestly has quit [Ping timeout: 240 seconds]
earnestly has joined #zig