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/
<emekankurumeh[m]> who's in charge of zig-spec?
mahmudov has joined #zig
mikdusan has quit [Quit: WeeChat 2.5]
wilsonk has quit [Ping timeout: 268 seconds]
wilsonk has joined #zig
<andrewrk> emekankurumeh[m], Jimmi started it but hasn't been active lately. so... me
mikdusan has joined #zig
<emekankurumeh[m]> is we updated the parser to remove pub from fields we need to update the spec too right?
<andrewrk> right
<andrewrk> after #75 is closed, it will be the other way around; spec must be updated first, then implementation follows
<emekankurumeh[m]> if you don't mind me asking what happened to kristate?
<andrewrk> send me an email
<andrewrk> thanks for the spec PR
<emekankurumeh[m]> np
_whitelogger has joined #zig
shachaf has quit [Quit: ?]
shachaf has joined #zig
marijnfs has quit [Ping timeout: 245 seconds]
marijnfs has joined #zig
<emekankurumeh[m]> foo suspends and calls bar
<emekankurumeh[m]> and when bar resumes foo, the rest of foo's code is run before control is returned to bar where is resumed foo?
<andrewrk> that looks consistent with what you said in your question
<pixelherodev> I'm going to guess that removing an element from an array list while iterating over the list is a no-no, correct?
<andrewrk> pixelherodev, generally, in computer science, if you iterate over an array list with an index, this can work fine if you manage the index correctly
<pixelherodev> I know that much :P I meant using the `.iterator()`
<pixelherodev> I'm guessing it's not designed to handle that?
<pixelherodev> Oh wait, I literally have the entire stdlib code right in front of me
Jezza__ has joined #zig
<pixelherodev> ... I think it would actually work.
keithdc has quit [Ping timeout: 264 seconds]
<pixelherodev> The iterator internally just keeps an index, so as long as the list's length changes properly, it shouldn't care if the list changes
<andrewrk> my suggestion is to avoid iterator() on ArrayList and use your own index variable
<pixelherodev> What for?
<andrewrk> I just don't see the value in ArrayList.iterator()
<pixelherodev> Why's it exist, then?
Ichorio_ has quit [Ping timeout: 264 seconds]
<pixelherodev> Though now that I'm using an index variable manually, I see your point
<pixelherodev> The iterator seems kind of pointless
<andrewrk> because the std lib is a community effort, and it's important for me to keep an open mind and not block neutral or possibly good ideas just because I have a preference
<pixelherodev> ... right. Yeah that makes sense :P
<andrewrk> but, yeah, I'll be eyeing some of the std lib functions skeptically during the planned audit (https://github.com/ziglang/zig/issues/1629)
<pixelherodev> So what, going to have the community vote?
muffindrake has quit [Ping timeout: 250 seconds]
<andrewrk> I'm planning to personally audit every function before calling it stable
muffindrake has joined #zig
<pixelherodev> If stack tracing fails whenever a `catch` statement is present in the main function, that's a bug with Zig which I should probably file on GitHub, right?
<andrewrk> yes
batok has quit [Ping timeout: 245 seconds]
doublex has quit [Ping timeout: 264 seconds]
<mikdusan> i have a hash_eql function and I have to disable line 1311 and avoid interning const_bigint otherwise compiler_rt.zig test fails pretty badly
<andrewrk> mikdusan, semi-related but are you aware of hash_const_val and const_values_equal in analyze.cpp?
<mikdusan> hmm no
<mikdusan> thanks i'm looking at it now
<andrewrk> apologies for the inconsistent naming
<andrewrk> what strategy are you using to store the interned data? I considered it for a moment and realized that it could be done with a "set" data structure (only a key, no value) and the keys could all be pointers. so that would be 8 bytes overhead per interned value. e.g. if you interned the integers 0-99, it would be 800 bytes total overhead, no matter how many copies of any of these integers you had
<mikdusan> i am using hash_map with key/`ZigValue*` and value/bool (no value)
<andrewrk> yeah that sounds right. unfortunately c++ does not let you pass void for the value like zig does
<mikdusan> heh yup
<andrewrk> oh wow, there's an easy gain here by re-arranging hash map Entry struct
<mikdusan> and for the map check, i use a stack tmp ZigValue to avoid heap traffic, and if not found, then heap create, copying what is needed from tmp, and finishing off construction. then map put
jicksaw has quit [Quit: ZNC is kill]
<andrewrk> oh neat
<mikdusan> oh so re-order `struct Entry` can save a few bytes?
jicksaw has joined #zig
<andrewrk> mikdusan, https://clbin.com/sGR9Y
<andrewrk> if K and V are both pointer aligned it does not matter
<andrewrk> but if V is bool then this re-arranging puts the bool in what would already be padding
<mikdusan> ah
doublex has joined #zig
<andrewrk> hm turns out it doesn't matter because V is often a pointer, in which case it will be better to have the bool after the int
<andrewrk> in zig the compiler is allowed to choose the best layout automatically
<andrewrk> it would be too annoying to express this with c++ templates
<daurnimator> andrewrk: I'm not sure I follow on the doc-sidebar issue: why would you ever want the side nav to scroll with main area. I'd find that weird/disorientating
<andrewrk> you need some way to jump back to the nav from the contents. status quo has that when you click a header
<andrewrk> "where am I in the toc?" status quo can answer this question with no javascript
<daurnimator> usually in other docs I expect clicking the header of a section to A. do nothing B. set my fragment to that section so I can get a link to it to share
<daurnimator> To get back to TOC I would just press "home" on my keyboard. I've also seen "Back to top" links in other documentation
chemist69 has quit [Ping timeout: 276 seconds]
<daurnimator> You could hide the "back to top" links based on a media query too.
chemist69 has joined #zig
<andrewrk> the toc is longer than 1 screen
<daurnimator> so?
<andrewrk> going to the top does not take you to where you are in the toc
<daurnimator> though also, did you see in the lua-http docs how the TOC sections are expandable with just CSS?
mahmudov has quit [Remote host closed the connection]
<marler8997_> for some reason getenv("TERM") is returning null...hmmm
<pixelherodev> Managed a massive performance boost to the heap in my kernel :)
<marler8997_> andrewrk: any idea why os.environ would be empty?
<andrewrk> marler8997, if you have the time to file an issue for that TODO I would appreciate it
<marler8997_> yeah no problem
<andrewrk> marler8997, did you see that I gave you a workaround?
marler8997_ has quit [Ping timeout: 265 seconds]
mahmudov has joined #zig
traviss has joined #zig
<traviss> does zig have array/slice designated initializers? ie int a[10] = { [1] = 1, [9] = 9 };
Jezza__ has quit [Ping timeout: 264 seconds]
riba has joined #zig
marler8997_ has joined #zig
<marler8997_> andrewrk: yeah thanks, I've updated my TERM=dumb PR to use the workaround getenvC
batok has joined #zig
batok has left #zig [#zig]
<Snektron> traviss: no
<traviss> ok thanks
<traviss> turns out i didn't need them because of @tagType(enumVar)
lunamn has quit [Ping timeout: 245 seconds]
lunamn has joined #zig
<traviss> s/tagType/tagName
LargeEpsilon has joined #zig
jokoon has joined #zig
<jokoon> can I compile zig from c++, and call zig function from c++ and vice versa?
<mq32> jokoon: you can compile C++ with zig and then use external functions to communicate between
<mq32> or you can compile object files with your c++ compiler and link them
<jokoon> I want to use a language to write scripts, for a video game
<jokoon> also I don't really know if zig is fast to compiel
<jokoon> compile
marijnfs_ has joined #zig
jokoon has quit [Quit: jokoon]
waleee-cl has joined #zig
casaca has quit [Ping timeout: 240 seconds]
casaca has joined #zig
casaca has quit [Ping timeout: 265 seconds]
casaca has joined #zig
mahmudov has quit [Remote host closed the connection]
casaca has quit [Ping timeout: 276 seconds]
doublex has quit [Ping timeout: 264 seconds]
casaca has joined #zig
doublex has joined #zig
LargeEpsilon has quit [Ping timeout: 276 seconds]
doublex_ has joined #zig
doublex has quit [Ping timeout: 265 seconds]
doublex_ has quit [Ping timeout: 268 seconds]
doublex has joined #zig
doublex has quit [Ping timeout: 240 seconds]
mrkishi has joined #zig
Akuli has joined #zig
THFKA4 has joined #zig
return0e_ has joined #zig
return0e has quit [Ping timeout: 268 seconds]
wootehfoot has joined #zig
mahmudov has joined #zig
jokoon has joined #zig
Jezza__ has joined #zig
wilsonk has quit [Ping timeout: 268 seconds]
<traviss> is it possible to pass flags to the zig compiler to which set global consts in a .zig file similar to -D[macro]=[value] for r c code?
wilsonk has joined #zig
<andrewrk> traviss, yes but the API is a bit experimental. look at std.build.LibExeObjStep.addBuildOption
<andrewrk> after this, you can @import("build_options") in the respective application/library
<traviss> ah, ok will try that out
<riba> do i use std.cstr.cmp for comparing c strings or is there something better?
<riba> and how do i compare regular strings
<riba> also is 0 false?
<traviss> regular strings i believe with std.mem.cmp(u8, s1, s2)
wilsonk has quit [Read error: No route to host]
<traviss> sorry, std.mem.eql(u8, s1, s2)
<riba> are there any string convenience functions?
<riba> split, etc
<riba> and are pointers to pointers even a thing
<riba> i think i am too retarded to use this language
<riba> i need to provide a callback to C code that takes a ** argument
<riba> i tried it like this: [*c][*c]
<riba> now i want to check both pointers to null
<riba> and "if (stanza == null || stanza.* == null)" does not work
<andrewrk> riba, have a look at std.mem.tokenize and std.mem.separate
<traviss> there is std.mem.splitIterator
<riba> i assume this is because c pointers are always optional or something?
mrkishi has quit [Remote host closed the connection]
<riba> and i cannot dereference it even though i just checked it?
<riba> andrewrk: cool, thanks
<andrewrk> riba, please, understand that you're using beta software, and make sure that if you're asking for help, it's actually asking for help and not complaining. don't appreciate this "retarded" comment
<riba> andrewrk: i did not think that talking about myself is complaining about this software
<andrewrk> what you're referring to is called context-aware types, I think, recently made famous by kotlin. zig does not do this everywhere
<riba> i'll try to watch the words i use though? really didn't mean to criticize anyone but me
<andrewrk> just try to keep the negative energy down, it's all good
<traviss> check here for comparing against nulls maybe: https://ziglang.org/documentation/master/#Optionals
<andrewrk> so it looks like you're trying to use translated C code yeah?
<riba> andrewrk: i am trying to translate my own C code, yes
<andrewrk> you never need to type [*c] into your keyboard
<riba> traviss: i'm trying to use "guard clauses", and i think the if-construct for unpacking optionals does not help me so i actually have to compare with null
<riba> andrewrk: i'm trying to write a function that i will pass to the C code as a callback
<andrewrk> riba, yes you will choose the correct pointer type and the answer is never [*c]
<riba> so even if i get this pointer from C code it will not be a [*c]?
<andrewrk> the answer to this question is in https://ziglang.org/documentation/master/#C-Pointers
<traviss> andrewk: could he use translate-c with his c code to see how zig would translate it?
<riba> The only valid reason for using a C pointer is in auto-generated code from translating C code.
<andrewrk> traviss, yes, if it is simple enough. translate-c is not yet complete
<riba> all right
<riba> i already got a part running where i use a [*c], i'll just see what it does without it
wilsonk has joined #zig
<andrewrk> I think you should read the documentation and understand how it works instead of guessing
<riba> i think my problem is that i only can invest half an hour at a time and forget half of what i read
<traviss> riba i have almost zero experience with this, but you might try `zig translate-c file.c --library c` and see if it works
<riba> in any case, i found why i had to type [*c] in the first place, which is probably where i got it from
<riba> a struct has a function member which expects a [*c] argument
<riba> when writing this function i did have to manually type [*c]
<andrewrk> that will be a compile error after https://github.com/ziglang/zig/issues/2984 is implemented
<andrewrk> as I said, you never need to type [*c] into your keyboard
<riba> but i get a compile error now from using this autoimported struct
<companion_cube> yep, you should have a snippet for it
<riba> i'll check again that i didn't add the [*c] myself when copying the autogenerated definition to overwrite some other part
<riba> here, this line was autogenerated during cimport:
<riba> load: ?extern fn ([*c]PurplePlugin) gboolean
<riba> now i changed the signature to [*] instead of [*c]
<riba> and it won't compile
<riba> did i get you wrong and i'm supposed to use something else entirely?
<mq32> is it an array of PurplePlugin or a single PurplePlugin?
<riba> i mean the signature of my implemented load function
<andrewrk> riba, what is the compile error you get when you change to [*] ?
<riba> it is a pointer to a single PurplePlugin struct
<mq32> then [*]PurplePlugin is correct
<andrewrk> riba, please at least read https://ziglang.org/documentation/master/#Pointers
<andrewrk> *PurposePlugin is single item
<riba> andrewrk: why do you assume i didn't?
<riba> error: expected type 'extern fn([*c].cimport:3:11.struct__PurplePlugin) c_int',
<riba> found 'extern fn([*].cimport:3:11.struct__PurplePlugin) c_int
<andrewrk> riba, because you chose [*] instead of *
<mq32> <mq32> then [*]PurplePlugin is correct
<riba> andrewrk: that is because i am tired :D
<mq32> i am stupid. it should be *PurplePlugin instead.... andrewrk is right
<riba> but i'm not the only one confused apparently
wootehfoot has quit [Read error: Connection reset by peer]
<riba> maybe there is some better syntax
<riba> but it does make sense
<riba> well, it still does not compile
<andrewrk> riba, please can I see the whole error message
<riba> andrewrk: ok
<riba> you mean the whole trace?
<traviss> try using https://clbin.com/ to post the trace
jokoon has quit [Read error: Connection reset by peer]
<andrewrk> riba, do you see the clues?
<riba> andrewrk: i do not understand them
<traviss> what happens if you use ?*PurplePlugin
<riba> traviss: i get more errors that seem even more intimidating
<riba> believe it or not i tried it but that's why i decided it's wrong
<andrewrk> riba, if you want to ask for help in this channel you need to put more effort in. we are happy to help but you cannot say these things, you need to ask questions instead of complaining. this is the last warning
<riba> andrewrk: i really don't understand why you think i'm complaining
<riba> where did i say anything negative
<traviss> riba try again. maybe use this tool <zig command> | curl -F 'clbin=<-' https://clbin.com
<riba> maybe i don't get it because english is not my first language
riba was banned on #zig by ChanServ [*!*@i577BCD5A.versanet.de]
riba was kicked from #zig by ChanServ [Banned: negative attitude and low effort]
waleee-cl has quit [Quit: Connection closed for inactivity]
<donpdonp> ouch. it might help to have another channel #zig-beginners or #zignewbs or some such.
<edr> wow
<andrewrk> this is the zig beginners channel
<edr> that is disheartening
<donpdonp> i think others were still willing to help out riba, it just got distracting/help-vampire for those way beyond his/her level
Akuli has quit [Quit: Leaving]
<andrewrk> please trust my decision making here. this individual has caused problems in the past and been temporarily banned before. there is no room in the community for bad attitudes
<andrewrk> newbies are more than welcome, but low-effort, high-demand communication is not welcome here.
keithdc has joined #zig
<traviss> +1 for the #zig-beginners channel idea
<andrewrk> there is a difference between being a beginner and being willfully ignorant
slice has joined #zig
<traviss> sure. just seems like it might serve to keep the signal to noise ratio higher here if there was a channel like that. and give people like me a place to learn by helping others.
<andrewrk> I don't think that beginner questions are noise, I think they are very on topic
<andrewrk> I appreciate the sense of helpfulness and caring that you're showing
<traviss> true. maybe something like #zig-discuss would be a better name
<andrewrk> you are welcome to advertise unofficial communities on https://github.com/ziglang/zig/wiki/Community
ltriant has joined #zig
dimenus has quit [Ping timeout: 246 seconds]
<traviss> thank you. i didn't realize there is an unofficial discord for zig users posted there with a beginners channel. nice.
<donpdonp> i didnt either o&O
Jezza__ has quit [Ping timeout: 245 seconds]
marijnfs has quit [Ping timeout: 276 seconds]
Ichorio has joined #zig
knebulae has quit [Read error: Connection reset by peer]
mahmudov has quit [Remote host closed the connection]
<emekankurumeh[m]> andrewrk: i found this gist that has details on how to get the windows PEB on platforms other than x86_64 and i386: https://gist.github.com/Wack0/849348f9d4f3a73dac864a556e9372a5
<emekankurumeh[m]> i'm not sure how trustworthy it is though
<emekankurumeh[m]> and it's in msvc intrinsics
<daurnimator> emekankurumeh[m]: is this an open question we have? I can probably do some research if we need it
<emekankurumeh[m]> not exactly, but andrew wanted to to try using the PEB to access a processes's information rather than using apis with a possibility of failure
<emekankurumeh[m]> he ported some code for getting the PEB from midipix, but they don't have code for windows on more exotic architectures
<daurnimator> emekankurumeh[m]: you can...... though it's not super stable: has changed between service packs before....
<daurnimator> emekankurumeh[m]: does anyone run windows on other than x86/i686/arm?
<emekankurumeh[m]> midipix didn't have code for arm, the other platforms were just included in the gist
<daurnimator> as if anyone still uses windows on alpha :P
<daurnimator> (discontinued before windows 2000 was released)
<Snektron> theres always that one person
<emekankurumeh[m]> windows embedded?
<ky0ko> from my understanding modern windows embedded basically doesn't run on anything that isn't x86/arm, even though it technically still supports mips and superh
<ky0ko> it's also a different platform than windows
<emekankurumeh[m]> windows embedded was also discontinued in favor of windows iot
<ky0ko> less discontinued, more renamed
knebulae has joined #zig
<ky0ko> actually, no, i should be clearer than that: windows embedded compact supports mips and superh, technically. windows embedded proper is just slimmed down windows, and was renamed to windows iot
<ky0ko> except for the things named windows 10 iot that are actually windows embedded compact
<emekankurumeh[m]> if we could have a way to access the result location, could we technically stack allocate in the stack of the calling from the function that called?
<Snektron> Isn't that what it does?
<emekankurumeh[m]> i mean do so directly, so we can for example have a unicode decoder allocate it's result in the frame of the function that called it, but treat is as a normal array
<emekankurumeh[m]> so you can "return" the array, but not worry about a dangling pointer
<emekankurumeh[m]> \ pointer to a stack var
<Snektron> Sounds dangerously close to VLA
<Snektron> VLA's are not bretty bad for performance
<Snektron> i mean, not bretty good
<Snektron> You can allocate a fixed buffer and assign to that, but at that point you can also just return the array i suppose
<Snektron> actually, you have to return the array then
<Snektron> but i think its more efficient to just return an int in the specific case of unicode