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/
<pixelherodev> Snektron, sure, but it's a simple enough optimization
dingenskirchen has quit [Quit: dingenskirchen]
dingenskirchen1 has joined #zig
dingenskirchen1 is now known as dingenskirchen
reductum has quit [Quit: WeeChat 2.6]
doublex_ has joined #zig
doublex__ has joined #zig
doublex has quit [Ping timeout: 250 seconds]
doublex_ has quit [Ping timeout: 250 seconds]
wootehfoot has quit [Read error: Connection reset by peer]
knebulae has joined #zig
<daurnimator> frmdstryr: that helped.... http://sprunge.us/hA8OB3
<daurnimator> How can I un-null an optional?
<daurnimator> e.g. I have a `var foo: ?sometype = null;` and I want to pass it as an out-arg to a function: `somefunc(&foo)` however that function takes a `sometype`, not a `?sometype`
<daurnimator> trying to pass it like that gets "expected 'sometype' got '?sometype'"
<daurnimator> however trying to pass it as `&foo.?` fails with "attempt to unwrap null"
<daurnimator> andrewrk: I'm getting misc failures in std/event/loop... occasional errors from waitFd with FileDescriptorAlreadyPresentInSet
_whitelogger has joined #zig
doublex_ has joined #zig
doublex__ has quit [Ping timeout: 250 seconds]
adamkowalski has joined #zig
waleee-cl has quit [Quit: Connection closed for inactivity]
adamkowalski has quit [Ping timeout: 265 seconds]
mahmudov has quit [Ping timeout: 265 seconds]
dingenskirchen has quit [Remote host closed the connection]
dingenskirchen has joined #zig
adamkowalski has joined #zig
adamkowalski has quit [Ping timeout: 268 seconds]
muffindrake has quit [Ping timeout: 276 seconds]
muffindrake has joined #zig
<daurnimator> anyone managed to get std.event.loop actually working?
* daurnimator now rewatching the chat server stream... cause this isn't adding up
adamkowalski has joined #zig
adamkowalski has quit [Client Quit]
<daurnimator> http://sprunge.us/BirF5a <== zig segfault that I have no idea where to start on...
_whitelogger has joined #zig
<mq32> <daurnimator> however trying to pass it as `&foo.?` fails with "attempt to unwrap null"
<mq32> foo = @as(MyType, undefined); func(&(foo.?));
<daurnimator> mq32: `foo` here is actually a largish field of a heap allocated struct
<mq32> huh
<mq32> and you heap-allocate an optional?
<mq32> instead of optional-to-pointer?
<daurnimator> A = struct { foo: ?something, bar: u8, }; const a = try allocator.create(Foo); ------- some time passes -------- somefunc(&a.foo)
<mq32> ah yeah
<mq32> you have to initialize the struct after heap-alloc
<mq32> and to access "a.foo", you have to initialize it to a non-null value
<daurnimator> but it *is* null just before somefunc()
<mq32> but somefunc does initialize foo with a fresh something, right?
<daurnimator> in fact in my code its: `if (a.foo == null) getafoo(&a.foo);`
<mq32> aa yeah
<mq32> you still have to initilaize the optional before unwrapping it
<mq32> just use the @as(something, undefined) before getafoo
<daurnimator> this seems like a language "bug
<daurnimator> oh initialize to undefined? interesting
<mq32> nah, why?
<daurnimator> is that guarnteed to not initialize it to null?
<mq32> yes
<daurnimator> how so?
<mq32> if you assign it a "undefined something" instead of an undefined ?something
<mq32> var x : something = undefined;
<mq32> var y : ?something = x;
<daurnimator> ah k. good solution I think; thanks!
<mq32> ^= second line just does fill the y with a value, so it is not null
<mq32> it doesn't mean the value must be meaningful
<daurnimator> I feel like this is one of those things that need to be written down. I just learned something that someday someone will be stuck racking their brains trying to figure out with a deadline
<mq32> hmm
<mq32> yeah there's a lot of fine grained detail in the language that is "obvious" as soon as you think about it
<mq32> but not obvious if you didn't grasp the semantics completly
<daurnimator> "set X to undefined if you want to access it" is not obvious at all
<mq32> nah, that's not the idea :D
<daurnimator> s/access it/take its address/
<mq32> set x to an undefined, but non-null value
<shakesoda> i feel like i have no idea why a lot of the dots in zig are needed
<shakesoda> not like, opposed to them being there, i just don't quite understand
<shakesoda> particularly .{ .* and .? seem really awkwardly placed, and i'm sure for a reason, i just don't know it
<mq32> .* and .? are quite nice because they remove two unary prefix operators and replace them with postfix operators
<mq32> so pointers and optionals moore behave like structs where you can access the content as a field
<mq32> .* is the same as .? or .field
<mq32> "access contents of the type"
<mq32> .{ … } isn't a syntax a like, but i can understand why it's there
<shakesoda> that makes sense for the .* and .?
<shakesoda> if i think of it with the same frame as .field access it isn't weird anymore
<mq32> yep
<mq32> and now if you think about it, "*ptr" is a weird syntax in C :D
<shakesoda> the weird i have always known ;)
<mq32> yeah, that's the point
<mq32> a lot of people are weirded out by "different", but not by the absurd stuff they use every day
<shakesoda> zig seems consistently good about things having a reason for being
<mq32> yeah that's an important design decision
<mq32> i just learnt that ada has always all language features :D
<mq32> but i like this syntax for "attributes" which is quite cool and removes a lot of operators
<mq32> instead of using "&x" to get a pointer, you do "x'Address"
<mq32> to get the type, you can do "x'Type"
<shakesoda> that seems practical but really verbose
<mq32> yeah, so? :D
<mq32> increased readability
<mq32> x'size, s'bitsize
<shakesoda> verbose doesn't directly equate to readability
<shakesoda> ongoing argument i have with my dev friends :D
<mq32> it depends on the context, yeah
<mq32> but in most places, it reduces the stuff you have to remember (syntax wise)
<shakesoda> some of my friends write code so verbose that things fall out of my working memory before i can figure out what they do :(
<gonz_> Consistency leads to obviousness which helps
<shakesoda> keeping things at least somewhat terse helps avoid that
<shakesoda> obviously not to extremes either
<shakesoda> overly terse gets cryptic
<mq32> verbose syntax doesn't increase "working memory use" :D
<shakesoda> it increases the amount of stuff i have to process to figure it out :P
<shakesoda> i don't feel strongly about this in abstract, i would have to use it
<mq32> most brains parse "'address" the same as they parse "&" :D
<shakesoda> mine certainly doesn't!
<gonz_> Brains read patterns, not letter by letter
<gonz_> I doubt yours does
return0e has quit [Ping timeout: 265 seconds]
knebulae has quit [Read error: Connection reset by peer]
return0e has joined #zig
<gonz_> Your brain is likely intrinsically going to have a harder time making a difference between `&some_variable` & `*some_variable` than it would actual words representing those things, it's just that you've given it plenty of training to do so.
<shakesoda> dunno, but i don't read the operators as their words when i read code to begin with
<mq32> at some point you also stop reading 'address as a word, but as semantics
<mq32> it's the same difference at the end
<mq32> it's just what you are used to and what not
<shakesoda> yeah, but 8 times the characters
<shakesoda> that can add up to a lot of visual noise very fast
<mq32> conveying more information anyways
<mq32> @as() also adds a lot of visual noise to zig, sadly :(
<shakesoda> it definitely does
<daurnimator> @as is pretty rare in my experience
<mq32> interfacing with SDL is quite horrible right now :D
<shakesoda> i noticed that when doing the few replacements on my end but it was infrequent enough not to feel too strongly
<shakesoda> there are quite a few pain points interfacing with sdl
<mq32> daurnimator: i challenge you!
<mq32> @divFloor((mouse.y - mapOffsetY) & ~@as(c_int, tileSize - 1), @as(c_int, tileSize));
<daurnimator> I think 60% of the time I need @as is in testing.expectEqual. 30% in broken peer-type-resultion. and 10% actual use cases.
<daurnimator> mq32: use @truncate instead for that one
<mq32> huh what?
<mq32> @as is coercion, not casting
<mq32> tileSize is u8 because it has a certain size range, mouse.x and mapOffset is c_int, because friction with SDL
<mq32> and there are also isize types which are incompatible to c_int as well
<daurnimator> mq32: is your & there not a truncation?
<mq32> it's the inverse
<mq32> "remove the last n bits"
<mq32> that line is actually not quite correct though
<mq32> but it's not a truncation
<mq32> problem is that u8 doesn't interface well with either isize or c_int
* shakesoda keeps running into problems with the translation of c macros
* mq32 is not surprised
<shakesoda> sdl has a bunch of them, lots of libraries will macro a bitmask etc and those kind of things don't translate :(
<shakesoda> i think i ran into some issues with unusual enum values too, also common in c code
<mq32> shakesoda: maybe you want to contribute to my https://github.com/MasterQ32/SDL.zig project then :)
<shakesoda> mq32: oh i might need to try that out
<mq32> it is 99% incomplete right now
<shakesoda> i noticed, all the functions i searched for first are missing :D
<mq32> i'm building the lib as i require the features
<mq32> :D
<shakesoda> (first was SDL_GetPerformanceCounter and SDL_GetPerformanceFrequency)
<mq32> haha
<mq32> maybe the most uninteresting features to me right now
<shakesoda> then SDL_GL
<mq32> but go ahead, implement them! :D
<daurnimator> mq32: you got event/loop stuf working before?
<mq32> never used it
<mq32> i'm not that much a fan of async/await for I/O semantics
<shakesoda> well, they're quite a lot better than SDL_GetTicks is
<mq32> shakesoda: so? :D
<mq32> SDL_GetTicks has roughly my framerate resolution
<mq32> and i'm always locking in on VSync
<shakesoda> getticks accuracy is atrocious though D:
<shakesoda> ms isn't nearly enough
<mq32> enough for animation anyways ¯\_(ツ)_/¯
<mq32> depends on what you are doing
<mq32> i seldom use it anyways except for main loop counting
<shakesoda> you'll have timing drift almost instantly with only ms precision
<mq32> nah
<mq32> :D
<shakesoda> that is probably acceptable in your case, but i really don't like that kind of stuff
<mq32> fixed timestep loops work quite well
<mq32> they don't drift in any way, the just may "stutter" for a frame or so
<shakesoda> stuttering is the most annoying visual artifact of them all!
<shakesoda> my eyes, they bleed!
<mq32> i never had any stuttering
<mq32> but i'm not doing "heavy heavy game logic", but shallow game logic stuff
<mq32> so game logic and physics run with 400 FPS
<mq32> where a missing frame doesn't hurt you
<mq32> and visuals run in sync with the screen refresh rate
<shakesoda> i'm doing heavy enough logic that i have tools for measuring the time every system takes, and missing frames is real bad for the kind of projects i work on
<mq32> as always: it depends on the use case
<shakesoda> yes, of course
<mq32> but yeah
<mq32> if you want to contribute to the wrapper/sdl lib, go ahead :D
<shakesoda> i will certainly give it a go
<shakesoda> good excuse as any to work on my zig-fu, and transplant some of the sdl stuff i've already got here
rappet has quit [Ping timeout: 252 seconds]
rappet has joined #zig
<mq32> i'm gonna improve the "meta" of the repo a bit right now
<mq32> okay, meta and example added :)
_whitelogger has joined #zig
SimonNa has quit [Quit: Leaving]
ovalseven8 has joined #zig
<ovalseven8> Hey, what's your opinion about V (https://vlang.io/)?
<daurnimator> ovalseven8: gingerbill is a nice guy
<daurnimator> oh wait vlang not volt
<ovalseven8> daurnimator, Thanks, so far from finished. Maybe in a a few years
<mq32> oh btw, as it reminds me of a question:
<mq32> how does "hot reloading code" look like in practise?
<ovalseven8> Is there a rough estimate when Zig hits 1.0?
<mq32> i know from .NET how you can change *some* aspects of your code, but not all of them. how does this look in a native environment?
<daurnimator> mq32: depends on the languagr
<daurnimator> mq32: if its a VM... by just giving new code to the VM
<daurnimator> mq32: for native: usually unloading/reloading shared libraries
<mq32> yeah for a VM, i can imagine how to implement this
<mq32> but for native code, it seems much harder
<mq32> you need to have defined "sync" points where you can hot-reload code
<mq32> otherwise you are "in the middle of anything" and you have to rewrite the whole stack and such
<daurnimator> mq32: to a point: you have "unload hooks" and "load hooks" for a shared object
tyler569 has quit [Ping timeout: 265 seconds]
tyler569 has joined #zig
<mq32> also i wonder: was a REPL planned for zig?
<mq32> i cannot quite imagine how that should work out as well
<daurnimator> no
<mq32> okay, good :D
<daurnimator> though that didn't stop people
<mq32> it's a thing i've never used except for like "extended calculator"
<mq32> [x] The compiler crashes if you look at it funn
<mq32> :D :D
<daurnimator> ovalseven8: zig 1.0 is still a while away. I'm not familiar with any estimates
ovalseven8 has quit [Quit: Leaving]
<stratact> So... I was creating a `setFilter()` method for my iterator and I had it accept a function type as a parameter, only to realize I forgot... I can't use closures or have functions be anonymous either... I guess I have to write a normal function?
<daurnimator> stratact: yeah and bound functions crash the compiler if you try and pass them
<stratact> wait, why?
<stratact> ICE?
<stratact> ...closures must be super magical to implement I suppose
<mq32> stratact: closures are hard to get right
<mq32> what gets captured, how does it get captured, where is the data stored?
<stratact> Yeah, that's too magical even for Zig. Then I'll toss my filter closure adapter idea and come up with another stratact-egy
<mq32> well, you can always use semi-anoynmous functions for filtering
<mq32> give me a second
<daurnimator> stratact: or fix the bug :P
<Snektron> Wait, couldn't closured be implemented as a kind of "async function literal"
knebulae has joined #zig
<Snektron> but well, not async
<Snektron> because a Frame already saves all state of a function
<stratact> Holy poop-emoji, that's amazing!
<stratact> mixin style?
<stratact> (well it's not a mixin though)
<mq32> stratact: no, just zig style
<mq32> downwards "closures" are already no problem, as they are in C :D
<mq32> "upwards closures" are much more complex (meaning: passing a closure upwards the stack)
<stratact> cool beans, my friend
<stratact> I have... a lot I need to learn from Zig and C.
<mq32> what are you programming usually?
<stratact> Most of my programming was from refactoring existing Rust code but on-and-off I worked on random userland applications
<mq32> here's my example with some advancements: https://gist.github.com/MasterQ32/839bca85018331b314be8af041271521
wootehfoot has joined #zig
<stratact> mq32: I'm still impressed, even if it's a downward closure. I love it and it makes sense from a stack (and frame) point of view
<stratact> Heh, I've been trying to write something for the past 8 minutes but I didn't want to sound overly appreciative because of how ignorant I am. :)
* stratact is going to take another nap because he got mind blowned by a simple (but cool!) concept
jokoon has joined #zig
<frmdstryr> daurnimator: anyone managed to get std.event.loop actually working?
<frmdstryr> yes
<frmdstryr> daurnimator> frmdstryr: that helped.... http://sprunge.us/hA8OB3, sweet!
<frmdstryr> you have a lot of good ideas in your praser
<frmdstryr> parser*
rappet has quit [Ping timeout: 276 seconds]
rappet has joined #zig
marmotini_ has joined #zig
WendigoJaeger has joined #zig
dimenus has quit [Remote host closed the connection]
mahmudov has joined #zig
Boko_ebaac has joined #zig
Boko_ebaac has quit [Read error: Connection reset by peer]
Boko_eaedc has joined #zig
Boko_eaedc has quit [Read error: Connection reset by peer]
<stratact> So thanks to mq32 for teaching me about downward closures, I've commited Zig Sin by writing this FP-style Zig code just for science and my amusement: https://gist.github.com/stratact/ed0df681c087ddeb89c98b9ca78e10de
<stratact> it legit works too
Akuli has joined #zig
<andrewrk> the only sin in zig is using [*c] pointers :P
<stratact> :)
ur5us has joined #zig
<stratact> andrewrk: you can see why I was so impressed, right? Zig's ability to adapt itself to different programming styles by its own universal style.
<stratact> Alright I had enough refactoring fun, time to get stuff done.
lukeholder has joined #zig
ur5us has quit [Ping timeout: 250 seconds]
lukeholder has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<mq32> i'm really looking forward to free function literals
<mq32> they will make quite a difference again
<mq32> and they unify function-, type- and var declarations
SimonNa has joined #zig
lukeholder has joined #zig
lukeholder has quit [Client Quit]
lukeholder has joined #zig
<fengb> I feel like Zero needs a mount
<lukeholder> a mount?
<mq32> damn, ziggy is cute :D
<mq32> Is Zero collecting star dust for Ziggy? *grin*
<fengb> Needs more awesome
<lukeholder> fengb haha
jokoon has quit [Quit: jokoon]
marmotini_ has quit [Remote host closed the connection]
lukeholder has quit [Quit: Textual IRC Client: www.textualapp.com]
ur5us has joined #zig
WendigoJaeger has quit [Ping timeout: 240 seconds]
<stratact> I think I'm experiencing the Zig's Zen. Hearing rain drops while hacking is quite the experience.
<shakesoda> sounds relaxing
<stratact> indeed
<mq32> cool
<mq32> i have LEDs glowing and i'm quite happy about that :D
<stratact> More than one way to reach nirvana
<mq32> yep
<mq32> okay, my LEDs are blinking now <3
<andrewrk> this is my favorite song to code to while it rains: https://www.youtube.com/watch?v=XVgHofNs3pE
<mq32> very chill
<stratact> yes, very much so. It feels like I'm healing listening to it.
<stratact> I'm listening with those Audio-Technica headphones with large speakers, which allows me to hear more details in the song
<shakesoda> stratact: i have a couple pairs of those, they are great
<stratact> shakesoda: with the 3D-wing head support, right? :)
<shakesoda> stratact: yes
<stratact> I'll need to ping andrewrk for more of his favorites songs whenever I'm feeling down.
<stratact> I think I'm pretty much done with the terminfo text source parsing. I collected the names of the terminals in a `names` table and the bool, strings, numerics values in a `caps` table, similar to daurnimator's Lua approach. However is there a way to do debug prints to check a value's data representation with stdout?
<Snektron> andrewrk, rameses b is a good choice
Akuli has quit [Quit: Leaving]
ltriant has joined #zig
<stratact> I suppose the "{?}" format is what I was looking for, but the pointers hide the entry data :(
<andrewrk> var args's days is numbered
dbandstra has joined #zig
mahmudov has quit [Remote host closed the connection]
WendigoJaeger has joined #zig
wootehfoot has quit [Read error: Connection reset by peer]
casaca has quit [Ping timeout: 250 seconds]
dbandstra has quit [Ping timeout: 240 seconds]
<Snektron> Whats the status on #1348?
<andrewrk> Snektron, the info/labels there is up-to-date and correct
<Snektron> So i guess there is nothing to hold it up?
<andrewrk> nope, it's just a contributor friendly PR away
<Snektron> Guess i'll go take a look :)
dbandstra has joined #zig
<daurnimator> oooo, comptime fields.....
emekankurumeh[m] has joined #zig
<emekankurumeh[m]> would it be possible to set up ci for mingw-w64?
<Snektron> I notice that there isn't any checking on builtin functions names in std/zig
ur5us has quit [Ping timeout: 250 seconds]
<Snektron> andrewrk, should there be any checking on that at parsing stage?
<andrewrk> emekankurumeh[m], what you're asking for is to add support for this as a first-class build environment, blocking master branch pushes and PR merges if they break the build for this environment. I'll consider it
<andrewrk> Snektron, semantic analysis is an OK place to catch this problem, since it is clear to the parser what the programmer intended. a message such as "xzy is not a builtin function" is better than "unknown token: @xzy"
<WendigoJaeger> finally got a basic Zig program to run a on Game Boy Advance: https://github.com/wendigojaeger/ZigGBAHelloWorld
<andrewrk> WendigoJaeger, wow, nice!
<WendigoJaeger> I was surprised that LLVM support that old ARM architecture
<andrewrk> WendigoJaeger, here is the issue to get rid of the llvm-objcopy dependency: https://github.com/ziglang/zig/issues/2826
<WendigoJaeger> andrewrk: oh nice!
ur5us has joined #zig
<WendigoJaeger> andrewrk: and it's even better than devkitARM because you don't need an extra program just to update the ROM header, gotta love comptime features
<andrewrk> :)
<Snektron> andrewrk, i'm unsure where to place typeOf/TypeOf substitution. I considered in the handling of BuiltinCall in renderExpression, but there is currently no way to render something other than a token without directly rendering a string
<Snektron> Another place is in renderTokenOffset, but that seems wrong too
<Snektron> I suppose the best place to add this is in tokenSlicePtr in ast.zig
<andrewrk> Snektron, in this case, just render the string, don't call the token function
<Snektron> Would that not create problems with formatting of stuff after the name?
<andrewrk> you can look at how use / usingnamespace did this
<Snektron> ah sure, good idea
<andrewrk> yeah it'll mess up line comments after that token, but *shrug* this is a convenience thing that is only intended to last for 6 months. probably nobody will put a line comment after @typeOf() during that time
<Snektron> famous last words
<andrewrk> nobody noticed with usingnamespace :)
<andrewrk> if you want to pioneer a more sound way to do it, go for it
<Snektron> I suppose a good point would be the tokenSlicePtr call i was talking about
<Snektron> Simply define a list of substitutions by token and matching text, and provide a replacement text
<daurnimator> andrewrk: 16:15:24 <daurnimator>http://sprunge.us/BirF5a <== zig segfault that I have no idea where to start on...