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/
kristoff_it has quit [Ping timeout: 252 seconds]
<daurnimator> also AFD helper functions
lunamn_ has joined #zig
lunamn has quit [Ping timeout: 276 seconds]
doublex has quit [Quit: Leaving]
doublex has joined #zig
doublex has quit [Client Quit]
doublex has joined #zig
doublex has quit [Client Quit]
doublex has joined #zig
doublex has quit [Client Quit]
doublex has joined #zig
<fengb> I'm a little confused about what to do with errno in std/os
<fengb> Doing some wasi implementation
<fengb> Should I be mostly ignoring the threadlocal value and returning the error codes directly?
bjorob has quit [Ping timeout: 252 seconds]
lunamn_ has quit [Quit: Lost terminal]
<daurnimator> fengb: in std/os.zig you should convert from (all of) errno to the specifically documented error conditions as zig errors
<fengb> Sure, but what do I do with errno? There's getErrno but it doesn't seem to actually check the threadlocal variable
<gruebite> i'm attempting to use C enum in a switch but getting type errors?
<gruebite> https://pastebin.com/hXexXuDj error: expected type 'c_uint', found '(enum literal)'
<gruebite> .GDNATIVE_EXT_NATIVESCRIPT => {
<gruebite> paste has the code
<gruebite> there isn't a "@uintToEnum` either
<daurnimator> fengb: huh? that's C code....
<fengb> I'm translating it
<daurnimator> fengb: okay. no you don't need to set errno from within std/os.zig
<daurnimator> that code is writing a *libc* implementaiton: where people may expect to call isatty() and then check errno.
<gruebite> daurnimator: when i do that i get uint cannot be cast to int
<gruebite> seems the C enum type is uint by default?
<daurnimator> andrewrk: I see your PR removes `const testing = std.testing;` in a module: is this now advised against?
qazo_ has joined #zig
qazo has quit [Ping timeout: 240 seconds]
<daurnimator> andrewrk: idea: instead of `[*]null u8`, `[*]sentinel(0) u8`?
jicksaw has quit [Quit: ZNC is kill]
<fengb> senti(null) 🙃
jicksaw has joined #zig
<fengb> Ah so threadlocal errno is just a libc convention?
<daurnimator> fengb: yep
<fengb> For some reason I thought it was a syscall thing. Thanks
adamkowalski has joined #zig
<adamkowalski> Do we have a way of parsing dates from a string?
reductum has quit [Quit: WeeChat 2.6]
redj has quit [Read error: Connection reset by peer]
redj has joined #zig
<adamkowalski> And if not, what would be the way to approach this?
<daurnimator> adamkowalski: no I don't think so
<adamkowalski> I was thinking about taking in a compile time date format string
<adamkowalski> then building a state machine thats specialized to read that?
<daurnimator> yeah I think that's what you'd have to do right now. zig std doesn't really have any higher level parsing utilities right now
<adamkowalski> Alright, thanks for the tip! I'm thinking maybe a DateTime struct and a TimeDelta struct
<adamkowalski> so if you "subtract" two dates you get a delta in days
<daurnimator> adamkowalski: nope
<adamkowalski> care to elaborate haha
<fengb> Oh boy datetimes
<daurnimator> dates do not work like that
<daurnimator> adamkowalski: you need to get the delta for each value
<daurnimator> e.g. 2020-02-29 subtract 1 year: what do you get?
<adamkowalski> well thats different
<adamkowalski> now your subtracting a DateTime from a TimeDelta
<adamkowalski> so you get a DateTime
<adamkowalski> DateTime - DateTime = TimeDelta
<adamkowalski> DateTime - TimeDelta = DateTime
<daurnimator> adamkowalski: what is the result though?
<adamkowalski> DateTime{.year=2019, .month=2, .day=29, .hour=0, .minute=0, .second=0}
<daurnimator> okay so its a non-existant date? what now?
<adamkowalski> well then DateTime - TimeDelta = !DateTime
<fengb> Also... are we ignoring calendars?
<fengb> Someone in this channel would flip out. I just don't remember who >_>
<daurnimator> 2019-10-06T04:00:00 Australia/Melbourne minus 5 hours. what do I get?
<adamkowalski> Thats why i'm bringing it up, let's talk about this and find out what works for people
<adamkowalski> However, I also need something for today to get my project moving forward
<daurnimator> its not perfect; but I think luatz did *most* things right
<adamkowalski> Hmm thanks i'll study that
<adamkowalski> The existing libraries we use at work are Pandas and Numpy for dealing with datetimes
<daurnimator> note that there is no "TimeDelta" type: you just have an out-of-range DateTime that you "normalise"
<adamkowalski> numpy does the datetime and deltatime appraoch
<adamkowalski> it works pretty well
<adamkowalski> pandas just throws up on itself, and when we are making predictions about failures 100 years into the future it says it can't create a c int that big haha
<daurnimator> `const x = DateTime{.year=2020, .month=2, .day=29, .hour=0, .minute=0, .second=0}; x.year -= 1; x.normalise();`
<adamkowalski> I think a timedelta notion is useful though
<adamkowalski> Because you want to reason about the passage of time seperately from what day it is
<daurnimator> Yes. You have to work the week-day out last.
<adamkowalski> I don't know if giving people the ability to mutate year directly is safe
redj has quit [Ping timeout: 252 seconds]
<daurnimator> what do you mean "is safe"
<adamkowalski> if people start just changing days/months/years whatever
<adamkowalski> you can get into the situation where day is 70
<daurnimator> exactly!
<daurnimator> that's the point
<adamkowalski> but if you are forced to say datetime plus some timedelta
<adamkowalski> then that function is in charge of maintaining invariants
<daurnimator> no its not
<adamkowalski> and the public api exposed to the user is safe
<daurnimator> you get back to a "normalised" (valid) form by calling .normalise()
<adamkowalski> yeah but thats one possible design
<daurnimator> btw, for figuring out day of the week I use the sakamoto method
<adamkowalski> I don't want the user to ever have a non normalized datetime
<adamkowalski> I also prefer returning new dates to mutating in place
<adamkowalski> if you keep things functional it makes parallelism simpler
<daurnimator> adamkowalski: you do though. otherwise you can't pass around unnormalised forms
<adamkowalski> whats a use case for that
<daurnimator> e.g. if you want to say "recurring event every 3rd day of the month", then you really want the unnormalised form
<adamkowalski> i'm still not sure I get why
<adamkowalski> you can have something return a array of dates that increment by delta time of 3 days
<adamkowalski> each date time within the array is a valid date though
<adamkowalski> or you can use an iterator if you don't want to store the memory for everything
<adamkowalski> each time you call next it could increment by the time delta
<daurnimator> `var start_date = DateTime{.year=2019, .month=11, .day=20, .hour=0, .minute=0, .second=0}; while (start_date < end_date) { start_date.month += 1; const appointment = start_date.normalise(); render(appointment) }
<daurnimator> adamkowalski: it doesn't work like that though
<adamkowalski> I mean it can work how we choose right?
<adamkowalski> you are proposing one possible design in the design space
<adamkowalski> i'm proposing another
<adamkowalski> it would be more helpful if you could elaborate on why they don't work
<adamkowalski> or provide counter examples
<daurnimator> with dates, a + b = c; c + b = ?; can be *different* to `a + b*2 = ?`
<adamkowalski> in my design you can't add dates
<adamkowalski> you could add a date and a delta time
<adamkowalski> in which case "multiplying" the delta time by 2 and adding
<adamkowalski> is the same as adding twice
<daurnimator> but it's not!
<adamkowalski> adding two days, or adding one day, then another...
<daurnimator> which can get different results
<adamkowalski> how do you figure
<daurnimator> add one day, then add a month. vs add one month, then a dday
<adamkowalski> are you adding the two timedeltas together first? or the datetime + timedelta + timedelta
<adamkowalski> either way I need to choose something thats gonna work for today, and then i'll work out the kinks later
<adamkowalski> but at a high level what would be the proposed API that you would suggest
<adamkowalski> from the consumers point of view, not the implementers
<daurnimator> adamkowalski: same as luatz: see the docs there
<adamkowalski> alright i'll read through that then
<torque> specify all timedeltas in femtoseconds
<fengb> "2/4 test "ZeeAlloc internals"...Error: wasm trap occured: memory out-of-bounds access"
<fengb> So... I think I got a wasi test built
<fengb> I'm sad that ZeeAlloc is buggy though :(
<adamkowalski> torque whats the advantage of that?
<adamkowalski> the way that numpys API looks for example is like this
<adamkowalski> >>> np.datetime64('1990-01-01') + np.timedelta64(1, 'D')
<adamkowalski> numpy.datetime64('1990-01-02')
<daurnimator> adamkowalski: also make sure that the timezone of any datetime is captured
<daurnimator> that was one thing missing in luatz
<companion_cube> or store them in UTC
<daurnimator> companion_cube: if you *can* yes; but if you need to have future events, you need to work in the timezone of the user
<daurnimator> companion_cube: e.g. if I say "set my alarm for 8am every morning", you need to know which timezone I'm in; and you need to make sure you do the correct thing around e.g. daylight savings adjustments
<companion_cube> yeah, I feel like this isn't even a datetime but something more complicated
<daurnimator> companion_cube: no it is datetime support
<companion_cube> cause if you take the plane to another timezone, you mean the new 8am
<daurnimator> companion_cube: you just need to make it an error to try and mix timezones
<companion_cube> it's tied to "current TZ", not the one in which you defined in
<companion_cube> +it
<adamkowalski> yeah if we wanted to support all that we would also have to think about leap years, and daylight savings time all all this other stuff
<adamkowalski> this is gonna balloon way out of proportion haha
<adamkowalski> for now i'm gonna start simpler
<adamkowalski> but i'll study the api you mentioned
<adamkowalski> we should enumerate all the issues we can think of
<adamkowalski> maybe write a proposal, and then we can build something that can be ready for the standard library
<adamkowalski> but I did start looking at adding months in numpy and I guess they don't handle that too well yet either
<adamkowalski> are there any other libraries in any other languages you all think we should consider?
<adamkowalski> we've currently just got luatz
<fengb> I believe Joda time / Java 8 time is considered pretty good
<andrewrk> alright I have time to answer some questions now
<andrewrk> fengb, you're doing WASI?
<fengb> Yeah trying to get tests running
<fengb> Seems to work :)
<fengb> Compiling to wasi and running them with wasmer
<adamkowalski> andrewrk: any thoughts on the date time debate?
<doublex> leap seconds are also a thing
<adamkowalski> What do you all think about following the standards? https://en.wikipedia.org/wiki/ISO_8601 https://en.wikipedia.org/wiki/Coordinated_Universal_Time
<daurnimator> What does he think about UTC? what sort of answer do you expect? :P
<andrewrk> fengb, I don't think web assembly has threads... are you sure WASI needs a thread local errno?
<adamkowalski> I mean what should we do about representing date time in zig
<adamkowalski> durations and instants? only instants? something completely different?
<adamkowalski> do we use time zones, or just adopt UTC? how do we handle parsing
<adamkowalski> the works
<fengb> It doesn't yet, but the de facto libc marks things as threadlocal. Doesn't matter since I just wrote the zig translation
<daurnimator> adamkowalski: you have to use time zones. UTC is one timezone of many. But I don't know how this applies to your question
<fengb> I was worrying about compatibility when we aren't really exporting a libc. Got confused because I was still trying to carry over C style errno
<adamkowalski> i guess my question is what is the vision for the zig standard library as far as approaching date times
<daurnimator> whatever we do, lets not make the same mistake as Go :P
<adamkowalski> what do you all think about that for the Date struct
<adamkowalski> it's all fits in a single i64
<daurnimator> adamkowalski: I wouldn't use a packed struct: also usually you'd want nanosecond resolution
<daurnimator> adamkowalski: also add a timezone member. but feel free to make it a single-valued constant "UTC" for now.
<fengb> Also year should be signed for BC
<fengb> Actually does that make sense? BC didn't have Gregorian
<daurnimator> fengb: it does "upon agreement"
<adamkowalski> We only go back in time to the real beginning
<adamkowalski> the unix epoch
<daurnimator> fengb: (to quote ISO_8601)
<companion_cube> rfc3339 is simpler, iirc
<daurnimator> companion_cube: RFC3339 is a printed format
<daurnimator> but yes. the default serialisation for your Date object should be RFC3339
<daurnimator> s/serialisation/strinigifcation/
<companion_cube> not sure of the difference there, since you can parse it back?
<adamkowalski> so are we saying get rid of hour/minute/second and only store nano second?
<daurnimator> adamkowalski: no. hour/minute/nanosecond
<doublex> 2^64 nanoseconds is only 585 years
<daurnimator> (you have to have seconds separate because of leap seconds)
muffindrake has quit [Ping timeout: 245 seconds]
muffindrake has joined #zig
<adamkowalski> take two https://pastebin.com/yyZt2dTa
<adamkowalski> destroy, throw tomatoes, the usual
Ichorio_ has joined #zig
<doublex> yet another weird thing: years are not integers, i.e. there is no zero. Before AD 1 comes 1 BC
Ichorio has quit [Ping timeout: 252 seconds]
<fengb> So we should use 0 = 1BC, -1 = 2BC, etc 🙃
<andrewrk> the C stands for "Computers" right? 1 year Before Computers
<doublex> natch
<fengb> Is there a way to attach methods to opaque types?
<andrewrk> there is not
redj has joined #zig
<adamkowalski> andrewrk: do you prefer methods to overloading or traits? The one issue is what fengb mentioned, but even more generally you cannot add behavior to types you do not own
<adamkowalski> I had this issue in D language for example. For whatever reason strings were not iterators
<adamkowalski> but iterators required a .next method on the type itself
<adamkowalski> so there was no way to extend strings to become iterators
<adamkowalski> I guess it's possible to create a new type, wrap the old type and then add a method on that new type. But being able to just implement a trait seems rather nice
<adamkowalski> It also means that you can auto generate docs for that trait and easily find every type which implements it
<daurnimator> fengb: yes that's the ISO standard
<daurnimator> fengb: https://en.wikipedia.org/wiki/ISO_8601#Years > To represent years before 0000 or after 9999, the standard also permits the expansion of the year representation but only by prior agreement between the sender and the receiver.[19] An expanded year representation [±YYYYY] must have an agreed-upon number of extra year digits beyond the four-digit minimum, and it must be prefixed with a + or −
<daurnimator> sign[20] instead of the more common AD/BC (or CE/BCE) notation; by convention 1 BC is labelled +0000, 2 BC is labeled −0001, and so on.
chemist69 has quit [Ping timeout: 252 seconds]
<fengb> Buh
chemist69 has joined #zig
adamkowalski has quit [Ping timeout: 265 seconds]
return0e has quit []
<andrewrk> adamkowalski, what's the benefit of adding behavior to types you do not own? just add functions that do what you want with the types you want
<daurnimator> andrewrk: being able to use method syntax with them
<daurnimator> e.g. myopaquehandle.dothing(x, y)
<andrewrk> that's not a real obstacle
<andrewrk> dothing(myopaquehandle, x, y)
<daurnimator> It is if you want to e.g. provide it to a generic
<daurnimator> fn myGeneric(foo: var) void { foo.someinterfacemethod(); }
<andrewrk> I don't see a real actual use case here
<daurnimator> andrewrk: I've wanted to do it several times...
<daurnimator> slightly different reason: what if you want to provide a `format` method?
<andrewrk> put it in a struct you do own. format("{}", Mine{.x = x})
<daurnimator> Can you even put an opaque in your own struct?
<daurnimator> You can put a pointer to opaque...
<mq32> andrewrk, regarding your latest tweet/null termination: wouldn't it be more consistent to use `[null*]const u8` similar to `[c*]const u8` ?
<mq32> also it reads just logical: "nullterminated pointer of many to constant u8"
adamkowalski has joined #zig
<andrewrk> slices can indicate their pointers are null terminated as well: []null const u8
<daurnimator> (and preceding points)
<mq32> ah, sounds reasonable :)
<daurnimator> mq32: see also https://github.com/ziglang/zig/issues/3731 :)
<mq32> daurnimator: that wouldn've been exactly my next comment
<andrewrk> daurnimator, I can confirm the sentinel thing would work with the semantics. everything works based on get_null_value_for_type(ZigType *ty)
<daurnimator> andrewrk: you mean in terms of making the argument to sentinel a comptime variable?
<andrewrk> yes, it would work semantically
<daurnimator> cool. I didn't consider that a blocker but its good to have
<andrewrk> yeah I'm just saying you're onto something that would work cleanly
<mq32> `0xFF`-terminated strings incoming? :D
<daurnimator> It was hard to come up with use cases. I'm sure there are APIs out there that e.g. take a -1 terminated list, but I couldn't think of one off the top of my head
<daurnimator> The one I did think about a bit was `sentinel('\n')` for the return value of e.g. `stream.readLine()`
<andrewrk> there is an ambiguous design decision to solve here. I made string literals in that branch single-item pointers to arrays. however upon further reflection, that wasn't a necessary change to remove C string literals from the language. the question is rather whether zig will allow type coercions of values to const references ever
<andrewrk> on one hand, it would be clean to have a rule, "zig never takes a reference without the & operator". however on the other hand, we have <kristoff_it> I have a function with this signature: `pub fn init(keys: []const []const u8) Self`, when I call it like this `init(.{ "lol", "123", "test" });`
<andrewrk> I think the important concept here is lifetimes. Comptime const values have a static lifetime; that is they are always valid. Maybe the rule is that zig is allowed to take a const reference of a value when that value's lifetime is static
<andrewrk> in which case maybe it would make sense to make string literals `[N]null u8` rather than `*const [N]null u8`. and allow coercion to `[*c]const u8`, `[*]null const u8`, and `[*]const u8`
<andrewrk> in this case, however, even the example `init(&.{ "lol", abc, "test" });` would require that `&` there, if `abc` was a local variable
<daurnimator> andrewrk: if the null-ness of a string literal is never used; could we avoid storing it twice?
<andrewrk> what's an example of storing it twice?
<daurnimator> e.g. `const a = "foo"; const b = "bar"; const c = a ++ b; fn myfunc(x: []const u8) void; myfunc(a); myfunc(b); myfunc(c);`
<daurnimator> we wouldn't need to actually store "foo", "bar" and "foobar" as strings in the binary: just "foobar" and `a` and `b` could be pointers into that
<andrewrk> a and b already de-dupe; tests would break otherwise. the ++ example is planned to de-dupe already, regardless of null termination, but not currently implemented
<daurnimator> huh?
<daurnimator> how would a and b dedupe?
<daurnimator> b and c could...
<andrewrk> sorry, I misread; assumed a and b were being assigned the same value
<daurnimator> but if null-termination of `a` was ever used, then you couldn't dedupe `a` and `c`
<andrewrk> I see your point now
<daurnimator> option 1. concatenation and some other comptime operations would need to "poison" a comptime variable as un-dedupable. option 2. we do a big deduping at the end as part of linking or something which could even cover complex comptime transformations that end up duplicates
<daurnimator> However even for option 2 I think we'd need a flag of "null termination used"
<andrewrk> this problem is fun to think about but I suspect it doesn't matter in practice
<andrewrk> I gotta go to bed, trying to fix my sleep schedule. good night. hope to catch up on PRs this week
<daurnimator> yeah I can only see it mattering for big embedded pieces with slight variations. maybe shaders? or if we embed icons or something? but yeah. might just YAGNI for now
<daurnimator> andrewrk: night :)
* daurnimator crosses fingers for fifo review
adamkowalski has quit [Ping timeout: 276 seconds]
<mq32> daurnimator, you're actually hitting a pretty good spot there with deduping
jjido has joined #zig
<mq32> we have to fight "small memory" all the time at work and do a lot of work to save all memory possible
<daurnimator> mq32: maybe its something you want to work on for zig then? :)
<mq32> not yet, i couldn't convince my colleagues to try zig :D
<mq32> and i'm the only non-embdedded dev :D
<daurnimator> mq32: then get zig running on a work device during your lunch time
<mq32> that's my plan, actually
<mq32> but i'm blocked on that
<daurnimator> mq32: eventually you'll have a question for your embedded developer peers.... and then "ooh whats that you're using"
<mq32> haha
<mq32> they already know that i evangelize zig use :D
<daurnimator> you gotta be more subtle ;)
<daurnimator> inception strats
<mq32> i'm still waiting for https://github.com/ziglang/zig/issues/661 to continue working on my ARM project
return0e has joined #zig
<mq32> as i require "ARM interrupt" calling convention
adamkowalski has joined #zig
<mq32> got to go
adamkowalski has quit [Ping timeout: 240 seconds]
<daurnimator> mq32: you can do anything with the naked calling convention and some inline asm :)
<daurnimator> (its awkward; but should be enough to get yourself unblocked)
adamkowalski has joined #zig
jjido has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
adamkowalski has quit [Ping timeout: 265 seconds]
adamkowalski has joined #zig
adamkowalski has quit [Ping timeout: 240 seconds]
adamkowalski has joined #zig
adamkowalski has quit [Ping timeout: 250 seconds]
Ichorio_ has quit [Ping timeout: 250 seconds]
<mq32> yeah, that's my plan for now
<mq32> but i'm focusing on the ZGS right now :)
<mq32> still searching for that weird "everything explodes" bug
<mq32> have to implement more memory security than "you can write any address you like"
<mq32> because it looks like something weird happens when assembling instructions with 3 operands
<mq32> as in "i get protection faults"
FireFox317 has joined #zig
FireFox317 has quit [Remote host closed the connection]
bjorob has joined #zig
return0e has quit [Remote host closed the connection]
return0e has joined #zig
return0e has quit [Ping timeout: 240 seconds]
bjorob has quit [Ping timeout: 240 seconds]
adamkowalski has joined #zig
adamkowalski has quit [Ping timeout: 276 seconds]
adamkowalski has joined #zig
adamkowalski has quit [Ping timeout: 240 seconds]
adamkowalski has joined #zig
adamkowalski has quit [Ping timeout: 240 seconds]
adamkowalski has joined #zig
adamkowalski has quit [Ping timeout: 240 seconds]
adamkowalski has joined #zig
adamkowalski has quit [Ping timeout: 252 seconds]
adamkowalski has joined #zig
kenaryn has joined #zig
forgot-password has joined #zig
<kenaryn> Hello, please what does it mean the variable's name 'amt'? It can be seen in tcp server livestream (i.e. `const amt = try self.file.read(&buf);`)
<forgot-password> Probably amount?
adamkowalski has quit [Ping timeout: 240 seconds]
<forgot-password> I'd guess it is the amount of bytes that were actualy read
<forgot-password> actually*
<kenaryn> I thank you.
adamkowalski has joined #zig
adamkowalski has quit [Ping timeout: 250 seconds]
adamkowalski has joined #zig
adamkowalski has quit [Ping timeout: 240 seconds]
Ichorio has joined #zig
adamkowalski has joined #zig
adamkowalski has quit [Ping timeout: 246 seconds]
<kenaryn> Is it DragonFlyBSD during Andrew's live streams? I do not recognize the desktop environment.
<daurnimator> kenaryn: he uses nixos. not sure what DE
adamkowalski has joined #zig
adamkowalski has quit [Ping timeout: 240 seconds]
forgot-password has quit [Ping timeout: 245 seconds]
<kenaryn> Thank you. Do you recommend it over Debian stable?
adamkowalski has joined #zig
<daurnimator> I don't use it
<daurnimator> And it all depends on what you want
adamkowalski has quit [Ping timeout: 265 seconds]
<kenaryn> I don't like much the dependencies's management on Debian, and there too many packages installed. I just saw NixOS use only X11 and Plasma 5, so I would have to abandon Xfce. Not a big deal I suppose.
adamkowalski has joined #zig
<daurnimator> "too many packages installed" <== what do you mean by that and why does it matter
<kenaryn> I have currently 1884 packages for about 5% used. I have no control over the system.
adamkowalski has quit [Ping timeout: 265 seconds]
adamkowalski has joined #zig
<daurnimator> kenaryn: you can't include dependant packages when you say that sort of thing
<daurnimator> kenaryn: I think `apt-mark showmanual` will show you things you have installed explicitly
<mq32> <kenaryn> I just saw NixOS use only X11 and Plasma 5, so I would have to abandon Xfce
<mq32> nixos is highly configurable
adamkowalski has quit [Ping timeout: 252 seconds]
<mq32> i have a setup with nixos, lightdm login manager and i3 for window manager, no desktop manager
<mq32> it really depends on what you want to do, nixos may be a pain or a relieve
adamkowalski has joined #zig
adamkowalski has quit [Ping timeout: 252 seconds]
adamkowalski has joined #zig
adamkowalski has quit [Ping timeout: 240 seconds]
forgot-password has joined #zig
adamkowalski has joined #zig
return0e has joined #zig
adamkowalski has quit [Ping timeout: 276 seconds]
return0e has quit [Remote host closed the connection]
return0e has joined #zig
adamkowalski has joined #zig
return0e has quit [Ping timeout: 240 seconds]
return0e has joined #zig
adamkowalski has quit [Ping timeout: 265 seconds]
adamkowalski has joined #zig
adamkowalski has quit [Ping timeout: 240 seconds]
adamkowalski has joined #zig
adamkowalski has quit [Ping timeout: 240 seconds]
dingenskirchen has quit [Quit: dingenskirchen]
dingenskirchen has joined #zig
sammich has quit [Quit: https://quassel-irc.org - Chat comfortably. Anywhere.]
adamkowalski has joined #zig
sammich has joined #zig
sammich has quit [Read error: Connection reset by peer]
adamkowalski has quit [Ping timeout: 245 seconds]
sammich has joined #zig
sammich has quit [Read error: Connection reset by peer]
adamkowalski has joined #zig
sammich has joined #zig
FireFox317 has joined #zig
<FireFox317> gruebite: Do you mind if I add the PR for the compiler bug we had yesterday?
adamkowalski has quit [Ping timeout: 240 seconds]
adamkowalski has joined #zig
adamkowalski has quit [Ping timeout: 276 seconds]
adamkowalski has joined #zig
adamkowalski has quit [Ping timeout: 252 seconds]
adamkowalski has joined #zig
adamkowalski has quit [Ping timeout: 240 seconds]
FireFox317 has quit [Remote host closed the connection]
adamkowalski has joined #zig
dimenus|work has joined #zig
adamkowalski has quit [Ping timeout: 276 seconds]
adamkowalski has joined #zig
dimenus is now known as Guest46760
Guest46760 has quit [Killed (cherryh.freenode.net (Nickname regained by services))]
dimenus|work is now known as dimenus
Guest46760 has joined #zig
adamkowalski has quit [Ping timeout: 240 seconds]
adamkowalski has joined #zig
FireFox317 has joined #zig
adamkowalski has quit [Ping timeout: 240 seconds]
<FireFox317> mikdusan: corner case: `var x: u0 = 0; switch (x) {};` : This shouldn't generate any code right? Because I'm not sure what this actually means to switch on a u0 and not put anything in the block. When you do `switch(x){ 0 => <something>}` that I see, but without anything in the switch statement it shouldn't generate any code right?
adamkowalski has joined #zig
<FireFox317> Or if someone else wants to clarify
dimenus has quit [Remote host closed the connection]
adamkowalski has quit [Ping timeout: 240 seconds]
waleee-cl has joined #zig
dimenus has joined #zig
adamkowalski has joined #zig
adamkowalski has quit [Ping timeout: 252 seconds]
adamkowalski has joined #zig
kenaryn has quit [Quit: WeeChat 2.3]
Ichorio has quit [Ping timeout: 245 seconds]
FireFox317 has quit [Ping timeout: 276 seconds]
adamkowalski has quit [Ping timeout: 265 seconds]
adamkowalski has joined #zig
[rg] has joined #zig
<[rg]> looking good boys
Ichorio has joined #zig
FireFox317 has joined #zig
<dimenus> daurnimator: woudl it be accurate to see that @as cannot coerce a type into a smaller type
<dimenus> *?
adamkowalski has quit [Quit: Lost terminal]
<mq32> dimenus: @as can only widen a type, not narrow it
<mq32> for narrowing, an @intCast is required
<dimenus> agreed, i'm referring to this issue https://github.com/ziglang/zig/issues/3724
<dimenus> the error that it currently generates is not helpful, i'm just looking to clarify that my understanding of as is correct
<mq32> ah!
<mq32> yeah, a better errorr message would be helpful
dtz has quit [Ping timeout: 250 seconds]
[rg] has quit [Remote host closed the connection]
wilsonk has quit [Ping timeout: 252 seconds]
<FireFox317> 'var x: u0 = 0; switch (x) {}' With my patch this reaches unreachable code, is that correct behavior?
wilsonk has joined #zig
wilsonk has quit [Ping timeout: 250 seconds]
wilsonk has joined #zig
<gruebite> FireFox317: no go ahead
<gruebite> I got distracted last night -.-
<gruebite> Can I get a link to it?
forgot-password has quit [Ping timeout: 246 seconds]
FireFox317 has quit [Remote host closed the connection]
FireFox317 has joined #zig
<FireFox317> gruebite: Yes, but I just want to make sure this is the correct behavior before making the PR. andrewrk? 'var x: u0 = 0; switch (x) {}' With the current changes that I currently have, this generates unreachable code and 'var x: u8 = 0; switch (x) {}' correctly outputs a compile error 'switch must handle all possibilities'.
<gruebite> by "generates unreachable code" do you mean it is optimized away into nothing?
<gruebite> it's a no-op?
<FireFox317> in debug mode I get a 'reached unreachable code' runtime error. But I'm just not understanding what switching on a u0 really means
<gruebite> yeah
<FireFox317> mikdusan yesterday mentioned that `var x: u0 = 0; switch (x) {}` is a corner case, but I don't get why. I think you still need to specify one case, namely `var x: u0 = 0; switch (x) {0 => <something>}`
<gruebite> which wouldn't even be a switch, it would just do the thing
<gruebite> `var x: u0 = 0; <something>`
<gruebite> yeah, i'm not so sure what that means either
<gruebite> switching on a zero sized integer
<FireFox317> Yes indeed, there is only one possibility
quetzalb has joined #zig
reductum has joined #zig
mahmudov has joined #zig
Ichorio has quit [Ping timeout: 245 seconds]
<mikdusan> FireFox317: i mentioned it was a corner case because it also crashed stage1; I don't really have any rational thoughts on if zig should accept that or require case for always-one-value
<mikdusan> i guess it is different from an empty errorset; an empty error set is truly nothing, where u0 is always 0?
<FireFox317> Yes I think that is correct, the only thing you can store in a u0 is a 0, nothing else.
<mikdusan> it seems to me maybe we actually desire to emit an error for u0 `switch (x) {}`. it seems to work fine for cases: 0 is allowed, else is allowed, anything but 0 emits proper error
<gruebite> so it's a like a single element error set?
<mikdusan> it's like a single-field enum too
<mikdusan> is there an issue open for this?
<gruebite> no, encountered this while writing some bindings
<gruebite> i don't think there is at least
wootehfoot has joined #zig
<FireFox317> I just added a PR (https://github.com/ziglang/zig/pull/3734), this is a fix for integers
<FireFox317> mikdusan: Yes indeed, currently it is possible to have the 0 case and else for a u0, but that shouldn't be possible
<gruebite> i still feel like multiline strings are not ergonomic
<gruebite> looking at the test case in the pr, unfamiliar with the testing stuff
<gruebite> i think switching on u0 should be an error? it doesn't make sense
<gruebite> it's likea if (unit_type) { .. }
<gruebite> i like lua's multiline strings, since they can have arbitrary escaping power
<gruebite> [=====[ [====[ ]] ]]
<gruebite> could do something like `/--/ multiline comment/string //`
<mikdusan> hmm how does one get an instance of an empty errorset?
<FireFox317> I think for now, the PR that i added is fine. There is not really a use case for u0 anyway
<gruebite> or `/**/ //`
<FireFox317> mikdusan: something like defining a function with an error empty and then catch on the function call and you have an instance of the empty error set?
<mikdusan> i'll try that
<gruebite> also, this is really cool. would zig support something like this? http://odin-lang.org/docs/overview/#implicit-context-system
<FireFox317> gruebite: implicit is no good for zig
<gruebite> seems to cover a lot of the issues that dependency injection is aimed at solving. or cross-domain modules like logging/errors/etc
<gruebite> ahh right
<gruebite> :D
<gruebite> i like that, it's tough passing around logging handles and stuff around everywhere though
<mikdusan> FireFox317: yeah integers/empty-switch seem to be the only crasher. { void, bool, error set, enum } don't crash.
<FireFox317> Okay good, so I don't have to adjust my PR :)
<gruebite> :)
return0e has quit []
Ichorio has joined #zig
qazo_ has quit [Quit: ...]
<gonz_> Does anyone here use the IntelliJ zig plugin?
<gonz_> It seems really out of date and I'm basically just wondering if maybe someone has set up their own stuff to make up for it.
lunamn has joined #zig
forgot-password has joined #zig
<gonz_> I already have reasonable solutions for zig support in editors but it would still be interesting to have IntelliJ as an alternative.
quetzalb has quit [Remote host closed the connection]
<andrewrk> mikdusan, I'd be interested in merging your branch that unembeds ConstExprValue from IrInstruction, even though it increases mem usage a bit
<andrewrk> I'm certain this needs to happen from a data layout perspective, regardless of what we do for improving memory usage in the future
<andrewrk> gotta climb up that global maximum
halbeno_ has joined #zig
halbeno has quit [Ping timeout: 268 seconds]
return0e has joined #zig
doublex is now known as doublex_
forgot-password has quit [Ping timeout: 276 seconds]
casaca has joined #zig
<andrewrk> fengb, your PR for wasmtime is good, will merge soon. btw, it is my current belief that implementing a wasi interpreter is in scope of the zig project
<fengb> 👍
<fengb> The guy from wasmer wants to interject lol
<fengb> I've kicked around the idea of implementing an interpreter
<andrewrk> 95% of the work is done, it's the cross platform abstractions of the zig standard library. and zig already has to be able to output web assembly. a simple interpreter would allow `zig test` to test web-assembly-specific code
<fengb> Ah, hook it directly into the compiler?
<andrewrk> yes, I don't see why not
<fengb> So basically it'd compile wasm down to LLVM IR?
<andrewrk> one of the features zig provides is as a "base dependency" that can eliminate other dependencies, or otherwise bring them in reliably and consistently across platforms
<andrewrk> I think this feature is generally undervalued. but this is what makes things "just work"
<andrewrk> clearly, it's possible to go to far- zig can't and shouldn't do everything. but there's a lot of value in the fact that it insulates you to differences across platforms
<andrewrk> *too far
forgot-password has joined #zig
<wilsonk> gonz_: what support do you have for zig in which editors, btw? I think the IntelliJ plugin is rotting as the maintainer is busy and waiting for the language changes to settle down (can't remember where I read that, but I am pretty sure that is the case).
bjorob has joined #zig
<wilsonk> I think vim/emacs/intellij/vscode all have some support...with vscode being the best. They all have syntax highlighting and vscode also has some support for code completion with ceymards plugin. I set up flycheck in emacs for actual syntax checking and it works nicely (ie. live update of syntax errors on each key press because 'zig fmt' runs so fast).
<wilsonk> btw gonz_, you can also try the TabNine deep learning code completer in vscode...it is easy to install and it actually works ok. Interesting to try out at least. Works well on Linux, but apparently is a mem/cpu hog on Mac OS and Win.
<gonz_> Yeah, I already use vim-zig & VSCode (also TabNine)
<gonz_> so no news there, really
<gonz_> I was mostly curious about the IntelliJ status
<wilsonk> Ah, ok...didn't realize you already knew about the others
<wilsonk> Have you used hoodie with vscode gonz_?
<gonz_> Not really, no. I should probably clarify; I'm not displeased with the support in VSCode
<wilsonk> ah, ok cool...I just like the one hoodie feature that allows you to click on any test and it will run in the terminal (at least I think that is only a hoodie feature...been a while since I used vscode)
<andrewrk> that's a neat feature, I wasn't aware of that
<wilsonk> yeah, it is nice...only issue is that hoodie has rotted a little and I had to revert the compiler back a few months to get it to compile
<andrewrk> personally, I am invested in a great IDE experience but I am resigned to the fact that we will not have it until the language is stable
<andrewrk> so that's why I'm allowing the bug count to get uncomfortably high, I think stabilizing the language is step 1 in the most efficient path toward 1.0
<wilsonk> ah, I see...I was a little curious about that actually. Good to hear the rational on that one :)
ltriant has joined #zig
wootehfoot has quit [Quit: pillow time]
<scientes> yes, getting the language stable is #1
<scientes> like the anonymous functions change
<Snektron> is there some kind of roadmap to 1.0 or is it just "when its done"?
FireFox317 has quit [Remote host closed the connection]
FireFox317 has joined #zig
<andrewrk> Snektron, accepted proposals on github issues
<andrewrk> most of them are not big language changes
FireFox317 has quit [Remote host closed the connection]
protty has joined #zig
<mq32> andrewrk, do you do any kind of "reachable analysis" for references variables?
<mq32> it looks like i can fix a bug by referencing a variable in my main function
<andrewrk> mq32, not yet
<andrewrk> is it a global variable?
<mq32> hmm
<mq32> yes
<mq32> it looks like my code is executing some stack memory or something
<andrewrk> globals are not even semantically analyzed unless referenced
<mq32> yeah, it is referenced
<mq32> but only "passive"
<mq32> so in a function that never gets called, but only it's address is taken
<mq32> and that kind of indirection three times :D
<mgxm> wilsonk: cool, do you mind sharing it? (flycheck)
<wilsonk> mgxm: sure one second
protty has quit [Ping timeout: 260 seconds]
<mq32> okay, this is really strange
<mq32> my bug gets fixed by a "print" statement
<mq32> more precise
<mq32> _ = userStack;
<mq32> this is my bugfix
<mq32> i put this statement into main, now it works
<mq32> if i remove that, it will stop working
* mq32 looks a bit irritated
<fengb> Yeah that's the way to force it into existence
<fengb> Otherwise it gets lazily ignored
<mq32> fengb, yeah, i know that
<mq32> that's why i tried that
<mq32> but i reference that variable in other code pieces
<wilsonk> mgxm: you also have to add zigfmt to the 'fly-checkers' quoted list!
<wilsonk> mgxm: if you want a few other things for emacs (or spacemacs, as that is what I use) then I could paste other goodies...like auto zig formatting on save, compilation window pop-up and removal upon success...also jump to first error upon compilation failure. Things like that
<mq32> it's really weird, i have two ideas what may happen:
<mgxm> wilsonk: thanks
<mgxm> oh, cool
<mq32> 1: compiler messes up stuff and code "slides" into that variable
<mq32> 2: the variable doesn't get emit, but i can see it in the objectfile
<mgxm> I sent a pr to the zig-mode repo with some improvements, including the fmt
<mgxm> Iḿ reading the cc-mode right now, trying to master the beast :)
<wilsonk> sounds good :)
protty has joined #zig
Ichorio has quit [Ping timeout: 250 seconds]
<wilsonk> mgxm: here is the more comprehensive emacs-list file https://pastebin.com/2bTAVxuS There are a few error-correcting lines for elpa/persp-mode/github near the top and then the compilation stuff. The LSP section is for c++/python and can be setup for zig once we have something working (hoodie does hook up but it isn't really fleshed out for code-completion yet, so it doesn't really do much in emacs...more for vscode).'
<wilsonk> There is also a section for TabNine deep learning code-completion but it is a little hit and miss in emacs...actually more miss than hit but it ismuch better in vscode!
dimenus has quit [Quit: Leaving]
traviss has quit [Quit: Leaving]
protty has quit [Remote host closed the connection]
mahmudov has quit [Remote host closed the connection]