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/
ur5us has joined #zig
a92 has joined #zig
AceNovo has quit [Quit: Konversation terminated!]
AceNovo has joined #zig
omglasers2 has quit [Read error: Connection reset by peer]
lkurusa has joined #zig
kristoff_it has quit [Ping timeout: 260 seconds]
Kingsquee has joined #zig
a_chou has joined #zig
a_chou has quit [Remote host closed the connection]
AceNovo has quit [Quit: Konversation terminated!]
AceNovo has joined #zig
a92 has quit [Quit: My presence will now cease]
adamkowalski has joined #zig
<adamkowalski> how does zig define intrinsics? like adding two ints or floats?
<adamkowalski> and how are ints themselves defined?
<adamkowalski> is there a way to create a "primitive" type which has some number of bits?
<adamkowalski> or
<adamkowalski> is there some internal notion of i64 built into the compiler? and when you type x + y some compiler logic kicks in?
<g-w1> you could use @Type to create a type
<adamkowalski> well yeah but I mean the "builtin types" are those actually built into the compiler?
<adamkowalski> or is there some core zig module which defines them, and then it gets implictly imported into every other module?
<adamkowalski> so i64 i32 bool etc
<g-w1> I dont think so. const x: u5 = 2; works. any width intger types (should) work
<adamkowalski> well but the question still holds right
<adamkowalski> where did all these types get defined
<adamkowalski> Are they implictily defined by the compiler?
<adamkowalski> and how does addition/multiplication etc work for all them
<adamkowalski> clearly + is a polymorphic function right?
<adamkowalski> but can we create our own version? or is it built in with compiler magic
<g-w1> I think zig is unlike other langs in that nothing is automatically imported (correct me if im wrong). since nothing can be overloaded, im pretty sure that * and + are just built in to the compiler and that they can operate on any integer/float/vector type.
<adamkowalski> ahh I see, yeah thats what I thought
<adamkowalski> i'm making a language for learning purposes and am trying to tackle that problem
<adamkowalski> I've been thinking that I want as little as possible to be built into the compiler
<adamkowalski> so i've been debating making it possible to just say (let u8 (primitive 8)) which defines u8 as a type which is 8 bytes
<g-w1> that seems cool
<adamkowalski> then you can overload + on that type, and call a compiler intrinsic add-u8 or something
<adamkowalski> but I wanted to know how Zig tackles that
x2C25 has joined #zig
<g-w1> imo and zigs, operator overloading makes things VERY confusing (this is why i can't read haskell)
<adamkowalski> i'm designing a lisp, so I don't actually have operators
<adamkowalski> everything is just functions, but you can overload them
<g-w1> ah
<adamkowalski> (+ (* 3 4) 5)
<adamkowalski> precedence is always obvious
<adamkowalski> and since it's primary purpose is as a numeric / linear algebra language then overloading is nice
<adamkowalski> (+ 3 [1 2 3])
<adamkowalski> will give
<adamkowalski> [4 5 6]
<adamkowalski> elementwise addition of scalar 3 and vector [1 2 3]
<adamkowalski> otherwise you need functions for add i64, i64. add i64, vec of i64, add i64 mat of i64
<adamkowalski> you think thats more readable?
<adamkowalski> all possible permutations of add?
<Snektron> the problem with operator overloading is that it adds overloading in general to the language
<adamkowalski> honestly curious, since i'm trying to figure it whats the right path forward
<Snektron> this makes it a lot more complex
<adamkowalski> zig has overloading too, just not obvious
<Snektron> before you know it you'll have people wanting to refer to operators as functions, and now you suddenly need a way to disambiguate functions by parameter type
<adamkowalski> if I have two structs, they can both have a function with the same name
<adamkowalski> so a function name can refer to different things depending on the subject
<adamkowalski> foo.bar()
<Snektron> those would still have a different name, X.func and Y.func
<adamkowalski> not really
<adamkowalski> it's syntactic sugar over func(x) and func(y)
<adamkowalski> then depending on x or y you dispatch to a differnt function
<Snektron> it is, but they are namespaced by X and Y respectively
<adamkowalski> if you have func(x, y) you can say it's static dispatch over the type of both x and y
<adamkowalski> neither "owns" it
<Snektron> i can refer to either function uniquely given just the name and the struct(s) it appears in
<adamkowalski> who owns adding a matrix and a scalar?
<Snektron> the module where you define it in
<adamkowalski> okay suppose you are right
<adamkowalski> if we go back to the numeric examples
<adamkowalski> how do you suppose you deal with adding/multiplying/subtracting matrices/vectors/scalars
<adamkowalski> and all possible combinations of them
<adamkowalski> matrix * vector gives a matrix
<Snektron> i agree with you that its messy to have no operator overloading for mathematical types
<adamkowalski> vector * scalar gives vector
<adamkowalski> scalar * scalar gives scalar
<adamkowalski> if you cover all those use cases
<adamkowalski> now you get into dense vs sparse matrices
<Snektron> i'm just saying that operator overloading adds a lot more complexity to the language, so such a feature must be well considered
<adamkowalski> yeah I agree it adds complexity, but I'm curious what is the alternative?
<Snektron> of course, you can emulate 'overloading' in zig by creating a generic function and inspecting parameter types
<Snektron> for operators that would need some intricate interplay between compiler and code though
<adamkowalski> true
<adamkowalski> but I don't like that becuase it's not open to extension
<adamkowalski> suppose you now came about and came up with a sparse symmetic matrix
<adamkowalski> symmetric*
<Snektron> well the obvious alternative is to define your function as 'add' and stuff. I'm not happy with it though
<adamkowalski> right so now we need to know whether we are dealing with a user defined type or a built in
<adamkowalski> if it's builtin, use +
<adamkowalski> otherwise use user.add
<adamkowalski> now I want to write a generic library
<fengb> Common Lisp has multi methods
<adamkowalski> that works with anything as long as it is a matrix
<adamkowalski> i don't care if it's sparse, dense, on the gpu, cpu, whatever
<fengb> Dispatch is based on name and type
<adamkowalski> I just care thats it is random access and contains floats
<fengb> Erlang too
<Snektron> One method would be to allow defining operators as member functions only. This solves the 'overloading' part
<adamkowalski> multi methods and overloading are the samething
<Snektron> but now you can't 'overload' <builtin> and <custom type>
<adamkowalski> just one is runtime, other is compile time
<adamkowalski> yeah exactly snektron
<adamkowalski> only solution which truely is generic is overloading
<adamkowalski> and having something akin to concepts
<adamkowalski> i want to accept ANY type as long as it acts like a matrix, and I can add it
<adamkowalski> user defined, built in, it's all good
<adamkowalski> and if you didn't implement add for your matrix
<adamkowalski> I shouldn't have to create a wrapper type
<adamkowalski> I should just implement + for your matrix type
<adamkowalski> and now I can use it with the generic algorithm
xackus has quit [Read error: Connection reset by peer]
<adamkowalski> because the compile time constraints are met
xackus_ has joined #zig
<adamkowalski> unless I'm missing something
<adamkowalski> I've been thinking about this for weeks, and can't think of a better way
<adamkowalski> every other solution seems to introduce coupling between types and functions
<Snektron> I think sadly the best way is to just bite the bullet and use .add
<adamkowalski> either you can add new types, but they won't work with exising functions
<adamkowalski> or you end up with a bunch of hacks, which seem worse then the overloading we wanted to get away from
xackus__ has joined #zig
earnestly has quit [Ping timeout: 256 seconds]
<adamkowalski> nobody will use my language if they need to write .add everywhere though
<Snektron> there are quite a few languages which seem to do fine without operator overloading
xackus_ has quit [Read error: Connection reset by peer]
<adamkowalski> (+ x (* y z))
<Snektron> if your use case is that math heavy, maybe some kind of dsl is in order?
<g-w1> i found out that you can do obj.@"+="(other_obj); this is pretty cool
<g-w1> in zig
<adamkowalski> or (x.add (y.times z))
<adamkowalski> why does x and y "own" the add and times methods respectively
<adamkowalski> neither the left hand or the right hand own in my opion
<companion_cube> are you doing multiple dispatch?
<adamkowalski> at compile time yeah
<adamkowalski> if you do a dense matrix * a sparse matrix
<adamkowalski> you should clearly do something different, then a sparse * sparse
<adamkowalski> and different then dense * dense
<companion_cube> it's what julia does, I think
<adamkowalski> AND you want to keep a graph of all the operations that you performed
<adamkowalski> because you need to take derivatives of the entire computation
<adamkowalski> thats how tensorflow/pytorch/jax/flux all do deep learning
<adamkowalski> I want to build that graph at compile time
<adamkowalski> because when you lower the AST into SSA form it's essentially a computation graph
<companion_cube> seems far too magical for zig :p
<adamkowalski> then you just walk the SSA in reverse order and call the derivative function
<companion_cube> well, you can use functions to build the AST to symbolically derive, I guess
<adamkowalski> hence the need for the new language haha
<adamkowalski> it's not quite symbolic
<adamkowalski> it's reverse mode automatic diff
<adamkowalski> every function takes in the gradient thus far, and the arguments that you used on the forward pass
<adamkowalski> then you compute your portion of the gradient
<adamkowalski> and send back to the nodes connected to you
<companion_cube> all arguments will have to be explicit anyway
xackus__ has quit [Ping timeout: 260 seconds]
xackus has joined #zig
frmdstryr has quit [Ping timeout: 240 seconds]
Ankhers has joined #zig
mmohammadi9812 has quit [Ping timeout: 272 seconds]
adamkowalski has quit [Quit: Lost terminal]
kristoff_it has joined #zig
mmohammadi9812 has joined #zig
xackus_ has joined #zig
<g-w1> is the zig build dirname loop going to be patched in 0.7.1?
xackus has quit [Ping timeout: 256 seconds]
GrooveStomp has quit [Remote host closed the connection]
GrooveStomp has joined #zig
<andrewrk> yeah
<andrewrk> feel free to request something else (bug fixes only)
ur5us has quit [Ping timeout: 265 seconds]
GrooveStomp_ has joined #zig
GrooveStomp has quit [Ping timeout: 256 seconds]
plakband has joined #zig
goldcell has joined #zig
jijii has joined #zig
jijii has quit [Remote host closed the connection]
marnix has joined #zig
marnix has quit [Read error: Connection reset by peer]
marnix has joined #zig
waleee-cl has quit [Quit: Connection closed for inactivity]
teratorn has joined #zig
<teratorn> how do you parameterize a fn to take a variable length array?
jjsullivan1 has quit [Remote host closed the connection]
jjsullivan1 has joined #zig
kristoff_it has quit [Ping timeout: 240 seconds]
plakband has quit [Quit: WeeChat 2.9]
xackus_ has quit [Ping timeout: 260 seconds]
cole-h has quit [Quit: Goodbye]
cole-h has joined #zig
AceNovo has quit [Quit: Konversation terminated!]
AceNovo has joined #zig
AceNovo has quit [Quit: Konversation terminated!]
AceNovo has joined #zig
factormystic2 has joined #zig
factormystic has quit [Ping timeout: 240 seconds]
factormystic2 is now known as factormystic
skuzzymiglet has joined #zig
skuzzymiglet has quit [Ping timeout: 260 seconds]
lucid_0x80 has joined #zig
lucid_0x80 has quit [Remote host closed the connection]
Ashpool has quit [Ping timeout: 258 seconds]
kristoff_it has joined #zig
Ashpool has joined #zig
data-man has joined #zig
ur5us has joined #zig
[RMS] has quit [Ping timeout: 240 seconds]
<data-man> Congratulations on the 0.7.0 release!
<goldcell> yeah congrats :]
<goldcell> the release party stream was cool, saw some replay
[RMS] has joined #zig
<alexnask[m]> Yeah it was a tonne of fun
<alexnask[m]> So many cool little showcases :)
<ikskuh> oh yeah!
<ikskuh> heya alexnask[m], goldcell! o/
<alexnask[m]> morning ;)
<goldcell> I've been following zig's progress so it was nice to see, the bootstrap project got me really curious
<novaskell> the ziguana drawings were great
data-man has quit [Quit: Konversation terminated!]
<alexnask[m]> Bow to your King 👑
AceNovo has quit [Quit: Konversation terminated!]
AceNovo has joined #zig
goldcell has quit [Quit: Konversation terminated!]
x2C25 has quit [Ping timeout: 260 seconds]
lltt has joined #zig
omglasers2 has joined #zig
marnix has quit [Read error: Connection reset by peer]
marnix has joined #zig
earnestly has joined #zig
<ifreund> teratorn: if the length is comptime known, something like fn foo(comptime N: usize, bar: [N]u8) void
<ifreund> if the length is runtime know you probably want to pass a slice ([]u8) which is a pointer + a length
hnOsmium0001 has quit [Quit: Connection closed for inactivity]
ur5us has quit [Ping timeout: 264 seconds]
osa1 has quit [Ping timeout: 260 seconds]
osa1 has joined #zig
cole-h has quit [Ping timeout: 240 seconds]
tane has joined #zig
gazler has joined #zig
<hch> (re 0.7.1 bugfix suggestions) would asking for a fix of std.build.Builder lib.femit_h bee too much? I was informed it's a regressed feature
AceNovo has quit [Read error: Connection reset by peer]
tane has quit [Remote host closed the connection]
tane has joined #zig
<daurnimator> hch: yes. emit-h is turned off for a release or 2 while we fix other things.
<hch> thanks, got it
<hch> which gh is tracking this?
marnix has quit [Ping timeout: 272 seconds]
marnix has joined #zig
<ifreund> I believe the plan is for femit_h to be integrated with/part of the C backend for the self hosted compiler
marnix has quit [Read error: Connection reset by peer]
marnix has joined #zig
mmohammadi9812 has quit [Quit: Quit]
mmohammadi9812 has joined #zig
Kena has joined #zig
<Kena> Hello, why all of miscompilation labelled issues are targeting 0.9.0 release and none of them are planned to be solved for 0.8.0 branch?
<ikskuh> Kena: probably because 0.8.0 will focus on self-hosted and *maybe* will make the issues obsolete by replacing the compiler
<daurnimator> Kena: I don't know; it could either be a mistake; or andrew decided that stage1 doesn't matter and 0.8.0 is all about stage2
<Kena> Yes I hope you're right, I didn't think of that.
<Kena> If 0.9.0 is all about stage3, it is likely there'll be a 0.10.branch :)
<Kena> RISC-V tier 1 support for all major OS for 1.1.0 lol
frmdstryr has joined #zig
<ifreund> stage3 is just stage2 compiled with stage2
<ifreund> once stage2 is feature complete we have stage3
<ifreund> maybe even slightly before then
<Kena> Then it will language specification forthcoming!
<Kena> *will be
<Kena> which will make the language production-grade perceived by the industry, which will in return mean a new bunch of job opportunities in Zig.
<g-w1> does zig build use multiple cpu cores, and is there a way to only make it use 1, like make -j1?
<daurnimator> no I think; and hence yes, but also no.
<g-w1> ok
<daurnimator> as in: it only uses a single core right now, in future it will use multiple cores; it's not planned to add a flag to limit the number of cores.
<Kena> Then why does the built-in `@Vector(N, T)` was removed? Isn't it the first step to use multiple cores thanks to SIMD mechanism?
<g-w1> this is just for compilation.
<Kena> I do not understand, you mean using generic data structure via `struct` do the same thing at run-time?
<Kena> and therefore enact SIMD capability?
<g-w1> compilation is usually sped up when using multiple cores to compile code. I was asking if multiple cores were planned to be used. this has nothing to do with runtime
<Kena> Yes but my first question with regard to @Vector() remains.
<Kena> isn't a compile-time feature?
<g-w1> i think it is for runtime simd
<novaskell> Kena: the type can be constructed via `@Type()` and thus `@Vector` (iirc) was removed in favour as it's use isn't as common to have a builtin just for that. There are proposals for explicit syntax (`u4x6` or similar) but as far as I know there hasn't been an update on accepting any of them.
<novaskell> same as `@Opaque()` was removed where `@Type(.Opaque)` was suggested as a replacement until opaques with methods `opaque {}` was accepted.
<ifreund> @Vector() is now std.mem.Vector()
<ifreund> s/mem/meta/
wib_jonas has joined #zig
Jahaja has joined #zig
_whitelogger has joined #zig
<Kena> Allright! You're really helpful! Thanks g-w1, novaskell and ifreund
osa1_ has joined #zig
osa1_ has quit [Client Quit]
lucid_0x80 has joined #zig
osa1 has quit [Quit: osa1]
osa1 has joined #zig
neptunepink has joined #zig
osa1 has quit [Quit: osa1]
osa1 has joined #zig
osa1 has quit [Quit: osa1]
osa1 has joined #zig
osa1_ has joined #zig
gazler has quit [Remote host closed the connection]
gazler has joined #zig
tane has quit [Quit: Leaving]
gazler has quit [Remote host closed the connection]
gazler_ has joined #zig
zipp has joined #zig
drazan has quit [Remote host closed the connection]
drazan has joined #zig
donniewest has joined #zig
tane has joined #zig
goldcell has joined #zig
marnix has quit [Read error: Connection reset by peer]
marnix has joined #zig
marnix has quit [Read error: Connection reset by peer]
marnix has joined #zig
<Kena> Does someone know what is the TypeId `BoundFn` represent?
<alexnask[m]> BoundFns are the types of expressions like someObject.someMethod
<Kena> Very nice. So it could be of type @This()?
<g-w1> I don't think. @This() is for structs
<Kena> Ah you're right, that's the type of the innermost struct.
<Kena> alexnask[m] I'm currently watching your "a practical guide to compile-time evaluation" video. You seems like a nice guy and you're talented, even if you describe the code presentend in such a hurry. I hope you'll find a job related to programming.
<alexnask[m]> thanks
<alexnask[m]> Presenting again this w/e ;)
<Kena> On which topic this time?
<Kena> It would be nice to explain in quite layman terms the introspection and reflection mechanisms.
waleee-cl has joined #zig
<Kena> That would help to identify which use cases they can be applied to.
<Kena> s/can/could
<teratorn> ifreund, I'm writing a lib that will expose a C API. Should i just accept like a void* and size_t, like a C API would? or can Zig use a fat pointer type, and expose it for C?
<goldcell> perphaps making printf
<ifreund> teratorn: zig doesn't have a way to expose it's fat pointers (slices) as a C API, you'll want a [*]u8 and usize yeah
<teratorn> ifreund, ok cool
<g-w1> are slices garuneteed to always have the same memory layout?
<ifreund> g-w1: no
<g-w1> ok
<ifreund> teratorn: you can easily convert that to a slice for interal usage as well, just `const slice: []u8 = ptr[0..length];`
<teratorn> cool!
wib_jonas has quit [Quit: Connection closed]
<teratorn> how do you pop an item from an ArrayList?
<teratorn> really a deque would be perfect
<ifreund> teratorn: std.LinearFifo
<ifreund> also ArrayList has a pop() function iirc
<dutchie> std.fifo.LinearFifo
<ifreund> dutchie: thanks :D
<dutchie> and yeah, ArrayList has a pop
<teratorn> are the docs not up to date?
<dutchie> though it's better as a stack than a fifo
<ifreund> teratorn: if you're talking about the generated std docs, no probably not
goldcell has left #zig ["Konversation terminated!"]
<ifreund> I recommend just searching the std source code, its surprisingly readably
<teratorn> yeah fifo would be good. its for a queue of packets that a consuming process will flush out of a decoder
Kena has quit [Remote host closed the connection]
<teratorn> ifreund, cool
hnOsmium0001 has joined #zig
tcsc has joined #zig
solaire has joined #zig
wootehfoot has joined #zig
frmdstryr has quit [Ping timeout: 240 seconds]
frmdstryr has joined #zig
b_jonas has joined #zig
<teratorn> getting error: use of undeclared identifier 'LinearFifo'
<g-w1> are you using LinearFifo as a function or struct? it is a function
<teratorn> i need a struct member of that type
<Nypsie[m]> `std.fifo.LinearFifo(u32, .Dynamic).init(allocator);` for example to create a dynamic list of u32's
<g-w1> ah. const X = struct {fifo: std.fifo.LinearFifo(WhateverTypeYouWantInTheFifo, .Slice)}
<Nypsie[m]> Aah struct membero
<Nypsie[m]> I didn't read :P
<g-w1> the function doesn't init it, but creates a type
<teratorn> cool
<Nypsie[m]> I am aware
<g-w1> I was talking to teratorn
<Nypsie[m]> My bad. I shouldn't be online after work I guess :P
Jahaja is now known as jahaja
<teratorn> so how do you init it?
<g-w1> std.fifo.LinearFifo(u32, .Dynamic).init(allocator);
<teratorn> yes but as a struct memeber
<teratorn> i dont know where i call the init method
<g-w1> add an init function to ur struct and then init it. or just pass an initted fifo to ur struct when u create it
<teratorn> MyStruct { fifo: .init() }
idk has joined #zig
jmiven has quit [Quit: bye]
<g-w1> MyStruct { fifo: std.fifo.LinearFifo(u32, .Dynamic).init(allocator) }
<g-w1> this should work
jmiven has joined #zig
<g-w1> var thing = MyStruct { .fifo = std.fifo.LinearFifo(u32, .Dynamic).init(allocator) }; (ive been writing too much rust :))
<idk> If i use a try statement in a function that returns a value will i have to mark the return value with a "!" because it may return a err?
GrooveStomp_ has quit [Ping timeout: 246 seconds]
<travv0> idk: yep
<idk> so then are there alot of functions in your code that return a "!" value
<g-w1> yes
<idk> also will zig throw an error on compliation if i put a "!" even if the function doesn't throw an error?
<travv0> nope
<idk> oh ok
<scientes> yes it will
<travv0> well maybe for the inferred error set (so just a ! with nothing to the left), not sure about that case
<scientes> it will say "functions that return ! must throw at least one error"
FireFox317 has joined #zig
skuzzymiglet has joined #zig
<scientes> you can lie to it with if (false) return error.NotAnError;
<scientes> however
<idk> nice
<idk> wait so every feature of zig is compiletime or ..?
<scientes> idk, type check is comptime, because zig is a static language
<ikskuh> <scientes> it will say "functions that return ! must throw at least one error"
<ikskuh> not anymore
<ikskuh> that error was removed
<scientes> oh ok
<scientes> my knowledge of zig is based on ~0.6.0 time-frame
<ikskuh> yeah, some stuff changed in the last 6 months :D
idk has quit [Remote host closed the connection]
donniewest has quit [Ping timeout: 260 seconds]
<travv0> i was wondering why it wouldn't just infer an empty error set
Kena has joined #zig
<scientes> travv0, that is irrelevent to the type
<scientes> if there is ! you have to unwrap the error
<scientes> even if it an empty error set
<scientes> well, yeah error set is part of the type...
<travv0> i think you're misunderstanding me
<scientes> when I actually used the error type as they were designed I ran into compiler bugs
<ikskuh> scientes: can you give an example?
<ikskuh> i never encountered compilerbugs
<ikskuh> even withy empty error sets
<scientes> error set merging
<Kena> I have a noobie question. Is caching a desirable effect or is a drawback? Alex state in a video that "anonymous struct literals have a different type at each creation, thus avoiding caching of functions.
<scientes> is unimplemented
<g-w1> do you mean error set merging is unimplimented in stage2?
<scientes> stage1
<ikskuh> can you explain this?
<ikskuh> i use error set merging
<ikskuh> the stdlib uses error set mergin
<scientes> there are a bunch of crashes because it cant compare error sets for equality, et cetera
<g-w1> im thinking of implimenting error set inference in stage2. do you think it would be hard?
<ikskuh> scientes: I see
<ikskuh> "(A||A) == A" is currently false
<scientes> no, its zig_panic("TODO")
<scientes> or at least it was
<ikskuh> i verified that code above
<scientes> oh ok
<ikskuh> must be a very old compiler version
<ikskuh> it worked for as long as i use zig
<scientes> no, this was 0.6.0
<travv0> that's very old in zig time
<ikskuh> 0.6.0: works
<scientes> hmm
<ikskuh> 0.5.0: works
Kena has quit [Remote host closed the connection]
<ikskuh> 0.4.0: works
<travv0> lol do you have all the versions on your machine?
<alexnask[m]> xq are you a zig historian?
<ikskuh> 0.3.0: works
<fengb> All the zigs
<travv0> oh
<travv0> duh
<alexnask[m]> ;)
<ikskuh> funny thing: that code didn't change since 0.3 :D
cole-h has joined #zig
<FireFox317> andrewrk, what is the lock on line 2356 in main.zig supposed to lock? Because currently it is a lock around the manifest file used when linkingWithLLD (i.e. ./zig-cache/h/b2fbb7ee8329c4685737834a259b3cbd.txt). Is this correct?
zipp has quit [Ping timeout: 264 seconds]
<andrewrk> FireFox317, the lock is protecting the `build` executable produced from build.zig
<g-w1> this is probably why zig run fails #6939
<FireFox317> andrewrk, okay thanks. So then what i'm seeing is a bug? I printed the lock and it is saying it is locking ./zig-cache/h/b2fbb7ee8329c4685737834a259b3cbd.txt.
<andrewrk> FireFox317, that .txt file is the file used as the lock to protect the `build` executable
<andrewrk> this would make another `zig build` hang until the lock is released
<FireFox317> andrewrk, yeah exactly that is what i'm trying to solve now
<andrewrk> FireFox317, I think it would make sense to release the lock before executing the child process
<FireFox317> andrewrk, Well now i see the issue, because you can have one instance of `zig build` running then change the underlying build.zig file and then run `zig build` again, and now the two instances use different zig build files. Do we want to protect this situation?
<teratorn> error: container 'std.heap' has no member called 'arena_allocator'
<teratorn> im trying to init an allocator (c allocator would be fine...) ..?
<andrewrk> FireFox317, it's a good question. I think probably the best behavior would be to release the lock just before executing the child process
<andrewrk> since it is common to have long running `zig build run` or similar and expected that they could run at the same time
<FireFox317> andrewrk, okay. But that won't protect for the situation i described above (which i think is a fair trade-off, because otherwise we can't run multiple `zig build` instances at the same time)
<andrewrk> hmm I think there is a new consideration though - with the updated caching behavior, this might actually cause a problem on windows where the exe can't be touched because it is being executed. previously we did not have this situation because hashing the input files was part of the cache namespace
<andrewrk> just brainstorming here, but one possibility would be to copy the `build` executable (which is likely to be small) to a unique file name before executing it, and then release the lock
<andrewrk> this would essentially match the semantics of the old cache behavior but with the performance benefits of the new one
<andrewrk> (in this proposal the unique file name would be based on the hashes of the input files)
<ikskuh> teratorn: std.heap.ArenaAllocator
<alexnask[m]> it could just be the digest, no?
mmohammadi9812 has quit [Ping timeout: 256 seconds]
<ikskuh> what kind of allocator do you want?
<novaskell> teratorn: `std.heap.ArenaAllocator.init(std.heap.page_allocator);` ?
<FireFox317> andrewrk, okay thanks for the information, i'm gonna work on this tonight :)
<FireFox317> I guess it's pretty stupid to change the build.zig file inbetween two running instaces of `zig build` anyway right
<alexnask[m]> users gonna dumb
<andrewrk> FireFox317, ehh not necessarily, maybe one of them is a long running process unrelated to the changes
<teratorn> .\amp.zig:58:55: error: expected type '*std.mem.Allocator', found '*const *std.mem.Allocator'
<teratorn> var alloc = std.heap.ArenaAllocator.init(&std.heap.page_allocator);
<ikskuh> std.heap.page_allocator is already a pointer
<alexnask[m]> std.heap.page_allocator is already a *std.memAllocator
<ikskuh> no need for adressing
<ikskuh> operator
mmohammadi9812 has joined #zig
<FireFox317> andrewrk, alexnask[m], yeah true actually.
<andrewrk> alexnask[m], yeah I'm just suggesting a way to avoid an ever-increasing number of copies every time it is executed - if it is hashed based on something consistent then it will not need to be copied if nothing is changed (or if it matches a previous state)
<teratorn> then i get, .\amp.zig:59:28: error: expected type '*std.mem.Allocator', found 'std.heap.arena_allocator.ArenaAllocator'
<teratorn> var a = AmpDecoder.new(alloc);
donniewest has joined #zig
<andrewrk> teratorn, there is an example of what you are trying to do on https://ziglearn.org/chapter-2/
<novaskell> need to get the allocator from it `&arena.allocator`
<teratorn> i dont understand why zig tells me i have to init a struct member in the definition of the struct
<teratorn> .\amp.zig:27:9: error: variables must be initialized
<teratorn> pub var box_buffer: std.fifo.LinearFifo(AmpBox, .Dynamic);
<teratorn> but if i try to call init() there i get another error
<teratorn> .\amp.zig:27:67: error: expected type 'type', found 'std.fifo.LinearFifo(AmpBox,std.fifo.LinearFifoBufferType { .Dynamic = {}})'
<teratorn> pub var box_buffer: std.fifo.LinearFifo(AmpBox, .Dynamic).init(std.heap.page_allocator);
<g-w1> you want pub var box_buffer = instead of :
FireFox317 has quit [Remote host closed the connection]
FireFox317 has joined #zig
mmohammadi9812 has quit [Ping timeout: 246 seconds]
mmohammadi9812 has joined #zig
mmohammadi9812 has quit [Quit: Quit]
CodeSpelunker has joined #zig
mmohammadi9812 has joined #zig
mixi has quit [Quit: quit]
mixi has joined #zig
<teratorn> in the struct definition??
<g-w1> you dont use var to declare struct members, you use it to declare variables inside structs
GrooveStomp has joined #zig
lucid_0x80 has quit [Ping timeout: 256 seconds]
FireFox317 has quit [Read error: Connection reset by peer]
ur5us has joined #zig
FireFox317 has joined #zig
_commonlylen has quit [Ping timeout: 260 seconds]
osa1_ has quit [Ping timeout: 272 seconds]
<FireFox317> andrewrk, I just implemented it for linux and tried to do it for windows, however there is different issue which i cannot debug since i have no debug version of zig on windows :(
<andrewrk> FireFox317, I have good news on that front - give me a minute and I'll explain
data-man has joined #zig
<teratorn> g-w1, in the struct definition??
<teratorn> g-w1, i thought you used ":" there between var name and type
<g-w1> could you send a little mode code? I can't really understand what you are trying to do
<teratorn> declare a LinearFifo in a struct def
<teratorn> thats all
<teratorn> with c_allocator if possible
<teratorn> and initialize it where and how im not sure
<data-man> Zig topic on GH https://github.com/github/explore/pull/1955 Comments and corrections are welcome!
<g-w1> ah `const P = struct { lfifo: std.fifo.LinearFifo(u8, .Dynamic), }; var thing: P = P { .lfifo = std.fifo.LinearFifo(u8, .Dynamic).init(alloc) };` teratorn, does this make sense
data-man has quit [Client Quit]
<teratorn> g-w1, makes sense ill try it
<teratorn> thx
<teratorn> it doesnt compile on 0.7.0
<teratorn> afaict im doing it as suggested
<teratorn> is there an online web compiler / pastebin for zig?
<g-w1> godbolt.org
<ugla> teratorn: looks like you want that variable to be a struct field.
<ugla> Both of them I guess
<g-w1> teratorn, this still doesn't compile, but its better than what you hard before. i dont know where you are getting ptr[0..size]. https://hastebin.com/suhixehuli.rust
<g-w1> s/hard/had
<justin_smith> that declaration for box_buffer - is LinearFifo supposed to be returning its type?
<teratorn> i think yes
<teratorn> its a fn that returns a type?
<andrewrk> FireFox317, so now with zig-bootstrap we could distribute a "work on zig" tarball which includes zig, lld libraries, clang libraries, llvm libraries, and then you could build zig from source using zig cc and this will give you * no MSVC needed to be installed * release LLVM + debug zig
jjsullivan1 has quit [Remote host closed the connection]
jjsullivan1 has joined #zig
<Snektron> that would be pretty great
<ikskuh> yes, indeed
<alexnask[m]> Is release LLVM + debug zig possible? I thought on windows the libcs had to match (in both dynamic vs static linking and build mode)
<andrewrk> it's an msvc limitation I believe
<andrewrk> but we would be compiling everything with zig cc
<alexnask[m]> Hm fair enough
xackus_ has joined #zig
<andrewrk> you could make this tarball right now, there is nothing preventing it from working
<alexnask[m]> I was intending on compiling LLVM in debug mode but this is probably the way to go
plakband has joined #zig
nvmd has joined #zig
<novaskell> teratorn: try to give a name to computed types e.g `const AmpBoxFifo = std.fifo.LinearFifo(AmpBox, .Dynamic);`, makes it easier to work with and keep track of things. Goal is to have to remember as little as possible as the names tell you the whole story.
marnix has quit [Ping timeout: 240 seconds]
<FireFox317> andrewrk, ah yeah that would be nice. I will try out that method
<teratorn> so no one is quite sure how to make this code compile? https://hastebin.com/ocukoxopix.zig :-)
<g-w1> where did you get ptr[0..size]?
<teratorn> oh thats a mistake but i think (hope) unrelated
<g-w1> and the switch statement with nothing in it is a compile error too, and you dont want vars for struct elements but `pub var state: ParseState;`-> `state: ParseState,` iirc there isn't a concept of public or private fields on a method
<teratorn> still says variable must be initialized in reference to the box_buffer definition
<g-w1> read my last message
ur5us has quit [Remote host closed the connection]
ur5us has joined #zig
<g-w1> pub var box_buffer: std.fifo.LinearFifo(AmpBox, .Dynamic); -> box_buffer: std.fifo.LinearFifo(AmpBox, .Dynamic),
<novaskell> teratorn: It compiles but I'm not sure what you want to do https://0x0.st/ineO.zig
FireFox317 has quit [Ping timeout: 246 seconds]
FireFox317 has joined #zig
<hch> the network game presented in yesterday's zig birthday party, is that public?
<hch> ah now he mentioned that it's on gh
<plakband> Hey all, I've been experimenting with Zig and was wondering if somebody could answer two questions about this snippet: https://pastebin.com/HQGsXzEE 1. I often find myself writing local functions like this. Is this unidiomatic? and 2. Writing type-y code like this is very trial-and-error for me. Are there any resources on how to reason about comptime/anytype/type inference/specialization?
<ifreund> plakband: avoid anytype unless you have to used it, which you don't here
<ifreund> fn gt(comptime T: type, a: T, b: T) bool { return a > b; }
<ifreund> but also yeah writing tiny functions like this is unidiomatic I'd say
<ifreund> why not just use the > operator?
<hch> got it, crawling through it already. thanks anyway
<plakband> ifreund: The > is arbitrary, I just needed some function to pass around. I'm trying to see to what degree I can do functional programming in Zig, and how much type inference I have to do "manually".
<plakband> What's wrong with anytype?
<ifreund> trying to do functional programming in zig is going to create a lot of friction
wootehfoot has quit [Read error: Connection reset by peer]
skuzzymiglet has quit [Ping timeout: 258 seconds]
donniewest has quit [Ping timeout: 244 seconds]
tane has quit [Quit: Leaving]
<plakband> I'm OK with some friction. I have a Haskell game library that I want to port to a systems programming language. It's tricky because of the types (Rust's type system wasn't flexible enough, which brought me to Zig), but the actual runtime code should be fairly easy, it doesn't need e.g. closures.
Ashpool has quit [Quit: Leaving]
<novaskell> using FRP or?
<plakband> No, ECS. If you do it right, most of your ECS logic can be fixed size vectors and bit masks
nvmd has quit [Ping timeout: 264 seconds]
nvmd has joined #zig
nvmd has quit [Client Quit]
_whitelogger has joined #zig
kristoff_it1 has joined #zig
GrooveStomp has joined #zig
ur5us_ has joined #zig
omglasers2 has quit [Read error: Connection reset by peer]
ur5us has quit [Read error: Connection reset by peer]
kristoff_it has quit [Ping timeout: 256 seconds]
<teratorn> hmm stuck on another compile error i dont really understand :-( https://0x0.st/in2r.zig any clue?
<ifreund> what's the error?
<teratorn> .\amp.zig:64:34: error: expected token 'Symbol', found 'error'
<teratorn> self.error = ParseError.KeyTooLong;
osa1 has quit [Ping timeout: 264 seconds]
<ugla> perhaps because error is a keyword
<teratorn> ouch
<ugla> there is some syntax to use keywords as identifiers, @"error" perhaps?
<ifreund> yeah, @"foo" lets you use literally anything
<FireFox317> andrewrk, i'm trying out your suggestion regarding building zig for windows-gnu using zig-bootstrap, but i'm getting the following error: https://pastebin.com/tCmTDdUX any clue what might be going wrong here?
<andrewrk> FireFox317, ah yes actually
<andrewrk> ok so first of all llvm::cfg::Update<llvm::BasicBlock*>::dump() is a debug function
<andrewrk> we shouldn't try to call it for an llvm compiled in release mode
<FireFox317> yeah i build llvm with release and zig in debug
<andrewrk> one thing to check: is that simply a missing library from this list? https://github.com/ziglang/zig/blob/73f3f0167079aaa47117175c31960963dc5af9ee/cmake/Findllvm.cmake#L197-L344
* andrewrk looks for which library exposes this
osa1 has joined #zig
<FireFox317> ah i guess because llvm-config build in release mode might be outputting different libs compared to debug mode?
osa1 has quit [Remote host closed the connection]
<andrewrk> FireFox317, yes perhaps. when we build with zig-bootstrap the list of libs is explicitly set - no invocation of llvm-config
<FireFox317> yeah but i mean the list you just pointed out is probably generated with a llvm-config built for release mode
osa1 has joined #zig
<andrewrk> ahh yes
<andrewrk> I think this is going to be a simple fix
<andrewrk> hmm I can't find that function in the llvm sources
<FireFox317> that is super strange
<andrewrk> uhh wtf is this macro LLVM_DUMP_METHOD
<andrewrk> anyway I would be happy with a patch to disable zig's call to that function until we get it sorted out
<FireFox317> andrewrk, yeah but just grepping for dump() in the zig source tree finds no cpp files
<andrewrk> ok looks like this has to do with the #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP) guard in front of the definition
<FireFox317> well expect for some stuff in libcxxabi
b_jonas has quit [Ping timeout: 260 seconds]