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: 246 seconds]
Kingsquee has joined #zig
JoshAshby has quit [Quit: WeeChat 2.9]
ashby has joined #zig
ashby is now known as JoshAshby
frmdstryr has quit [Quit: Konversation terminated!]
frmdstryr has joined #zig
<frmdstryr> Is there anyway to do this so slice does not become a dangling pointer? https://zig.godbolt.org/z/x437zr
Patrice_ has joined #zig
frett27_ has quit [Ping timeout: 246 seconds]
<Kuraitou> frmdstryr: update slice whenever buf reallocates, or don't store a pointer and instead use buf.items[0..4] in place of slice, or make sure buf is big enough ahead of time and never resize it
<frmdstryr> Kuraitou: Thanks, will just try to make it big enough and don't resize
xackus has quit [Ping timeout: 256 seconds]
notpiika has quit [Quit: https://quassel-irc.org - Chat comfortably. Anywhere.]
notpiika has joined #zig
marijnfs has joined #zig
marijnfs has quit [Ping timeout: 258 seconds]
zippoh has quit [Ping timeout: 240 seconds]
jayschwa has quit [Remote host closed the connection]
_whitelogger has joined #zig
<kandinski> if there isn't, it seems to me that std.math.sign returning an i2 enum for numeric values and an error for non numeric values would be a good beginner feature, and I offer to write it up on github and try and contribute it if you all think it's worthy.
<kandinski> This is my proposal for std.math.sign(). Comments appreciated: https://termbin.com/5w4a
<kandinski> (I won't put it on github until someone with better criteria tells me it's a reasonable idea)
waleee-cl has quit [Quit: Connection closed for inactivity]
semarie has quit [Ping timeout: 256 seconds]
semarie has joined #zig
semarie has quit [Quit: WeeChat 2.9]
ifreund has quit [Ping timeout: 272 seconds]
<Axiomatic> It could be the case (perhaps in the future) that numeric values include complex numbers, so one might think of what it should do then.
<Axiomatic> Or, if a number is binary, and meant to be interpreted as 1s complement vs 2s complement vs unsigned.
<Axiomatic> And similarly for number-ish NaN, etc.. Would a "positive infinity" have a positive enum value, and a negative one a neative value?
ifreund has joined #zig
_whitelogger has joined #zig
cole-h has quit [Ping timeout: 258 seconds]
ur5us has joined #zig
decentpenguin has quit [Quit: ZNC crashed or something]
decentpenguin has joined #zig
omglasers2 has joined #zig
kristoff_it1 has joined #zig
demizer has quit [Ping timeout: 264 seconds]
srgpqt[m] has joined #zig
ur5us has quit [Ping timeout: 260 seconds]
earnestly has joined #zig
gazler__ has joined #zig
gazler_ has quit [Ping timeout: 260 seconds]
shurane has quit [Ping timeout: 272 seconds]
nikita` has quit [Ping timeout: 272 seconds]
nikita` has joined #zig
betawaffle has quit [Ping timeout: 272 seconds]
shurane has joined #zig
guan has quit [Ping timeout: 272 seconds]
r0bby has quit [Ping timeout: 272 seconds]
betawaffle has joined #zig
r0bby has joined #zig
guan has joined #zig
karrick has quit [Ping timeout: 272 seconds]
lucid_0x80 has joined #zig
nikita` has quit [Ping timeout: 272 seconds]
karrick has joined #zig
jzelinskie has quit [Ping timeout: 272 seconds]
nikita` has joined #zig
nikita` has joined #zig
nikita` has quit [Excess Flood]
rzezeski has quit [Ping timeout: 272 seconds]
nikita` has joined #zig
rzezeski has joined #zig
jzelinskie has joined #zig
<daurnimator> karrick: what about signed zero?
omglasers2 has quit [Read error: Connection reset by peer]
<daurnimator> uh kandinski
aperezdc[m] has joined #zig
skuzzymiglet has joined #zig
gazler_ has joined #zig
gazler__ has quit [Ping timeout: 240 seconds]
hnOsmium0001 has quit [Quit: Connection closed for inactivity]
tundrax has joined #zig
m4r35n357 has joined #zig
<kandinski> daurnimator: if it's signed zero, this application doesn't care. It's a C return code.
<kandinski> but you're right that in this case the function would not be able to perform all kind of uses over all kind of numerics. Oh well.
tundrax has quit [Ping timeout: 245 seconds]
<kandinski> Axiomatic: just saw your answer in backroll. Yeah well, I got something that works for me now, and I'll keep thinking about it.
<kandinski> Thanks both of youse.
Kingsquee has quit []
nebulaek has quit [Quit: Leaving]
knebulae has joined #zig
ur5us has joined #zig
gazler__ has joined #zig
dumenci has joined #zig
gazler_ has quit [Ping timeout: 260 seconds]
dumenci has quit [Read error: Connection reset by peer]
lucid_0x80 has quit [Ping timeout: 258 seconds]
dumenci has joined #zig
waleee-cl has joined #zig
ask6155 has joined #zig
Patrice_ has quit [Ping timeout: 256 seconds]
skuzzymiglet has quit [Quit: WeeChat 2.9]
skuzzymiglet has joined #zig
radgeRayden has quit [Remote host closed the connection]
ur5us has quit [Ping timeout: 260 seconds]
tane has joined #zig
marnix has joined #zig
mokafolio has quit [Quit: Bye Bye!]
ask6155 has left #zig [#zig]
mokafolio has joined #zig
mokafolio has quit [Client Quit]
mokafolio has joined #zig
xackus has joined #zig
mokafolio has quit [Client Quit]
mokafolio has joined #zig
frmdstryr has quit [Ping timeout: 260 seconds]
frmdstryr has joined #zig
marijnfs has joined #zig
<marijnfs> damn, is Andrew allright?
Crisp has joined #zig
frmdstryr has quit [Ping timeout: 264 seconds]
Crisp has quit [Client Quit]
CmdrCrisp has joined #zig
marijnfs_ has joined #zig
marijnfs has quit [Ping timeout: 264 seconds]
marijnfs has joined #zig
Tharro has quit [Remote host closed the connection]
skuzzymiglet has quit [Ping timeout: 265 seconds]
marijnfs_ has quit [Ping timeout: 240 seconds]
cole-h has joined #zig
marijnfs_ has joined #zig
marnix has quit [Read error: Connection reset by peer]
marijnfs has quit [Ping timeout: 240 seconds]
marijnfs_ has quit [Client Quit]
marnix has joined #zig
x2C25 has quit [Ping timeout: 246 seconds]
marnix has quit [Read error: Connection reset by peer]
CmdrCrisp has quit [Remote host closed the connection]
xackus has quit [Ping timeout: 272 seconds]
dumenci is now known as gel_babana
Akuli has joined #zig
marnix has joined #zig
Patrice_ has joined #zig
skuzzymiglet has joined #zig
marnix has quit [Ping timeout: 272 seconds]
marnix has joined #zig
xackus has joined #zig
<ryuukk__> are there built in functions to cast slice into i32 and other types, with options for endianess?
<ryuukk__> i tried cast with poiunter but it complains with: error: cast increases pointer alignment
xd1le has joined #zig
<ifreund> ryuukk__: you can @alignCast() as well, but what you probably want is in std.mem
<ryuukk__> ifreund: can you show me how exactly to do this please? int i = *(int*) &data; i fail to understand what to pick from std.mem
<ifreund> what is data?
<ryuukk__> a fixed char array, or if you prefer int i = *(int*) data; for a char*
<ifreund> ryuukk__: mem.bytesAsValue()
<ryuukk__> i get: error: expected *[4]u8, passed *u8
gel_babana has quit [Remote host closed the connection]
<ryuukk__> data is supposed to be a []u8, not a fixed array, but for this example to keep it simpler i use fixed array
<ifreund> well, you can @ptrCast() that if you know there will always be at least 4 u8s
<ryuukk__> that is what i tried to do with it complained, check msg above
<ryuukk__> can you show me please?
<ryuukk__> i spent quite some time already without success..
<ifreund> ryuukk__: @ptrCast(*[4]u8, &self.data[self.pos]),
<ryuukk__> doesn't work, it prints:  instead of 5
benjif has joined #zig
<ryuukk__> this is frustrating
<ifreund> why should it print 5
<ryuukk__> 5, 0, 0, 0 = 5
<ifreund> uh, byte order?
<ryuukk__> it's x64 so little endian
marnix has quit [Read error: Connection reset by peer]
marnix has joined #zig
<ifreund> uh, your function is hardcoded to return 0...
<ryuukk__> i know it is to stop compiler to complain, above i print the ret value
<ryuukk__> here clean example:
<ryuukk__> var data = [_]u8{5,0,0,0};
<ryuukk__> std.log.info("{}", .{ret});
<ryuukk__> var ret = @ptrCast(*[4]u8, &data[0]);
<ryuukk__> it prints: info: ♣
<ryuukk__> i need an i32 that prints 5
<ifreund> no, you still need mem.bytesAsValue
<ryuukk__> i'd prefer to do it manually to understand how things works compared to my C++ project code
<ryuukk__> it really is not possible to do: int i = *(int*) data; ???
<ifreund> manually is just @ptrCast(*i32, @alignCast(4, ptr));
TheLemonMan has joined #zig
<ryuukk__> so why u gave me different code ?
<ifreund> but that only works if the bytes are aligned
<ifreund> but it's what the C version is doing
<ryuukk__> incorrect alignment
<ryuukk__> var ret = @ptrCast(*i32, @alignCast(4, &data[0]));
<ifreund> but it's UB if the bytes aren't aligned, see mem.bytesAsValue for a proper implementation
<TheLemonMan> there's readIntNative too
<ryuukk__> i don't want a function
<TheLemonMan> or readIntSliceNative...
<ifreund> isn't that just a wrapper?
<ifreund> nvm
<TheLemonMan> yep, but it works on unaligned pointers by using a pointer with alignment of 1
<ryuukk__> forget std.mem exists
<ryuukk__> how to do it?
<ifreund> read what std.mem does
<TheLemonMan> read std.mem
<ryuukk__> nobody can explain?
<mht> ryuukk__: what would you like to happen if the pointer is not aligned?
<TheLemonMan> read what I said
<TheLemonMan> @ptrCast(*align(1) const i32, data).*
<TheLemonMan> voilá
<ifreund> \o/
* ifreund wonders when bytesAsValue is useful
<TheLemonMan> beware of the performance implications on non-x86 silicon
<ryuukk__> that works, it print 5, thanks
<TheLemonMan> you owe me a tenner
xd1le has quit [Read error: Connection reset by peer]
xd1le has joined #zig
<ryuukk__> mht: it is not gonna happen on my use case so i don't need to worry about that
hnOsmium0001 has joined #zig
ask6155 has joined #zig
Kena has joined #zig
<Kena> Hello, please in which case should I use `expect()` instead of `assert()`?
<Nypsie[m]> assert is for debug modes, expect is for tests
<Kena> So in releases like fast, small or safe, i shall never have neither of them?
<Nypsie[m]> Assert will not be called in non-debug modes yes.
<Nypsie[m]> Anything part of std.testing should not be used outside tests. (ever)
<Kena> Allright, I understand.
Axiomatic has quit [Remote host closed the connection]
<Kena> Are you aware of any kind of Zig projects related to graphQL server/client libraries? Or there will be any in the upcoming months? I think it would benefit greatly to Zig's visibility.
<Nypsie[m]> Haven't seen any yet. The ecosystem is quite small still, so you'd have to write one yourself.
<Kena> Seems only fair :)
lucid_0x80 has joined #zig
<Kena> I have a grammatical question, a little off-topic I admit, but English is not my native language: does the words ``bit` and `byte` are prononced the same way?
ryuukk_ has joined #zig
ryuukk__ has quit [Ping timeout: 260 seconds]
<earnestly> Kena: Nope, bit is pronounced as, well, bit (e.g. [bit]ten by a dog), byte is bye-t, e.g. "I took a bite out of the dog"
klltkr has joined #zig
ask6155 has left #zig [#zig]
CmdrCrisp has joined #zig
m4r35n357 has quit [Quit: Ex-Chat]
klltkr has quit [Quit: Textual IRC Client: www.textualapp.com]
lucid_0x80 has quit [Ping timeout: 272 seconds]
<fengb> ryuukk__: looks like you were doing a bit kludge? Zig has @bitCast(u32, data) for that
<fengb> Also protects you from doing a bad cast due to mismatched size
<Kena> Thank you earnestly! I try to reason in english when I read the Zig documentation and I always stumble upon the prononciation issue especially with the alignment question where bits and bytes often cohabit.
<alva> Bit is /bɪt/ and byte is /baɪt/. And English is an inconsistent mess. :)
<earnestly> Tolkin was sad that most of the world spoke English, instead of their own unique tongues
wootehfoot has joined #zig
skuzzymiglet has quit [Quit: WeeChat 2.9]
skuzzymiglet has joined #zig
lucid_0x80 has joined #zig
lucid_0x80 is now known as gel_babana
TheLemonMan has quit [Quit: "It's now safe to turn off your computer."]
xd1le has quit [Read error: Connection reset by peer]
xd1le has joined #zig
gel_babana has quit [Ping timeout: 260 seconds]
<ryuukk_> @fengbit doesn't work, @bitCast(i32, &data[pos])
<ryuukk_> i'm having trouble figuring out what to put to handle float types here
<ryuukk_> @typeInfo have 0 documentation https://ziglang.org/documentation/master/#typeInfo
<ryuukk_> i feel like i'm gonna wait for zig 1.0, port progress is way to slow that it is way to frustrating for me
<ryuukk_> i'm fighting with language every step
x2C25 has joined #zig
Tharro has joined #zig
Tharro has quit [Client Quit]
Tharro has joined #zig
marnix has quit [Read error: Connection reset by peer]
marnix has joined #zig
<ryuukk_> why don't they document stuff as they implement things, how people expected to use them
<Kena> You also have https://ziglang.org/documentation/master/std/#std;builtin.TypeInfo but it's pretty limited too, you may want to check out the implementation detail in the source code
<ryuukk_> this is horrible user experience
<ryuukk_> also this link has 0 info how to use
<Kena> It was declared several times that documentation would always be left behind as the language is still under heavy development and breaking changes are to be expected until 1.0 (which is not planned before 2 years according to Andrew, who also added that it was already the case last year ^^)
<Kena> I know, it is fairly discouraging for beginners.
<alva> Knowing what state things are in, I just keep a local clone of the git repo, for documentation
<ryuukk_> it's just just documentation it is the features too
<alva> So I've only gotten stuck on actual bugs :)
<ryuukk_> it's just confusing mess
<ryuukk_> i kept continuing with the port because i thought it's ok i only have to do X thing once, but it's like that every step
<Kena> Yeah, it seems the best available workaround, as learnzig.org will not provide you with any kind of intermediate level of knowledge.
xd1le has quit [Read error: Connection reset by peer]
<Kena> You may want to start a kickstarter campaign to finance a introduction to programmation in Zig's book :)
<ryuukk_> i didn't need book for D and the port was done in 1 week
<Kena> But it's a pipe dream before releasing 1.0
<ryuukk_> here im almost 1 week, and not even 20% done
<tane> a website featuring common idioms like chapter 2 of ziglearn.org seems fine and should be easy to keep in sync
<Kena> D 0.0 was launched the december 9th 1999 by Walter Bright, it has a lot more time than Zig to gain maturity
<ryuukk_> that is not an excuse, with LLVM now, everyone can make language in under a year
<Kena> Maybe you should ask some questions to Marler8897, he was a D contributor until last year.
<ryuukk_> and this language has simple features wich makes it require less time
<Kena> and fell in love with Zig when a guy posted a link to ziglang.org in the D newsgroup lol.
<ryuukk_> i liked ZIG at first, but as i try to implement stuff i get frustrated even more
<Kena> Perhaps you should synthesize your thoughts (and frustrations) about Zig in a reddit post. It would be more consistent and academic than raising some vague deceptions in IRC?
xd1le has joined #zig
<Kena> Knowing than others with prior experience in programmation have still difficulties to port some basic features towards Zig may be reassuring for a silent part of the community.
<ryuukk_> i should have noted the issues as i encounter them
<ryuukk_> but i don't have time to write blog post, i'm not interested
<Kena> It's understandable, perhaps you would reconsider to share a post when you'll have overcome even more difficulties.
<Kena> With regard to the current progress and the functional scope to reach, I think there will be at least a 0.10.0 before 1.0 so there's plenty of time before stabilizing the language (and the documentation afterwards)
<Kena> It is clearly still expertimental so the workarounds and others hint/tips will be scattered into IRC, reddit and informal medium, we are nowhere near to a exhaustive documentation or even a full tutorial to begin with.
cole-h has quit [Ping timeout: 272 seconds]
Kingsquee has joined #zig
<ryuukk_> they just need to test other languages, really, like the iterator problem, it's easy with other language, why i need to type ton of bloat to make something similar, same for interface, why i need to write ton of bloat, for pointer casting why it is so confusing to get right, same for std.log.info, why is not possible to remove the need to type .{} at the end, it's many little things like that that stack up, it's not just documentation, i think they have
<ryuukk_> different meaning for "simple language", it is instead "minimal language", not simple, they put constraints that doesn't help move forward
<ryuukk_> self: *Self whenever i write a function in a struct, it should be implicit
<ryuukk_> many little things like that
<alva> I like not having variadic functions, and that the language doesn't make arbitrary decisions for me in order to appear simple (while hiding potential bugs.) These things are subjective. :)
<alva> There's plenty of language that do that already
<ryuukk_> move i type, more stuff are convoluted and actually hides the reasoning in the code
frmdstryr has joined #zig
<ryuukk_> more*
<ryuukk_> wich introduces bugs more easily
marnix has quit [Read error: Connection reset by peer]
marnix has joined #zig
<g-w1> what about static methods
<ryuukk_> another case where it is misleading in ZIG actually
<ryuukk_> static methods
<g-w1> wdym?
<ryuukk_> *, ithe thing that differientiate them, and it is confusing, it is * times, * pointer, and * is super tiny character
<ryuukk_> bug that is easy to introduce
<ryuukk_> static fn
<ryuukk_> easy
<ryuukk_> and things like that stack up
xd1le has quit [Read error: Connection reset by peer]
<alva> Instance methods can take self by value too.
<Kena> Interfaces and iterators are still considered issues in discussion in github I believe. You could add your two cents on the matter and express your concern in a more formal manner.
<ryuukk_> alva: even more confusing
<ryuukk_> Kena: interface are not, they closed all the issues about it
<alva> How so? It's totally explicit
frmdstryr has quit [Ping timeout: 264 seconds]
<ryuukk_> it is confusing because it can be many things
squeek502 has quit [Remote host closed the connection]
<ryuukk_> implicit self, and explicit static solve that
<ryuukk_> but no, they decided to be "simple"
<alva> How would you choose by value or by reference with implicit self?
<travv0> i'll give you that i wish methods taking self by value and by reference had different syntaxes
<ryuukk_> if not implicit then forbit putting functions inside structs
<travv0> not sure what that has to do with static though
<ryuukk_> it is confusing
<travv0> static methods don't mention self at all unless i'm misunderstanding
<Kena> It may be related to "communicate intent precisely" principle or even "no hidden control flow" requirement.
<g-w1> they are saying that all struct methods should have self: *Self by default unless it is static fn
<g-w1> travv0
<travv0> ah, i gotcha
<travv0> i don't see the problem with the way it is, it's also how rust does it and it works well there too
<travv0> plus the whole by value/by reference thing
<ryuukk_> i don't consider rust to be a good example to be honest
<ryuukk_> rust didn't like 1 day in my testing
<ryuukk_> last*
<travv0> thanks for being honest
<alva> Not everything is for everyone.
xd1le has joined #zig
<ryuukk_> of course, but that shouldn't from having concerns, opinions and suggestions
<ryuukk_> prevent*
<ryuukk_> sorry my typing is bad today
<ryuukk_> rather have them than people testing product and leaving without notice
<travv0> but as Kena pointed out, this isn't really the medium to point that stuff out if you want it to get any real attention
<ryuukk_> using IRC is the best i can do
<Kena> you could expose your grief during a ShowTime Zig :p
<Kena> It can help formalizing a brief proposition in github/reddit.
<ryuukk_> i don't think i can do that
<ryuukk_> if all this IRC already doesn't understand my points i doubt it can change :p
<ryuukk_> i'm not saying it has to change
<alva> I understand your points, I just disagree with them. :)
<alva> Doesn't make you wrong
<Kena> Start forking Zig and conquer the world.
<ryuukk_> i only want to make a game :p
<Kena> Do you plan to conceive your own GUI?
<ryuukk_> that is the plan, but for the moment i have to finish the foundation of the engine
<ryuukk_> will see if i manage to finish it before stopping and waiting for zig 1.0
<CmdrCrisp> @ryuukk_, FWIW (i know the conversation has drifted a bit), here's this: https://zig.godbolt.org/z/E4Tvfa
<CmdrCrisp> The thing about that code sample is there just arent' that many floats. It's not purely generic, but it's not too much work to maintain.
alva is now known as ugla
<ryuukk_> CmdrCrisp: thanks a lot
<CmdrCrisp> Sure, no problem.
tane has quit [Quit: Leaving]
Kena has quit [Remote host closed the connection]
Akuli has quit [Quit: Leaving]
xd1le has quit [Read error: Connection reset by peer]
xd1le has joined #zig
marnix has quit [Ping timeout: 272 seconds]
Jayce has joined #zig
Jayce has left #zig [#zig]
ryuukk__ has joined #zig
ryuukk_ has quit [Read error: Connection reset by peer]
CmdrCrisp has quit [Ping timeout: 260 seconds]
CmdrCrisp has joined #zig
solaire1 has joined #zig
xackus has quit [Ping timeout: 260 seconds]
rx_ has joined #zig
skuzzymiglet has quit [Ping timeout: 240 seconds]
a92 has joined #zig
solaire1 has quit [Quit: WeeChat 2.9]
skuzzymiglet has joined #zig
maxrazer has joined #zig
<maxrazer> I'm trying to understand the potential use cases of zig vs. golang. I'm thinking that maybe go would allow easier and more rapid development when real time is not an issue. Or, would zig be easy and rapid enough to negate this benefit? I know in the presentation there were 4 different reasons given languages should be disqualified to be perfect. This seems like zig is trying to be an all-use case general programming language.
<maxrazer> However, does it really have all the advantages of golang for example, without any of the negatives?
skuzzymiglet has quit [Ping timeout: 260 seconds]
<rx_> whaat?
<maxrazer> Does zig have all the advantages of golang without the disadvantages?
<g-w1> Are you talking about the talk at localhost?
<rx_> I'm unaware this was a thing
<maxrazer> I'm look at the Emerging Technologies for the Enterprise Conference, but I also watched another presentation before.
<rx_> I don't think there is a comparison at all, but I would like to see how this plays out
<g-w1> Ok. I have not programmed in golang, but I have seen that talk. Since golang is garbage collected, it may be easier to program in, since you do not have to do manual memory management, but zig provides a lot of features to make that super easy. These features include, defer, general purpose allocator, testing allocator. I would say: write some programs in zig and see how fast you develop compared to golang.
<rx_> is zig going to bless some libraries or make a big standard library?
<rx_> iirc regexp is not currently a thing?
<g-w1> Someone wrote a compile time regex library, but I do not know if it is official
<rx_> that's cool :]
<maxrazer> Ok, thank you.
xackus has joined #zig
rx_ has quit [Ping timeout: 260 seconds]