<frmdstryr>
leeward: how far did you get with the msp432?
layneson has quit [Ping timeout: 240 seconds]
craigo has quit [Quit: Leaving]
craigo has joined #zig
daurnimator has quit [Quit: WeeChat 2.8]
<leeward>
frmdstryr: Not super far. I generated something with --emit-asm, added a line, and linked it with gnu ld, and it ran. I could probably skip the "add a line" step if I tweaked the linker script, but I couldn't get clang to generate an msp430 executable directly from C code (linker issues).
dingenskirchen has quit [Remote host closed the connection]
dingenskirchen has joined #zig
<leeward>
I wanted to get llvm to generate something before I went fiddling with linker scripts.
<leeward>
On the plus side, Zig can emit a single instruction for `volatile_ptr.* |= 1` while gcc and clang both emit 3.
aerona has joined #zig
stripedpajamas has joined #zig
nikita_ has joined #zig
waleee-cl has quit [Quit: Connection closed for inactivity]
epmills has joined #zig
nikita` has quit [Ping timeout: 246 seconds]
frmdstryr has quit [Ping timeout: 240 seconds]
epmills has quit [Remote host closed the connection]
fraktor has quit [Quit: WeeChat 2.8]
epmills has joined #zig
dongcarl has joined #zig
dingenskirchen has quit [Remote host closed the connection]
dingenskirchen has joined #zig
epmills has quit [Quit: Leaving...]
stripedpajamas has quit [Quit: sleeping...]
reductum has joined #zig
aerona has quit [Quit: Leaving]
_whitelogger has joined #zig
vimanuelt has joined #zig
stripedpajamas has joined #zig
B4s1l3 has joined #zig
B4s1l3 is now known as opDispatch
stripedpajamas has quit [Quit: sleeping...]
stripedpajamas has joined #zig
stripedpajamas has quit [Client Quit]
_whitelogger has joined #zig
marnix has joined #zig
cole-h has quit [Quit: Goodbye]
marnix has quit [Ping timeout: 258 seconds]
_whitelogger has joined #zig
<GreaseMonkey>
0.6.0, riscv32-freestanding-none, using QEMU's version of the SiFive-E platform for the time being: currently trying to get the machine trap vector working, and i can either give it a pointer which doesn't exist, or i can give it the address to the function which ends up being null
<GreaseMonkey>
never mind i need to somehow align the function
<GreaseMonkey>
yeah i needed align(4), problem solved
<leeward>
\o/
marnix has joined #zig
nikita_ is now known as nikita`
nycex- has quit [Remote host closed the connection]
nycex has joined #zig
dermetfan has joined #zig
_hl_ has joined #zig
vimanuelt has quit [Quit: Leaving]
marnix has quit [Read error: Connection reset by peer]
<_hl_>
A couple days ago I asked here about converting an enum to an error set. I have since (RSI is a pain...) gotten around to implementing that using some comptime hacks if anyone is interested in that sort of thing: https://gist.github.com/he-la/f23aa89611fd573cca380cdb76caf3ea
<_hl_>
This is useful for working with C libs that use enums for their error codes
marnix has joined #zig
ur5us has joined #zig
_hl_ has quit [Remote host closed the connection]
waleee-cl has joined #zig
_Vi has joined #zig
scriptdevil has joined #zig
marnix has quit [Ping timeout: 256 seconds]
ur5us has quit [Ping timeout: 260 seconds]
KKRT has joined #zig
marnix has joined #zig
<scriptdevil>
a question about standard docs. Is there a reason andrewrk decided to only generate docs for functions which are "reachable" from tests or code? Why not simply generate entries for every function in source files?
<ikskuh>
scriptdevil: because the stddocs are based on the semantic analysis of the source
<ikskuh>
this means that the docgen does not "see" the unused functions
<ikskuh>
the plan is to have multiple analysis runs, merge the results of those and output that as a merged documentation
marnix has quit [Ping timeout: 256 seconds]
_Vi has quit [Ping timeout: 272 seconds]
<ikskuh>
so you can see the differences in function signatures between different OSs
<scriptdevil>
I saw that in the video from andrewrk. However, why does it need to be based on semantic analysis?
dddddd has quit [Ping timeout: 240 seconds]
<ikskuh>
because function signatures differ between OSes
<ikskuh>
so you need to evaluate some comptime code
<scriptdevil>
Aah - comptime code. That is what I was missing.
<Barabas>
Seeing how it's not easy to replace all my instances of the var type I can see this is a good change =D
<ifreund>
Barabas: zig fmt should do that for you
_Vi has joined #zig
<Barabas>
Oh... oh well, there wasn't too much that I had to fix
heitzmann has quit [Quit: WeeChat 2.8]
heitzmann has joined #zig
<Barabas>
And all my code still works :)
KoljaKube has joined #zig
waleee-cl has quit [Quit: Connection closed for inactivity]
dermetfan has joined #zig
marnix has joined #zig
<Sahnvour>
Barabas: zig fmt can do the replacement for you
<KoljaKube>
Is there a way of doing early exits with optional types without checking the presence of the value at every step?
<KoljaKube>
Basically what I would want to do is `const f: ?Foo = mayFail(); if (f == null) return Err.Fail; useNonOptionalFoo(f);`
<ifreund>
const f = foo() orelse return Err.Fail;
<KoljaKube>
That too has the success in the middle and the failure at the end
<KoljaKube>
Kotlin's compiler makes `foo` non-optional after a `if (foo == null) return`, basically the variable changes its type in the middle of a function
<ifreund>
KoljaKube: f is non optional in my example
<KoljaKube>
Ohh, sorry
xackus has joined #zig
<KoljaKube>
OK, I guess that's the way to do it without magical type changes ;-)
<ifreund>
indeed, it's much simpler :D
<KoljaKube>
That it is, though maybe not as flexible
<ifreund>
how so?
<KoljaKube>
Not that I have a great use case for it at hand, but you can put an arbitrary amount of statements between the assignment and the "conversion" in Kotlin
<ifreund>
How would that possibly be useful? I don't see it
<ifreund>
well, maybe there are some ways to use that, but imo anything that requires that kind of control flow is smelly code
<KoljaKube>
As I said, I don't have a great use case for it...
<KoljaKube>
It just feels natural. No new syntax to learn, just "I checked here, it can't have changed, so it's definitly a value down here"
<ifreund>
I get that, but it's implicit and not really in line with the philosophy of zig imo
marnix has quit [Read error: Connection reset by peer]
<ifreund>
it's new semantics not new syntax, which is imo worse
<ifreund>
having the simplest semantics possible is critical for readability
<KoljaKube>
Yeah, I think so too
<KoljaKube>
But the downside is that the "opposite" of `x = xyz(); if (x) |xx| foo else bar` is `x = xyz() orelse bar; foo`
<KoljaKube>
Which is not really symmetrical
<KoljaKube>
And only works if bar is noreturn I guess
frmdstryr has quit [Ping timeout: 246 seconds]
<ifreund>
or of the same type of foo
<ifreund>
*as
<ifreund>
const num = foo() orelse 42;
<KoljaKube>
Sure
<KoljaKube>
I'm assuming that bar can also be optional?
<ifreund>
yeah as long as the peer type resolution works out
<KoljaKube>
So `x = foo() orelse { handleSomeStuff(); null }; domeSomeMoreStuff()` would also work
<KoljaKube>
s/dome/do/
<ifreund>
yeah, if x is ?u32 or whatever
marnix has joined #zig
<KoljaKube>
Other topic. Do those C APIs you use in river also do that callback-functions-get-passed-a-context-pointer thing I am seeing quite often in C libraries?
<KoljaKube>
Something like `LibContext* ctx = lib_initContext();` and LibContext's whatEverCallback has the signature `void whatEverCallbackFunc(LibContext*, ActualData*)`
<ifreund>
yeah, there's either a void pointer that I need to cast or I'm passed a struct that I can call @fieldParentPtr() on to get my struct
<KoljaKube>
Hmm
<KoljaKube>
Not sure I completely understand if @fieldParentPtr fits my problem
<ifreund>
what API are you trying to use?
<KoljaKube>
I only get a pointer to LibContext, which is allocated within the library, and I can't put my own stuff in there
<KoljaKube>
I have multiple cases of this, but currently I'm trying to create Wren wrappers
<ifreund>
looks like wren explicitly eschews global state: "Wren has no global state, so all state stored by a running interpreter lives here."
<ifreund>
comment on WrenVM in the header
<KoljaKube>
Yeah
<ifreund>
so I think they don't want your callback to access global state
<KoljaKube>
My end goal is having my own zig version of WrenVM with some added stuff, but since I only get that WrenVM*, I'm looking for a way to from Wren* -> ZigWrenVM*
<KoljaKube>
My latest thought was copying the whole WrenVM struct data into a struct of my own that starts with a WrenVM member, so that I should be able to safely @ptrCast
<ifreund>
yeah that would work
<KoljaKube>
Which, if I haven't overlooked something, should work, but feels hacky and needs that copy
<KoljaKube>
I guess for @fieldParentPtr to work I would need to control placement of the actual WrenVM struct data as well, right?
<ifreund>
though you'd probably need to read some of their code to make sure that doesn't break anything
manikawnth has quit [Remote host closed the connection]
<KoljaKube>
Yeah, already doing that
<KoljaKube>
So far every function accesses everything through that WrenVM*
<ifreund>
if you want to use @fieldParentPtr on WrenVM you need to make a struct that has the WrenVM as a member
<ifreund>
then you can call @fieldParentPtr(*MyStruct, "wren_vm_member", wren_vm_ptr) to get a pointer to your struct
<KoljaKube>
OK, then I read the documentation right
<KoljaKube>
Maybe I could also hijack the allocation callback to place-allocate the VM data into my struct
<KoljaKube>
Also slightly hacky though
<KoljaKube>
This would all be unnecessary if WrenVM contained just one `void* userdata`
<KoljaKube>
Oh.
<ifreund>
what global state are you trying to add that you need this struct for?
<KoljaKube>
This is why up-to-date documentation is important. If it's not documented, I go to the source, but if it's documented, I tend to rely on the docs...
<KoljaKube>
It's also why I don't write documentation at work, it makes one indispensable ;-)
<ifreund>
depends on the language for me. For C/Zig i just read the soruce
<KoljaKube>
C libraries yes, but I'm having a hard time reading libc
<KoljaKube>
libc++ as well
<ifreund>
yeah I do read man pages for libc, which are pretty great
<ifreund>
not a chance reading libc++, I use cppreferenc.com
<KoljaKube>
Don't know if you're the application-over-web kind of guy, but my wife used Zeal https://zealdocs.org in Linux, which is a FOSS reimplementation of the Dash documentation browser for macOS
Barabas has quit [Ping timeout: 245 seconds]
<KoljaKube>
I think it's pretty neat, especially if you switch between languages more often or have the library documentations available in it
<ifreund>
does look neat, though I don't think I switch around enough to justify it
Barabas has joined #zig
<KoljaKube>
One advantage is having documentation available offline
<KoljaKube>
My commute goes through a Funkloch ;-)
stripedpajamas has joined #zig
cole-h has joined #zig
stripedpajamas has quit [Quit: sleeping...]
layneson has joined #zig
layneson has quit [Ping timeout: 258 seconds]
marnix has quit [Read error: Connection reset by peer]
waleee-cl has quit [Quit: Connection closed for inactivity]
marnix has joined #zig
marnix has quit [Ping timeout: 256 seconds]
KoljaKube has quit [Ping timeout: 256 seconds]
<leeward>
Heh, reading https://github.com/ziglang/zig/wiki/Why-Zig-When-There-is-Already-CPP,-D,-and-Rust%3F I found this quote: "Zig has no macros and no metaprogramming" which is...dubious. It could be argued that most comptime constructs qualify as metaprogramming. That includes common idioms like `fn Container(comptime thing: type) type { return struct { ... }; }`
<Sahnvour>
indeed, probably what is meant here is "template metaprogramming"
cole-h has quit [Quit: Goodbye]
<leeward>
It doesn't have a separate language for metaprogramming, which sets it apart from several languages.
<leeward>
(not D, but hey, steal the good ideas)
<leeward>
Finally got around to updating 5800; turns out the day job is actually pretty good at wearing me out.
marnix has joined #zig
aarvay has joined #zig
stripedpajamas has joined #zig
dingenskirchen has quit [Quit: dingenskirchen]
aerona has joined #zig
dingenskirchen has joined #zig
marnix has quit [Ping timeout: 240 seconds]
stripedpajamas has quit [Quit: sleeping...]
dingenskirchen has quit [Read error: Connection reset by peer]
dingenskirchen has joined #zig
Akuli has quit [Ping timeout: 240 seconds]
<companion_cube>
Sahnvour: that looks a lot like templates though, except with a better syntax
<oats>
zig homoiconicity when? :P
<oats>
hoping zig will eventually be a cleverly disguised scheme dialect
<companion_cube>
without even closures, it's a long way away :D
traviss has quit [Remote host closed the connection]
traviss has joined #zig
Flaminator has joined #zig
aerona has quit [Remote host closed the connection]
xackus has quit [Ping timeout: 258 seconds]
aarvay has quit [Quit: Connection closed for inactivity]
<blinghound>
I whipped up a little terrain generator using pure zig today
<blinghound>
just thought it could be interesting
<blinghound>
is anyone else working on a game engine or a graphics based app with zig?
tyler569 has quit [Quit: WeeChat 2.3]
<leeward>
blinghound: ifreund is working on a wayland compositor, and fengb made a gameboy emulator. There's a decent amount of game/graphics stuff onhttps://github.com/nrdmn/awesome-zig
<blinghound>
leeward thanks for the link, I had an appetite for more zig stuff