ChanServ changed the topic of #zig to: zig programming language | | be excellent to each other | channel logs:
<daurnimator> andrewrk: misc idea re: createOne: call it `new`?
<daurnimator> otherwise, why is the memcpy compulsory? shouldn't the optimizer eliminate it?
<andrewrk> daurnimator, `new` is a good idea.
<andrewrk> there's an important distinction between "guaranteed by the zig language" and "the optimizer will probably eliminate it"
<daurnimator> given that we control the zig language; and the parameters to the optimizer; can't we make that guarantee?
<andrewrk> I'd be interested in an explanation of how that would work
<j`ey> daurnimator: zig doesnt control exactly what LLVM does
<j`ey> / can do
<daurnimator> yeah I don't know. but it theorectically seems under our control
<daurnimator> andrewrk: so I was quite confused about the .create deprecation. It wasn't communicated anywhere; and I think still used all over the standard library
<daurnimator> andrewrk: that it was in a seemingly unrelated commit+PR is.... opaque
Ichorio has quit [Ping timeout: 240 seconds]
hooo has quit [Quit: Connection closed for inactivity]
knebulae has joined #zig
oats is now known as ailur
ailur is now known as oats
_whitelogger has joined #zig
_whitelogger has quit [Remote host closed the connection]
_whitelogger has joined #zig
_whitelogger has joined #zig
rayman22201 has quit [Ping timeout: 256 seconds]
andrewrk has quit [Ping timeout: 250 seconds]
andrewrk has joined #zig
Zaab1t has joined #zig
_whitelogger has joined #zig
forloveofcats[m] has quit [Remote host closed the connection]
dtz has quit [Read error: Connection reset by peer]
Triplefox[m] has quit [Remote host closed the connection]
dtz has joined #zig
forgot-password has joined #zig
<forgot-password> I think I'm having trouble with understanding the comptime concept. Would somebody mind checking out this little gist? I tried to break it down as much as I can, so I hope it's understandable what I am trying to do :)
<knebulae> can you post a link to the c header?
forgot-password has quit [Ping timeout: 252 seconds]
forgot-password has joined #zig
<forgot-password> knebulae: I justed used that as an example, in my actual code it's importing the OpenGL header
<forgot-password> If call std.debug.warn instead of the c function it says that it cannot call var args functions during compile time.
<forgot-password> Does the fact that my function takes a comptime type result in the whole function being a comptime function?
hooo has joined #zig
<forgot-password> I tried a few other approaches, and it seems like as soon as I have a member of type 'type' in my struct the compiler throws the same error at me when I try to call the c function in any member function (is that what it is called?) of the struct.
<forgot-password> I assume that this is inteded behaviour, but I just can't wrap my head around it :/
oats is now known as ailur
ailur is now known as oats
daurnimator has quit [Ping timeout: 260 seconds]
daurnimator has joined #zig
Ichorio has joined #zig
Zaab1t has quit [Quit: bye bye friends]
return0e_ has joined #zig
return0e has quit [Ping timeout: 250 seconds]
<ofelas> forgot-password: i changed your gist a little,, maybe it can help
<andrewrk> forgot-password, I believe what's happening here is that your struct, MyResultType, has a field of type `type` (the `input` field).
<andrewrk> the type `type` can only be used at compile-time, which means that your getResultType function will always be called at compile time
<andrewrk> you cannot call C functions at compile time
<andrewrk> hence the error
<forgot-password> andrewrk: Thanks, first of all. I don't intend to call the c function at compile time, I think this is where my misunderstanding is coming from. It's an OpenGL function, which makes it require a bound context.
<andrewrk> it is planned for compile error notes to explain this better
<andrewrk> consider that if you add a field of type `type` to a struct, then that struct must always have a compile-time known value
<forgot-password> ofelas: Thank you, but I don't need a value of type T. Instead I wanted to preserve the type for later use. However, it makes sense that the whole struct then has to be a comptime value, since type information is not available at runtime (Is that correct?)
<ofelas> that is my understanding
<forgot-password> Regarding my question about types at runtime or the former statement?
<andrewrk> correct: type information is not available at runtime
<ofelas> thanks, was reading about comptime...
<forgot-password> Speaking of questions, I kind of feel like a small burden on this IRC, since I'm constantly spamming questions. But on SO there's only a single question tagged with zig. Are there any other available resources except for langref.html and the GitHub issue tracker?
<andrewrk> forgot-password, no, it's a very young language, still changing quickly, documentation is hard to come by
<andrewrk> newbie questions are 100% on topic here, don't feel bad
<forgot-password> Alright, great :)
<andrewrk> one more place you can look is at example code
<andrewrk> here are some github repos that have zig code
<forgot-password> I also wanted to mention that's it is an awesome expierence so far and it's the most fun I've had programming in a long time. The only thing better than that was the revelation of Haskell ;)
<forgot-password> It's really rewarding to check out some upcoming languages from time to time
<andrewrk> glad to hear that :)
SimonNa has quit [Remote host closed the connection]
SimonNa has joined #zig
fsateler has quit [Read error: Connection reset by peer]
fsateler_ has joined #zig
knebulae has quit [Quit: Leaving]
<forgot-password> I'm calling a function that only takes comptime arguments and try to store its result in another comptime variable.
<forgot-password> But the compiler complains that I cannot store a runtime value in a comptime variable. How do I make that function execute at compiletime?
steveno has joined #zig
<andrewrk> forgot-password, you can use a comptime expression
<forgot-password> Heh, just as you wrote that I prefixed my call with 'comptime'
<forgot-password> That's where I got from ^^
<andrewrk> :)
<forgot-password> Is there some way to concat two '[]const u8's? The compiler says 'unable to evaluate constant expression', but @typeOf gives me the same type for both variables.
<ofelas> are you using ++?
<forgot-password> Yes
<forgot-password> However, one side should be a comptime value and the other a function argument. Is that not reflected in a values type? I guess that could be it
<ofelas> const s = "H"; const ss = "W!"; var sss = s ++ ss; they must be known at comptime
<forgot-password> Oh alright, do I have to do a dynamic allocation and write the two buffers into that?
<ofelas> i guess so
<forgot-password> Yep, that worked. Thank you :)
steveno has quit [Remote host closed the connection]
torque has joined #zig
<andrewrk> forgot-password, you might find std.fmt.allocPrint useful
<forgot-password> Nice, that saved some lines, although the mem.copy wasn't too bad either :)
daurnimator has quit [Quit: WeeChat 2.3]
daurnimator has joined #zig
<forgot-password> Is there an std function to append a []u8 {0} to a string?
<daurnimator> forgot-password: you can use a c string literal