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/
<adamkowalski> This is how I approached the test case https://pastebin.com/RYahJCNY
<Snektron> cota: Did you forget extern or something like that? And why do you import a header file in your zig library? (or did you mean exported?)
<Snektron> adamkowalski: i'd declare n and p before their respective while loops
<Snektron> Did anyone already propose something like newtype? i was just programming c++ and i thought that would be a nice addition
<Snektron> basically a stronger version of @OpaqueType()
<Snektron> in fact, that would be equivalent to @NewType(void)
<cota> Snektron: the library is a "plugin" that is dlopen'ed from the C binary.
<Snektron> oh, i think i see what you mean
<cota> that's why the types are opaque
<cota> for now I just defined a foo.h where I define struct opaque { int unused; }, but that is dodgy
<Snektron> you can do it in zig with the builtin @OpaqueType i think
dbandstra has joined #zig
<Snektron> cota: When exactly does this happen? I jsut made a simple test program which seems to work
<dbandstra> adamkowalski: there is `std.meta.eql` which is a userspace implementation of deep equality check
<cota> Snektron: can you please provide a paste to your test program?
<dbandstra> adamkowalski: also you should use `std.testing.expect` instead of `std.debug.assert`. there's also a `std.testing.expectEqual` but it currently only supports one-level-deep arrays
<daurnimator> huzzah; merging
<daurnimator> dbandstra: oh it doesn't support multi level arrays? that should be easily fixed
<dbandstra> true, although you could get carried away if you try to make it give nice failure messages
lunamn has joined #zig
<daurnimator> that's fine; "uninformative error messages" is better than "doesn't work"
jessemeyer has quit [Remote host closed the connection]
traviss has joined #zig
<traviss> adamkowalski does https://ziglang.org/documentation/master/std/#std;meta.eql work for your use case? it will not follow pointers.
<cota> Snektron: thx for the example. I've modified it a bit: https://pastebin.com/raw/JvxLf8M9
<traviss> and you should be able to find a test executable to debug in zig-cache/o/*/test
<traviss> `ls zig-cache/o/*/test`
karrick has joined #zig
bjorob has quit [Ping timeout: 265 seconds]
<daurnimator> andrewrk: around?
karrick has quit [Remote host closed the connection]
<fengb> Is there a way to convince LLVM to partially unroll a loop?
<adamkowalski> dbandstra: thanks I changed my implementation to use expectEqual!
karrick has joined #zig
<adamkowalski> Snektron: I changed my variables to be created by the while loop
<fengb> I miss duff's device 🙃
<adamkowalski> so with std.meta.eql, std.mem.eql, and == I feel like we're trying to work around not having traits or overloading
<adamkowalski> whats the reasoning behind not doing something akin to those?
<adamkowalski> then we could extend our own types with equality comparisons
<adamkowalski> because otherwise I will need to implement yet another equality check for nd arrays right?
<daurnimator> no?
<adamkowalski> right now i'm doing a while loop and checking equality for each row of the inner array
<karrick> IIRC overloading is one of the major things the language does not support, because it adds uncertainty to what a particular block of code will do, based on the structure’s overloaded methods.
<adamkowalski> Which I get, but whats the proposed alternative I guess
<adamkowalski> Since we have "methods"
<karrick> Yeah I don’t know yet
<adamkowalski> you can add functions inside structs and get some syntax sugar
<daurnimator> adamkowalski: how are you defining your nds? arrays of arrays?
<adamkowalski> then you can take any generic type as long as you can call .eql on it or something
<karrick> In other languages without overloading I typically define the functionality as a method or two.
<adamkowalski> but I don't get how thats different to overloading
<adamkowalski> just whether you want to call f(x) or x.f()
<adamkowalski> either way it's polymorphic and depends on the type
<karrick> Overloading is exactly that but where that method is bound to a different token used for something else for a different structure. Especially when that token is a reserved token.
<adamkowalski> well overloading also allows you to extend types you don't own with new behavior
<adamkowalski> same with traits/protocols/concepts/etc
<karrick> I have not ever wished I had overloading. I used it in college for C++, and have not needed it again
<daurnimator> actually I'm not sure why meta.eql is not the same as the == operator
<adamkowalski> karrick it is incredibly useful when writing generic code
<karrick> Interesting comment about extending structures from outside the current namespace.
<adamkowalski> you don't necesarrily care what type gets passed in
<adamkowalski> instead you care about the interface it conforms to
<adamkowalski> it allows in my opinion for a much higher level of abstraction
lunamn has quit [Quit: leaving]
<karrick> I do like that adamkowalski
<karrick> I use extensively in Go
<adamkowalski> we already do that in zig for +, -, /, *
<adamkowalski> it is defined for floats, ints, and mixtures of the two
<adamkowalski> but it's a closed set
<adamkowalski> meaning you cannot extend it's usage to new types
<adamkowalski> so we end up creating functions called add, mul, whatever
<karrick> Kind of, say for int addition and floating point addition?
<adamkowalski> now you need to memorize multiple different names for the same concept
<karrick> Sorry I’m typing on cell phone and sliw
<karrick> While I type my response you also type the same thing
<karrick> 😜
<adamkowalski> if you want to see this concept in action I recomend looking at iterators in C++ and the whole standard template library
<adamkowalski> it means you can use linked lists, vectors, arrays, maps, sets, etc, all in a common interface
<adamkowalski> you can simply replace the input and see how it changes the performance characteristics of your application
<daurnimator> except in C++ no bit orgs use the standard template library
<daurnimator> s/bit/big/
karrick has quit [Remote host closed the connection]
<adamkowalski> thats not true at all. i've noticed a lot of c programmers hate it, but i've never heard the rational for why
<daurnimator> adamkowalski: I'm more referring to how most corps end up creating their own "standard library" for C++ as the STL is deficient in some way, e.g. EASTL
karrick has joined #zig
<traviss> adamkowalski, maybe related to some of you ideas are std.meta.trait.hasField / hasFn https://ziglang.org/documentation/master/std/#std;meta.trait
<traviss> i haven't used traits in zig before. this might be more informative than the docs: https://github.com/ziglang/zig/blob/master/lib/std/meta/trait.zig
<fengb> Zig doesn’t have runtime interfaces/traits/protocols yet
<karrick> I just went through Andrew’s most recent live coding and followed along. Really great. But the std lib has already changed since he did it. So I actually went through std source code, rectified the example against the new std lib code, and got it working. I now feel like I am starting to understand how to make non trivial software.
<fengb> The existing trait infrastructure is effectively comptime duck typing
karrick has quit [Remote host closed the connection]
karrick has joined #zig
karrick has quit [Remote host closed the connection]
<adamkowalski> daurnimator: people may end up making their own stls but the fundamental idea is the same. we want a set of abstractions that can work across a class of types.
<adamkowalski> fengb: yeah thats how templates worked for a long time. C++ 20 introduced concepts which is something we could steal ideas from. It allows you to constrain generic types to only those which meet some interface
<adamkowalski> But unlike traits/protocols/etc concepts allow you to operate on many types at the same time
<adamkowalski> so you can say that my function accepts ANY two arguments as long as addition is defined between them. That means you can take a matrix on the left and a scalar on the right
<adamkowalski> overloading also pairs really nicely with concepts, because you can define a function such as std::transform which can operate on iterators
<adamkowalski> but if you only support .next() like zig then you must do a forward traversal
<cota> What is the right type to use when importing a 'char' from C? u8?
<adamkowalski> if your iterator also supports random access, you can opearte in parallel across the entire data structure
<cota> (I tried with c_char: error: use of undeclared identifier 'c_char'
<adamkowalski> what happens when you try u8?
<cota> It compiles
<cota> so c_char is just a remnant of the past? Then we should remove it from doc/docgen.zig
<adamkowalski> u8 should be int8_t
<adamkowalski> so thats effectively char
return0e has quit [Read error: Connection reset by peer]
mikdusan has quit [Quit: WeeChat 2.5]
return0e has joined #zig
<cota> It's a little tricky though, see https://github.com/ziglang/zig/issues/875
mikdusan has joined #zig
shodan45 has quit [Quit: No Ping reply in 180 seconds.]
karrick has joined #zig
karrick has quit [Remote host closed the connection]
karrick_ has joined #zig
karrick_ has quit [Remote host closed the connection]
<fengb> c_anything is strictly for C. It’s ambiguous in Zig land (can be either u8 or i8) so translate-c won’t narrow it down
return0e_ has joined #zig
return0e has quit [Ping timeout: 276 seconds]
<daurnimator> I'm suprised there's not a c_char
<daurnimator> in C, sometimes char is signed; sometimes unsigned
knebulae has quit [Read error: Connection reset by peer]
<daurnimator> are stack traces meant to work on windows?
doublex has quit [Ping timeout: 240 seconds]
doublex has joined #zig
<pixelherodev> I think so?
muffindrake has quit [Ping timeout: 246 seconds]
muffindrake has joined #zig
knebulae has joined #zig
demizer has quit [Remote host closed the connection]
adamkowalski has quit [Ping timeout: 276 seconds]
dbandstra has quit [Ping timeout: 265 seconds]
chemist69 has quit [Ping timeout: 250 seconds]
chemist69 has joined #zig
lupine has quit [Ping timeout: 245 seconds]
dbandstra has joined #zig
<gruebite> hmmm `pointer type child '.cimport:2:12.struct_godot_gdnative_core_api_struct' cannot cast into pointer type child '.cimport:1:11.struct_godot_gdnative_core_api_struct'`
lupine has joined #zig
<daurnimator> pixelherodev: I've never had them work => I just get error.FileNotFound
<daurnimator> I've copied across the .pdb file as well
<gruebite> can I import more than one header at a time?
<gruebite> into the same variable and have all the resolutions.
<gruebite> I have opaque struct that is declared in one header, but defined in another generated one.
<gruebite> so all the prototypes have incompatible struct definitions
<gruebite> easy way to call an optional function?
<gruebite> expected function, found '?extern fn([*c].cimport:1:11.godot_variant, i64) void'
<gruebite> nvm on all that, just using if || {} syntax
<gruebite> daurnimator: got it all working, thanks. i can communicate with zig from godot now. rest is just filling in abstracting over it
ltriant_ has quit [Ping timeout: 276 seconds]
<cota> any tips for using @cInclude and @OpaqueType? i.e. when the .h file to be included declares some opaque types. I've worked around this by either (1) adding a dummy .h file that is @cInclude'd first or (2) using @OpaqueType and redeclaring (in Zig) the functions that use the opaque type (this is bad because it defeats the purpose of using @cInclude)
<cota> (I started looking at Zig today so it's likely I'm missing something.)
<gruebite> i had the same issue and just ended up making a separate h. if there is a better way i have not found it
adamkowalski has joined #zig
<gruebite> getting this now though "variable of type '.cimport:1' not allowed zig"
<gruebite> where cimport is some C struct
<gruebite> it's defined and not opaque
<cota> this is with the additional header? I'm confused
<gruebite> no additional header, likey separate issue :P
<cota> oh I see =)
<cota> I might file a bug tomorrow for the @cInclude/@OpaqueType thing -- meanwhile I'll use the separate .h file
<cota> thanks for your help! at least I see that I'm not the only one who noticed it
mahmudov has joined #zig
<daurnimator> gruebite: great.
<daurnimator> gruebite: you might have to provide a snippet for us to debug that one :P
<daurnimator> gruebite: yes you can include multiple headers in a single @cImport block.
adamkowalski has quit [Ping timeout: 276 seconds]
<gruebite> how? i tried commas :D
nomadgamma has joined #zig
adamkowalski has joined #zig
return0e has joined #zig
return0e_ has quit [Ping timeout: 240 seconds]
<gruebite> oh man: error: enum tag value 3 already taken
<gruebite> this one will be tough. zig does not support enums pointing to the same value? D:
<gruebite> with the same value?
<gruebite> i would have to modify the enum
<adamkowalski> How do I print a unicode character which was stored in a u16 with std.debug.warn?
<adamkowalski> I'm building a unicode plotting library and I want to use the braille alphabet https://jrgraphix.net/r/Unicode/2800-28FF to get higher resolution
<adamkowalski> I need to bitwise or two unicode characters together and print the output
<adamkowalski> This is the look i'm going for https://github.com/Evizero/UnicodePlots.jl
<nomadgamma> I noticed Zig has Tier 4 support for nvptx and renderscript, are there any other ways to target GPGPU?
<nomadgamma> I guess the other option would be to keep the kernels in C, and use Zig to interface with libCL etc.
<scientes> nomadgamma, I was at LLVM Dev Mtg and AMD uses LLVM internally for everything
<scientes> so if there is a way, you can figure it out
<scientes> and patches to make it work with zig are welcome
<scientes> it is just that nobody with expertise in that has worked on it yet
<nomadgamma> ah, I think I will go the easy route for now and stick with C and OpenCL for that stuff
<adamkowalski> Is this the recommended way to turn a unicode character to utf8 that can be printed by std.debug.warn?
<adamkowalski> const result = try std.unicode.utf16leToUtf8Alloc(allocator, [1]u16{i});
adamkowalski has quit [Quit: Lost terminal]
jjido has joined #zig
jjido has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
jjido has joined #zig
jjido has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
jjido has joined #zig
dbandstra has quit [Quit: leaving]
jjido has quit [Client Quit]
<nomadgamma> so, related question about Zig, I am writing code which can be executed symbolically (emits opcodes for later analysis) or evaluated at runtime, with the idea being that I can write the algorithm(s) once and execute natively with zero overhead or output opcodes for processing & analysis by a second stage, with C++ and Python I can use operator overloading to have near zero boilerplate (although C++ templates are getting
<nomadgamma> tedious in some cases, hence looking for different ways)... looking at Zig's compile time evaluation looks like I could do this but it would still need a lot of boilerplate - any suggestions?
casaca has quit [Ping timeout: 240 seconds]
<mq32> nomadgamma, so you want to have both "record what my code does" and "execute the code" with switchable behaviour?
casaca has joined #zig
<nomadgamma> yea essentially
<nomadgamma> there is only really 1 underlying type (some field), but many wrappers around it, in symbolic mode you get all the variables in SSA form and a trace of the operations performed
<mq32> hmm
<mq32> so more a kind of metaprogramming
<mq32> you can probably do something like this with zig comptime, but you don't have the luxury of operator overloading
return0e_ has joined #zig
return0e_ has quit []
<ikan-keli_> are we having this on Zig in the future? https://tokio.rs/blog/2019-10-scheduler/ :)
return0e_ has joined #zig
return0e_ has quit [Remote host closed the connection]
return0e_ has joined #zig
return0__ has joined #zig
return0e_ has quit [Ping timeout: 240 seconds]
<mq32> ikan-keli_: we already have a scheduler/event loop today :)
<scientes> a real scheduler is too much however, we have linux for that
<scientes> it should never be preemptable
<scientes> I guess go has preemption between function calls
<scientes> so maybe explicit preemption points
Aransentin has quit [Remote host closed the connection]
<hooo> is the Zig webassembly stuff working now, in a sort of production ready state?
<mq32> scientes: there could be something like "await std.event.scheduleStuff();"
<scientes> hooo, we are based on llvm, like everyone else, so I would say as much as anyone else's stuff is production-ready, and also zig is not stable as a language yet
<scientes> mq32, sched_yield()
<mq32> or even just "yield()": await std.event.EventLoop.yield();
<scientes> i was referencing the linux syscall
<scientes> which is sched_yield()
<mq32> ah
Ichorio has joined #zig
return0__ is now known as return0xe
<mq32> afaik tokio.rs is similar to our std.event.EventLoop
<ikan-keli_> thanks mq32, scientes
<daurnimator> mq32: isn't ours closer to the original one (mentioned in the article) under "The Tokio 0.1 scheduler"
<mq32> good question
<mq32> haven't used tokio much, it did just bloat my code
<daurnimator> My first reaction is how much better these approaches are compared to what I consider the "dumb simple" way of your tasks having intrusive linked list member(s) and having your scheduler just go through them....
<mq32> oh, on the topic of bloat: does zig clean up the cache at some time?=
<mq32> or does it grow infinitly?
<daurnimator> I'm not sure. But I'm very glad its in ~/.cache now....I had to delete most of my backups because they were full of zig-cache
<daurnimator> (I exclude .cache from backups)
<mq32> i don't think everything is in .cache
<mq32> the shared stuff (libc, ...) is in .cache, but there is still a project-related zig-cache
dimenus|home has quit [Ping timeout: 240 seconds]
<ikan-keli_> what is the C++'s std::vector equivalent for Zig?
<mq32> std.ArrayList
M-ou-se has quit [Ping timeout: 250 seconds]
M-ou-se has joined #zig
<ikan-keli_> https://github.com/ziglang/zig/blob/master/lib/std/array_list.zig#L265 wow.. is there implicit default allocator?
<mq32> ikan-keli_: nope. zig does not have default allocators
<fengb> Unfortunately there’s no general purpose allocator yet
<ikan-keli_> Impossible, or not there yet?
<daurnimator> not there yet
mht has quit [Read error: Connection reset by peer]
dimenus has joined #zig
Akuli has joined #zig
frmdstryr has joined #zig
Ichorio has quit [Ping timeout: 245 seconds]
waleee-cl has joined #zig
mahmudov has quit [Remote host closed the connection]
<fengb> So... Godbolt doesn't emit code unless I select Zig 0.3
<mq32> fengb: yeah, I'm ignoring this for a while now... :D
<daurnimator> fengb: yeah I noticed the other day..... any idea why?
<daurnimator> I'm still also curious about how to get a traceback on windows....
forgot-password has joined #zig
<fengb> I don't know much about Godbolt. 0.5 was working when it first released :/
<scientes> oh yes, its been that way for a few weeks....
<scientes> since the 0.5 release
forgot-password has quit [Ping timeout: 240 seconds]
doublex has quit [Read error: Connection reset by peer]
<fengb> scientes: do you know if there's a way to convince LLVM to partially unroll a loop?
<scientes> fengb, *clang* and not llvm, has a fancy loop unroller, where you give it the number of iterations at a time to unroll to
<fengb> Bah
<fengb> I guess I'll test this code out in C before migrating it to Zig
<scientes> >
<scientes> I'll be sending out a LLVM patch which consumes the generated metadata right after this.
<scientes> oh, appears there is a llvm feature
<fengb> Yeah I was hoping there's somethiing we could do in Zig to activate it
<scientes> yeah look at link
<fengb> I basically want duff's device lol
<scientes> ahhh, duffs device is more complicated
<scientes> not sure if it does that
<scientes> actually, why wouldn't it
<scientes> I know the hardware loop pass does duffs device
forgot-password has joined #zig
<fengb> Also... llvm doesn't seem to be using cmov?
<fengb> nvm, found this: https://reviews.llvm.org/D36858
<scientes> fengb, when you realize the compiler is out-smarting you :)
<scientes> like when it converts you careful avoidance of multiplication into multiplication :)
<fengb> An older article from 2012 relied on cmov being faster. Maybe times have changed
forgot-password has quit [Ping timeout: 240 seconds]
<fengb> 7 years of branch prediction work? I dunno
<scientes> the branch predictor is insanely complicated
<fengb> It's binary search so the branch prediction would never be very good :/
<scientes> it can even handle *patterned* branches
<scientes> <fengb> It's binary search so the branch prediction would never be very good :/
doublex has joined #zig
<scientes> ahh yes, then you should be able to attach branch weight meta-data to effect code-gen https://llvm.org/docs/BranchWeightMetadata.html
forgot-password has joined #zig
<scientes> modern CPUs branch predict both branch directions, right?
<scientes> just far deeper into the expected direction
<daurnimator> scientes: you should also read throw my link
<daurnimator> *through
<daurnimator> and that typo is how I know I need to head to bed
<scientes> daurnimator, I made it a little, but I too need sleep before reading this
<scientes> its quite in depth
<scientes> ijts also a little too specific to current hardware for me
<scientes> and will have nothing about spectre/meltdown
<scientes> which I would like to have included in the paper
<mq32> scientes: afaik modern CPUs do not only predict, but actually *execute* both branches and then decide which branch takes effect
<mq32> that's the basic idea behind the meltdown attack
<scientes> mq32, branch prediction is all about execution
casaca has quit [Ping timeout: 240 seconds]
<scientes> especially of loads
<mq32> nah. the basic idea of branch prediction is not flushing your pipeline
<scientes> ahh I see
<mq32> executing both branches is a pretty *advanced* version
<scientes> but the back branch predictor has an alternate pipeline
casaca has joined #zig
<scientes> (a shallow one)
<mq32> the simplest version is just "if branch was taken last time, fill pipeline with stuff from that direction"
<mq32> otherwise, use the other direction
<scientes> mq32, yeah, and without even a "undo" transactional model to it
<scientes> cause the memory stuff means you need transactions
<scientes> but that is branch prediction 486 style
<scientes> **686
<scientes> Pentium I
wilsonk has quit [Ping timeout: 268 seconds]
<mq32> yeah, i know
wilsonk has joined #zig
<mq32> modern CPUs are quite crazy
<mq32> speedup * 3 with the same clock count
<scientes> except the power efficient ones, without power-hungry OOO
<mq32> "Just throw more transistors at the problem" is the current solution :D
<scientes> they are still superscalars
<scientes> mq32, that stopped working years ago, now its "throw 64 threads at the problem"
<fengb> Back in the day, we could simply ratchet up clockspeed to improve performance
<scientes> or I mean 128 threads
<mq32> hehe
<mq32> scientes: nah, also single core perf has increased
<scientes> The Rome 2
<fengb> Hardware guys have been carrying us on their backs :/
<mq32> not that much anymore, but it still does
<mq32> oh, btw. is there any frontend html dev here? :D
<scientes> yeah but its can't much more
<mq32> i have an annoyance i'd like to fix
<scientes> IBM too put lots of research into it
<mq32> scientes: i really should get back to my CPU project and start implementing it...
* mq32 requires some motivation
<fengb> I am
<scientes> I have a project to improve the switch statement
<fengb> Frontend
<scientes> and also the switch on strings that needs that optimization
<scientes> but not the shitty D implementation
<mq32> fengb: firefox stores form state over page reloads. can i prevent that? i'm building a user interface that should not have some stuff from previous iterations
<scientes> or equally shitty gperf implementation
<scientes> x86 is indeed a well-polished turd
<fengb> I think the easiest way is to set a default value on the input. Even empty string can convince the browser to stop doing stuff
<mq32> <scientes> "x86 is indeed a well-polished turd" this is a quite wonderful sentence :D
<mq32> fengb: i'm talking about radio buttons
<mq32> i'm using them to implement a tab view
<scientes> mq32, whenever I do asm I do arm or PPC cause x86 is so insane
<mq32> and firefox stores what tab was active the last time, but doesn't trigger click events for that
<mq32> ARM is quite nice
* mq32 wants to learn 68k ASM
<scientes> I refuse to read x86 just to understand the compiler
<fengb> `Unlike other browsers, Firefox by default persists the dynamic checked state of an <input> across page loads. Use the autocomplete attribute to control this feature.`
<mq32> oof
<fengb> Another case of "stop helping"
<mq32> thanks mozilla :D
<mq32> fengb: Array.from(document.querySelectorAll("form")).forEach(f => f.reset())
<mq32> this works as well
<daurnimator> mq32: document.forms :)
<mq32> who knew :D
<mq32> but thanks, daurnimator and fengb :)
<mq32> i wonder how much work a semi-complex CSS engine would be
<mq32> would be cool allow styles for my UI project....
<fengb> Also, autocomplete="off" probably will work
<companion_cube> CSS -> too much work
<mq32> autocomplete is an attribute for input elements, right?
<mq32> companion_cube: yeah, but it's really conventient to have it *grin*
<mq32> i implemented most of the UI stuff only via CSS
forgot-password has quit [Ping timeout: 276 seconds]
<fengb> CSS is terrible, but it's still the standard for the web. Any attempt at replacing it so far have been even worse
<mq32> why is it terrible?
<fengb> For web I mean. People have written their own layout systems in JS and they become just as complicated but woefully underdocumented
<scientes> fengb, you can't replace something like that, you can just add a second more complicated thing to be used and supported *in unison*
<scientes> which is a nightmare
<mq32> there's a lot of unnecessary stuff in it, but you don't need to use that
<mq32> i don't like CSS for layouting, though
<scientes> mq32, its alot better than tables without CSS
<fengb> But you have to worry about it. Inline elements have baselines, so images have magic floating whitespace. Floats do silly stuff. Flexbox is pretty sane but it interferes with position absolute (and have performance issues)
<mq32> scientes: yes, true
<scientes> (for anyone that remembers such things)
<companion_cube> juste produce .tex files 🤔
<fengb> Basically, none of the layout related styles are orthogonal. And there's like 5 ways of defining them
<scientes> you have to remember the web was built progressively, and without much thought
<mq32> fengb: yeah, true. i don't like the implementation of CSS regarding to web, but i like the idea of cascading styles
forgot-password has joined #zig
<fengb> But hey, job security :P
<daurnimator> So who's ported cassowary to zig? :)
<mq32> what about this "proposal": Use language A (e.g. XAML) to define layout and content, use language B (CSS) for (visual) styling the content
<daurnimator> ( https://en.wikipedia.org/wiki/Cassowary_(software) => its essentially *the* layout engine algorithm)
<mq32> wow
<fengb> Oh the constraints engine. Yeah it's pretty nice
<mq32> all nice talk and no examples on how to define even simple constraints :D
<fengb> But... it's a pain to work with outside of a visual design tool :(
<fengb> mq32: the best demo is using Xcode
<fengb> Assuming you have access...
<mq32> i've used an apple device like ... 5 times in my live yet?
<mq32> 2 times iphone, 1 times ipad and 2 times a MAC
<fengb> Doing it manually is really complicated :(. But the visual tool is quite nice
<mq32> so: haven't had contact with that world :D
<mq32> have you worked with XAML/WPF?
<mq32> it's also a quite nice way to define UI layouts/constraints
forgot-password has quit [Ping timeout: 265 seconds]
<fengb> Nope
<mq32> you have different kind of "layout containers" and widgets
<mq32> layouts available are (from mind): stacking, docking, tabular, canvas(xy-position), flowing
<mq32> a button with a icon and a text would be something like this:
<mq32> Button { DockLayout { Image { .dock=left, .image="bla.png" }, Text { .text="foo" } } }
<daurnimator> Those all sound like one liners using cassowary
<mq32> only with XML and not that nice as i wrote that above :D
<mq32> daurnimator: probably. i have never used any constraint engine
forgot-password has joined #zig
<daurnimator> mq32: maybe the rust docs are useful? https://dylanede.github.io/cassowary-rs/cassowary/index.html
<daurnimator> I can't find a great introductory link :(
<fengb> Mac/iOS autolayout Cassowary is the least bad layout engine I've used
<fengb> But underneath the covers is pretty complicated stuff
<daurnimator> fengb: the core algorithm is pretty portable
<daurnimator> the trickest thing for zig would be how to be expressive... without operator overloading it's going to be hard
hooo has quit [Quit: Connection closed for inactivity]
<fengb> I don't doubt it, but making it palatable to users gets pretty hairy
<mq32> daurnimator: comptime strings?
<fengb> I used RubyMotion which forces devs to do it programmatically, and every one of them we wrote was broken in awkward ways
<daurnimator> mq32: system.addVariable("x"); system.addConstraint("x + 20 = y") => you'd want to parse that at comptime? I guess it would work...
<mq32> we still need a comptime allocator though :D
<mq32> (a usable one...) :D
<daurnimator> why?
<mq32> would make some stuff (like building tree/graph structures) simpler
<mq32> daurnimator: my layout engine in the UI system is pretty simplistic
forgot-password has quit [Ping timeout: 240 seconds]
forgot-password has joined #zig
<mq32> this is a "complex" example i made with it
return0xe has quit []
<scientes> daurnimator, eventually we will enable calling llvm bindings at comptime
<scientes> and also having using the llvm jit for comptime perhaps, so its actually the same code path
<scientes> that means we need a sandbox in another process
<scientes> julia does this
<scientes> you can construct a llvm function, build it, and then insert it into the run-time linker
<scientes> which makes it easy to write a customer interpreter in julia
<mq32> scientes: i don't think that's a viable path for zig, as this is pretty LLVM-specific and makes implementing stage2 much harder
forgot-password has quit [Ping timeout: 245 seconds]
<scientes> the compiler wouldn't use it
<scientes> the issue with zig is that we don't have this run-time linker than julia has
<scientes> and julia links all applications to libllvm already (even if the language doesn't strictly require llvm)
forgot-password has joined #zig
return0e has quit [Read error: Connection reset by peer]
return0e has joined #zig
forgot-password has quit [Ping timeout: 252 seconds]
forgot-password has joined #zig
qazo has joined #zig
wootehfoot has joined #zig
forgot-password has quit [Ping timeout: 240 seconds]
forgot-password has joined #zig
forgot-password has quit [Ping timeout: 240 seconds]
shodan45 has joined #zig
mahmudov has joined #zig
forgot-password has joined #zig
lunamn has joined #zig
tgschultz has joined #zig
forgot-password has quit [Ping timeout: 240 seconds]
forgot-password has joined #zig
jessemeyer has joined #zig
<jessemeyer> How do I take the first n bytes of a C string (known as ?LPWSTR type)?
forgot-password has quit [Ping timeout: 246 seconds]
<jessemeyer> To store in a u16 array.
forgot-password has joined #zig
<jessemeyer> I'm working on build a Windows program (subsystem windows) through WinMain and running into surprises.
<jessemeyer> If I define WinMain as: export fn WinMain(hInstance: ?HINSTANCE, hPrevInstance: ?HINSTANCE, lpCmdLine: ?LPWSTR, nShowCmd: INT) INT
<jessemeyer> The parameters do not appear to be passed successfully, I suppose, because the calling convention is not supplied. So if I add stdcallcc, Zig complains about a lack of main() function...
<jessemeyer> So if I provide an empty main(), WinMain() is no longer called at all!
adamkowalski has joined #zig
<adamkowalski> How do you all attach gdb/lldb to a test case?
forgot-password has quit [Ping timeout: 265 seconds]
FireFox317 has joined #zig
<mikdusan> a crashing test case?
<adamkowalski> no just any test case
<FireFox317> jessemeyer: I think you are forgetting a `pub` in front of the `WinMain` function. I also had this problem earlier
<mikdusan> adamkowalski: afaik, you either have to use a few tricks to find the executable name inside zig-cache yourself,
<adamkowalski> I can attach a debugger to my actual binary
<adamkowalski> but then you need to move your test case into your actual program
<adamkowalski> that doesn't sound right
<adamkowalski> I want to keep things test driven, and when something is wrong just debug the test case
<mikdusan> `zig test` actually creates an executable. it's just hidden inside zig-cache/
<adamkowalski> mkdusan do you know where in zig-cache?
<adamkowalski> and does nobody else have that workflow? is debugging a test case not a common thing in zig?
jessemeyer has quit [Remote host closed the connection]
<mikdusan> should be in current dir that runs `zig test ...`
<adamkowalski> what do you all do instead?
forgot-password has joined #zig
<adamkowalski> mikdusan it's not
<adamkowalski> I ran zig test src/plot.zig
<adamkowalski> it ran the test case
<adamkowalski> I looked at my root dir, no new artifacts
<adamkowalski> I went inside zig-cache/bin
<adamkowalski> there is a binary there, but it runs the main program
<mikdusan> which OS?
<adamkowalski> mac os catalina
jessemeyer has joined #zig
<adamkowalski> the zig cache folder has a h folder and an o folder
<mikdusan> right. inside the o folder will be a big hash name of another folder, then "/test" which is the executable.
<mikdusan> it's easy when there is only 1 "o/*/test" but everytime a change or diff test is created, there will be another exe.
<adamkowalski> hmm
doublex_ has joined #zig
<adamkowalski> so if I delete everything and run the one test case then I will just have one hash with one exe
<adamkowalski> that doens't sound like the nicest workflow though haha
<adamkowalski> I guess it goes back to my question of what you all are doing?
<adamkowalski> I don't want to swim upstream if there is a better way
<jessemeyer> Making WinMain pub didn't seem to improve things, but it's hard to say.
<fengb> There should be a --verbose flag that spits out the program it’s executing
<jessemeyer> For some reason, I don't have to specify main() if WinMain is just exported.
<mikdusan> adamkowalski: one trick you can use is `zig test ... --verbose-link` and if it's the __FIRST_TIME__ the test is created, you should see exactly where it will be
<jessemeyer> But, if I qualify WinMain has having stdcallcc, Zig requires main() to be defined, irregardless if the exported function is public or not (I think exporting makes it public)
doublex has quit [Ping timeout: 240 seconds]
<FireFox317> jessemeyer: That is correct I think, you don't need a `main` when you define a `WinMain`
<jessemeyer> Apparently, if main() is defined alongside WinMain(), only main() is ever called.
<jessemeyer> Then it's a bug on Master.
<FireFox317> You only want `WinMain()` I'm pretty sure
<jessemeyer> Roger. I'll submit a bug report. It's a blocking issue for me.
<FireFox317> jessemeyer: https://github.com/ziglang/zig/issues/2989 The example code in this issue is not compiling for you?
dimenus has quit [Read error: Connection reset by peer]
<FireFox317> I mean if you remove the `compilelog`
<adamkowalski> ➜ pinnacle git:(master) zig test src/plot.zig --verbose-link
<adamkowalski> Build Dependencies...lld -demangle -dynamic -arch x86_64 -macosx_version_min 10.14.0 -sdk_version 10.14.0 -pie -o zig-cache/o/EwewtdK_mk80bNqZS3h4CLKtpnGiPuT_oueukqxoOCWlzGu2-0bkFKqzJ4dTWfBN/test zig-cache/o/EwewtdK_mk80bNqZS3h4CLKtpnGiPuT_oueukqxoOCWlzGu2-0bkFKqzJ4dTWfBN/test.o /Users/adamkowalski/Library/Application
<adamkowalski> Support/zig/stage1/o/AvP0t-z5AbZjwU9LDQ6c9VNf7Rt_YI2_rsJHpYJOR1gvvfWeGU1RwzW9xbZWah3f/libcompiler_rt.a -lSystem
<adamkowalski> Test [1/4] test "scatterplot"...
<adamkowalski> thats the output
<fengb> I think it’d be nice if on test failure it outputs the file name
<fengb> It does for hard crashes
dimenus has joined #zig
<mikdusan> andrewrk: look at the ARG following `-o` . that's the path . --> `lldb zig-cache/o/EwewtdK_mk80bNqZS3h4CLKtpnGiPuT_oueukqxoOCWlzGu2-0bkFKqzJ4dTWfBN/test`
<mikdusan> whups wrong person. ^^ is meant for adamkowalski
<jessemeyer> FireFox317 When I define it that way, the parameters are not passed correctly.
<jessemeyer> FireFox317 So I think it needs to be stdcallcc'd.
<FireFox317> Hmm yeah I see indeed
forgot-password has quit [Ping timeout: 240 seconds]
<jessemeyer> FireFox317 I managed around the subsystem issue by manually setting that by overriding --subsystem.
forgot-password has joined #zig
doublex_ has quit [Read error: Connection reset by peer]
doublex has joined #zig
adamkowalski has quit [Quit: Lost terminal]
doublex_ has joined #zig
doublex_ has quit [Read error: Connection reset by peer]
doublex has quit [Ping timeout: 252 seconds]
forgot-password has quit [Ping timeout: 252 seconds]
adamkowalski has joined #zig
<adamkowalski> thanks I was able to find the test binary and break inside of it!
<gruebite> What would be the short term recommendation for resolving this? https://github.com/ziglang/zig/issues/2115
<gruebite> run a patch over the headers during build?
doublex has joined #zig
<mikdusan> adamkowalski: oh i just found something that might even be easier: `zig test foo.zig --cache off --verbose-link` <-- this will create an executable named "./test" which is very convenient
forgot-password has joined #zig
<adamkowalski> mikdusan awesome! thanks i'll try that now
<adamkowalski> mikdusan for some reason lldb is giving me error: process launch failed: failed to get reply to handshake packet
<adamkowalski> when you actually try to run the project
<mikdusan> odd. i'm able to lldb/break into a simple ./test without issue on catalina
<mikdusan> for now then i'd suggest just use what so far was working
THFKA4 has joined #zig
kristoff_it has joined #zig
forgot-password has quit [Ping timeout: 240 seconds]
forgot-password has joined #zig
<adamkowalski> which lldb are you using/
<kristoff_it> hello everyone! I've been away a couple of weeks and it feels like forever. I have a quick question about the new way of doing varags: what is the canonical way of knowing if a given struct is an "arg list"?
<adamkowalski> I've built llvm from source so I can get access to c++20 concepts and i'm using the lldb
<adamkowalski> kristoff_it can you use reflection and ask for the type of each argument and check if it maches the struct?
<mikdusan> oh, i've seen that error before with a custom build of lldb and never been able to solve it
<mikdusan> i am on catalina/10.15.1, xcode 11.3 beta, lldb-1100.0.30.10
<adamkowalski> mikdsuan are you using the one that apple provides with xcode?
<jessemeyer> kristoff_it Are you aware of the recent anon structs? https://github.com/ziglang/zig/pull/3652
<fengb> So many new faces >_>
<adamkowalski> mikdusan i'll check what version I'm on. catalina was a disaster. ever since i've upgraded they disabled nvidia driver support so I can't use cuda anymore
<adamkowalski> they want to force you to use metal
<kristoff_it> jessemeyer: yes I'm aware and I'm asking precisely about that. I want to distinguish between `.{10, true, "banana"}` and `.{key="hello", .prop1 = true}`
<adamkowalski> we need something like opencl but thats actually reasonable to use haha
<adamkowalski> has anybody tried using vulkan for compute rather then graphics?
<jessemeyer> kristoff_it Ah, got it. I don't know the answer ... I'm not sure if that's even been resolved yet. What may be the answer today may change tomorrow.
<FireFox317> gruebite: Probably running `zig translate-c` manually on the file and then make some changes by hand.
<jessemeyer> kristoff_it have you read this discussion? https://github.com/ziglang/zig/issues/208
<mikdusan> adamkowalski: also it might be viable to use your custom llvm/clang with latest xcode llvm
<mikdusan> oops. i meant 'latest xcode lldb'
<gruebite> FireFox317: I have to run a patch anyway because of some __attribute__ that chokes the translator so i miss function definitions
<gruebite> there's a PR now for it, but in the mean time
<fengb> kristoff_it: not sure this is the *right* way, but you can check hasField(val, "_0")
<kristoff_it> jessemeyer: yeah I read it, but the subject is not mentioned
<FireFox317> Ah yes I saw that one coming by. It's just really hard to properly translate all the c-code
<fengb> I also don't think the new varargs is in std yet so we'll have to establish some pattern
<gruebite> yep :) all good
wilsonk has quit [Ping timeout: 265 seconds]
<kristoff_it> fengb: thanks, I guess that works
FireFox31783 has joined #zig
FireFox31783 has quit [Remote host closed the connection]
<kristoff_it> So I'm still working on my Redis client and all seems working with async/await, so I'm updating the interface to the new syntax.
<fengb> I think this would be a nice function in std.meta
FireFox317_ has joined #zig
FireFox317 has quit [Ping timeout: 260 seconds]
<FireFox317_> gruebite: But for sure the multiple enumerations should be solved, because that such a common thing in imported C code
<gruebite> oh yeah, i've done it too in my C code
jjido has joined #zig
adamkowalski has quit [Quit: Lost terminal]
wilsonk has joined #zig
doublex_ has joined #zig
doublex has quit [Ping timeout: 265 seconds]
forgot-password has quit [Ping timeout: 240 seconds]
kllr_sbstn has joined #zig
forgot-password has joined #zig
jessemeyer has quit [Remote host closed the connection]
wilsonk has quit [Ping timeout: 265 seconds]
forgot-password has quit [Ping timeout: 240 seconds]
forgot-password has joined #zig
forgot-password has quit [Ping timeout: 240 seconds]
wilsonk has joined #zig
forgot-password has joined #zig
jjido has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
forgot-password has quit [Ping timeout: 245 seconds]
forgot-password has joined #zig
forgot-password has quit [Ping timeout: 265 seconds]
forgot-password has joined #zig
forgot-password has quit [Ping timeout: 240 seconds]
forgot-password has joined #zig
Akuli has quit [Quit: Leaving]
bjorob has joined #zig
forgot-password has quit [Ping timeout: 240 seconds]
doublex_ has quit [Ping timeout: 240 seconds]
forgot-password has joined #zig
doublex has joined #zig
Ichorio has joined #zig
forgot-password has quit [Ping timeout: 265 seconds]
forgot-password has joined #zig
quetzalb has joined #zig
<andrewrk> dimenus, related to your @Vector based matrix project: https://twitter.com/tom_forsyth/status/1196511893059276800
<andrewrk> Tom Forsyth is one of the main Intel people who designed SIMD
<dimenus> what is ISPC?
FireFox317_ has quit [Ping timeout: 240 seconds]
forgot-password has quit [Ping timeout: 265 seconds]
<mikdusan> Intel SPMD Program Compiler
<dimenus> andrewrk: i'm not really using any hadds / hmuls at the moment - but good to know that it's not really worth pursuing
forgot-password has joined #zig
<dimenus> andrewrk: did you and gingerBill get into any recorded discussions? :)
<fengb> Oh how did Handmade go?
qazo has quit [Quit: ...]
forgot-password has quit [Ping timeout: 240 seconds]
forgot-password has joined #zig
qazo has joined #zig
forgot-password has quit [Ping timeout: 276 seconds]
ky1ko is now known as ky0ko
<andrewrk> I think it went well!
<andrewrk> dimenus, ha! I didn't even consider that
forgot-password has joined #zig
kristoff_it has quit [Ping timeout: 245 seconds]
<dimenus> andrewrk: the discussion part or just the recorded part?
<andrewrk> the recording part
<dimenus> he's always been very supportive of what your doing but firmly against the Zig style of error handling, so I'm just curious if you guys got to discuss that in person
<dimenus> *you're
forgot-password has quit [Quit: leaving]
<fengb> "Error cases are handled like any other piece of code." that's what Go does and everyone reinvents error traces :(
<dimenus> errors are way way more ergonomic in Zig than they before the great desigiling
<dimenus> in 2017 i think I was on GB's side of the fense
<quetzalb> i successfully cross compiled from windows amd64 to windows aarch64 with today's zig master but I had to make some hacks. Does anyone know the correct way to generate lib/libc/mingw/libarm64/*.def files? I copied them from lib64 and hand edited to make it work.
<dimenus> *fence
<fengb> Ah yeah the old %% syntax scared me
<fengb> Although quite a few people now think try / catch are exceptions, even though the behave a lot more like Rust (or even Go if there's some syntax sugar)
<dimenus> i was annoyed by exceptions in c# and wanted something that was supposed to be simplier
<dimenus> but zig is actually simple for the READER, it's easy to see at the callsite if something can fail
<dimenus> and i've grown to really enjoy that feature
<andrewrk> quetzalb, those files are provided by the mingw-w64 project. if you have improvements to them, then we can return the favor from the zig community back to the mingw-w64 community by sending them patches
<dimenus> fengb: yeah, i can see how that might be confusing
<andrewrk> quetzalb, there is also a #mingw-w64 channel on OFTC
<quetzalb> andrewrk: thanks! I see the gendef program is in mingw-w64 project. I'll see if I can make it work to generate legit .def files.
kllr_sbstn has quit [Quit: leaving]
<AlexMax> speaking of mingw, perhaps you might be able to bring in the .def file for shlwapi?
<andrewrk> zig currently has mingw-w64 v6.0.0. it looks like since then they have released v7.0.0, so one open task is to upgrade
<andrewrk> AlexMax, yes, will do
<AlexMax> at least I think that's the issue, I'm not familiar enough with internals
<AlexMax> also, while you're here, what exactly would .rc file support look like in Zig? It requires a separate compilation step and needs either windres or clang -E > llvm-rc.
<andrewrk> I saw that issue - that's a good question. I don't have an answer without looking into it
<AlexMax> *nods* no worries, I'm not exactly a win32 maven myself and it's easy enough to work around for now
<fengb> til what maven means
jua_ has joined #zig
forgot_password has joined #zig
forgot_password has quit [Quit: Leaving]
dimenus has quit [Ping timeout: 252 seconds]
jjido has joined #zig
wootehfoot has quit [Read error: Connection reset by peer]
<quetzalb> I'm trying to use @cInclude("bthsdpdef.h") but I get "file not found". I see that header is included in zig sources at lib\libc\include\any-windows-any. Can I compile using that header or do I need my own copy somewhere else?
vexu has joined #zig
dimenus|home has joined #zig
mahmudov has quit [Remote host closed the connection]
dimenus|home is now known as dimenus
waleee-cl has quit [Quit: Connection closed for inactivity]
jua_ has quit [Quit: Leaving]
<andrewrk> quetzalb, you probably need -lc
<quetzalb> andrewrk: thank you that was it
vexu has quit [Quit: WeeChat 2.6]