ChanServ changed the topic of #zig to: zig programming language | | be excellent to each other | channel logs:
Ichorio has quit [Ping timeout: 258 seconds]
develonepi3 has quit [Quit: Leaving]
walac has quit [Ping timeout: 258 seconds]
develonepi3 has joined #zig
walac has joined #zig
kristate has joined #zig
kristate has quit [Ping timeout: 245 seconds]
redj has joined #zig
wilsonk has quit [Read error: No route to host]
wilsonk has joined #zig
return0e_ has joined #zig
return0e has quit [Ping timeout: 255 seconds]
kristate has joined #zig
MajorLag has joined #zig
tgschultz has quit [Ping timeout: 250 seconds]
MajorLag is now known as tgschultz
kristate has quit [Ping timeout: 250 seconds]
MajorLag has joined #zig
tgschultz has quit [Ping timeout: 258 seconds]
MajorLag is now known as tgschultz
tgschultz has quit [Ping timeout: 264 seconds]
dewf has quit [Quit: Leaving]
MajorLag has joined #zig
MajorLag is now known as tgschultz
adrusi_ has quit [Quit: ZNC 1.7.2 -]
adrusi has joined #zig
Ichorio has joined #zig
kristate has joined #zig
tleguern has joined #zig
<tleguern> Hello
<tleguern> I am really sorry for the time in takes me for the OpenBSD.
<tleguern> I am reimplementing selfExePath at the moment, as it migrated from C++ to zig.
kristate has quit [Read error: Connection reset by peer]
kristate_ has joined #zig
allan0 has quit [Ping timeout: 258 seconds]
allan0 has joined #zig
DutchGh0st has joined #zig
<DutchGh0st> tgschultz: , perhaps I can see if I can come up with something that works, and is simple to use for recursive field enumeration?
<DutchGh0st> I think iit would be usefull to have
<andrewrk> tleguern, there is a C++ implementation in os.cpp and a zig implementation in std/os/index.zig
<andrewrk> both are required
<DutchGh0st> mhh, how is recursive comptime evaluation?
<andrewrk> DutchGh0st, it works fine
<andrewrk> I think your meta function sounds application-specific
<DutchGh0st> okey, cool. Most structs don't have that many depths anyway
<DutchGh0st> at least I think :3
<DutchGh0st> there
<DutchGh0st> I suppose I wouldn't need 2 inline fors there
<DutchGh0st> but just call the mem.eql, and the recursive call in the inline for
<andrewrk> DutchGh0st, neat! and then until is done you'll want to put `comptime assert(..);` to catch it at compile time
<DutchGh0st> oh! yeah!
kristate_ has quit [Read error: Connection reset by peer]
kristate has joined #zig
<DutchGh0st> it has a slightly more complicated testcase
DutchGh0st has quit [Quit: - A hand crafted IRC client]
DutchGh0st has joined #zig
<DutchGh0st> oh, I just had a little thought about it andrewrk. the current std.meta hasField function could take a const boolean, to specify if it should search recursively, or just to search the struct you gave it
<andrewrk> DutchGh0st, I think recursive search is application specific logic
<DutchGh0st> yeahh, probablyy
<tgschultz> yeah, I'm having difficulty seeing how it would be generally useful. I imagine this is for some kind of assistence with flattening composed structs? How would I access the field, given that I don't know where in the structure it is? What if there are two matches? etc.
<DutchGh0st> huh, 2 matches, have not though of that one..oopsy
<DutchGh0st> well it just returns true on the first one it finds
<tgschultz> Sure, but how is that information useful?
<DutchGh0st> maybe fieldnames aren't that usefull recusively, fieldtypes however could be
tleguern has quit [Ping timeout: 256 seconds]
<DutchGh0st> in a way that you can have a dummy struct that specifies `phantom` behaviour,
<DutchGh0st> kind of like marker traits in Rust, but in this case it would be marker fields
<tgschultz> I'm not following. I'm not familiar with marker traits in Rust (or Rust in general). What are they used for?
<DutchGh0st> For example there's been quite some changes in the way they want to kind of ensure safety with regards to generators that have references across yield points
<DutchGh0st> in other words, if you resume the generator, then you'd move, all the references become invalid. To solve this, they have a marker trait called Unpin. In this specific case, Unpin specifies that a type is `safe` to move
<DutchGh0st> generators are !Unpin (not Unpin)
<DutchGh0st> but because we don't have traits, but you can simulate this marker behaviour with just an empty struct,
tgschultz has quit [Ping timeout: 255 seconds]
Akuli has joined #zig
hg has joined #zig
allan0 has quit [Ping timeout: 244 seconds]
<DutchGh0st> for example this:
tgschultz has joined #zig
<tgschultz> DutchGh0st: I think instead of a field for that you want a definition. `struct { const unpin = void{}; };` vs `struct { unpin: void, };`. it won't make any difference to the compiler, but you also won't have to initialize the void field. The change in the metafunction would be to iterate over all definitions then recursively through each field.
<tgschultz> actually the iteration over definitions could just be replaced by 'hasDef()'
<DutchGh0st> mhhh
<DutchGh0st> but then I steal a possible fieldname away?
<DutchGh0st> I guess hasDef i'm going to write then haha
walac has quit [Ping timeout: 250 seconds]
walac has joined #zig
shachaf has quit [Ping timeout: 250 seconds]
shachaf has joined #zig
Avila has joined #zig
DutchGh0st has quit [Quit: - A hand crafted IRC client]
<develonepi3> andrewrk, I just updated my documentation of openjpeg for Ultibo. This is found A 2048 x 2048 takes 16 sec which is better than my FPGA of the DWT. Would zig improve on this?
<develonepi3> andrewrk, This work also demonstrates what can be done with bare metal on the RPi. Since this provides an EBCOT bit stream not just the lifting step.
very-mediocre has joined #zig
<AlexMax> Zig is one of those languages that I put a pin in because the back-of-the-box pitch looked pretty neat
<AlexMax> However, in conversation about this language, someone else pointed out that the "Why Zig?" wiki page claimed that Zig has no metaprogramming.
<AlexMax> While at the same time providing generics through comptime
<AlexMax> What is the disinction...or I suppose the difference in practice - between C++ templates and Zig's comptime T?
<AlexMax> The same wiki page also claims that allocators are explicit, but I think most C++ types that allocate memory allow you to pass a custom alloactor to them.
<AlexMax> basically, `fn max(comptime T: type, a: T, b: T) T` vs `<typename T> T max(T a, T b)`
<tgschultz> Zig has no default allocator. If something doesn't take an allocator as a parameter in idiomatic Zig, it doesn't allocate.
dewf has joined #zig
<tgschultz> In C/Cpp there are no such guarantees.
<AlexMax> Yeah, and some functions don't even take alternative allocators in a trivial way (asprintf, strdup)
<AlexMax> I see. What about C++ templates vs zig generics?
<AlexMax> What make's Zig's approach better? Is it faster? Does it produce more comprehensible error messages?
<tgschultz> I'm not sure. If I had to guess, I'd say that the difference is Zig doesn't have a separate language for meta programming. Type is a type of type `type`. It definitely produces better error messages than Cpp templates, but to be frank that's a really low bar.
<andrewrk> AlexMax, c++ templates vs zig comptime parameters are almost equivalent. some differences are: * zig has no overloading/inference, which makes compile errors much simpler * it's much faster in zig because we have a module system instead of a preprocessor. with C++ the compiler does the work N times and the linker has to deduplicate the work
<andrewrk> * in zig when you have a comptime parameter, that parameter can participate in comptime expressions ("static if"). I don't believe that works in C++
<andrewrk> if it is guaranteed to work on template parameters, then that last bullet point is equivalent
<AlexMax> I see. Still, perhaps the "Why Zig" wiki page could be updated to be worded differently.
<andrewrk> what is your proposed change?
<AlexMax> I'm not sure what to change it to, but the point that tripped up my friend is the part about "no metaprogramming"
darithorn has joined #zig
<AlexMax> Since it seemed to him that comptime + types implementation seemed to him to be broadly equivalent to C++ templates.
<AlexMax> I did a google search and somebody on the D language forum brought up the same point on the same wiki article.
gunnarahlberg has joined #zig
<gunnarahlberg> Hi again!
<andrewrk> I should probably move that wiki page to my personal blog as it was not really a community created page anyway. I'll do that and then update the content. I can make this case much more clearly now (2 years later)
<andrewrk> hi gunnarahlberg
<gunnarahlberg> I see zig test is missing documentation at
<gunnarahlberg> Any way I could contribute and maintain something there?
<andrewrk> sure thing, any contribution would be welcome
<andrewrk> I think someone may have started this effort, I'd have to search the IRC logs for --test-name-prefix to remind myself
<gunnarahlberg> I'll search logs
DutchGh0st has joined #zig
<DutchGh0st> I tried to do an `if(comptime expr) {}` in a struct declaration, and it didn't work, why actually doesn't that work?
<andrewrk> DutchGh0st, that's never been a feature - if statements are only valid in block scope
<DutchGh0st> well, guess I can just get around it
<andrewrk> sorry not block scope. but they're not valid top level declarations
<DutchGh0st> `var s = undefined; if (expr) { s = struct { whatever } } else { s = struct { otherstuff } }`
<andrewrk> struct fields are declarative
<DutchGh0st> *var s: type = undefined
<DutchGh0st> which seems to work actually
<andrewrk> why not: const s = if (expr) struct {whatever } else struct { otherstuff };
<gamester> you can do "struct_field: if(comptime expr) A else B", that's all I know
<andrewrk> gamester, that's correct, and the `comptime` is redundant in that example
<gamester> yes
<DutchGh0st> huh, mh, I guess, but depending on the if, I have a struct with 1 field, else 2
<andrewrk> it's still declarative. never at any point does a struct exist which only has some of its fields and then more are added later
<gamester> DutchGh0st: field: if(expr) T else void
<andrewrk> it's important for structs to be declarative because they can reference themselves
<DutchGh0st> I was actually looking at andre alexandrescu's bits of his checkedInt implementation, where he does use if's and else's to include fields in structs
<DutchGh0st> so I figured I'd try it out in Zig
<gamester> the zig way is "else void"
<andrewrk> AlexMax, ^ example of zig not having metaprogramming
<DutchGh0st> ehh, I shouldn't do this anyway I think:
<DutchGh0st> const s = if (@sizeOf(Hook) > 0) struct { int: I, hook: Hook } else { struct { int: I } };
<DutchGh0st> 'cuz a 0 sized type is nothing after compilation anyway
<hg> I never checked; I'm glad that u0 and i0 exist
<DutchGh0st> and conditionally specifying functions for the type?
<DutchGh0st> I suppose you could do this with an array of function definitions or whatever
<andrewrk> no you cannot do that
shawn_ has joined #zig
wilsonk has quit [Read error: No route to host]
scientes has joined #zig
shawn_ has quit [Ping timeout: 250 seconds]
<andrewrk> with llvm 8.0.0rc3 tagged yesterday, I am happy to announce all zig tests passing in llvm8 branch
<andrewrk> when this branch is merged into master, web assembly goes from tier 4 to tier 3
<scientes> sweet
<scientes> that is a place where zig could really have an edge too
<DutchGh0st> how should std.meta's hasFn be used?
<DutchGh0st> does it only look at a function's name?
shawn_ has joined #zig
darithorn has quit [Remote host closed the connection]
scientes has quit [Ping timeout: 258 seconds]
<DutchGh0st> oh, my function I was checking for was not pub ._.
shawn_ is now known as scientes
<tgschultz> yeah, it looks for functions by name that are pub. Reasoning was that non-pub functions probably couldn't be called by whatever was inspecting anyway.
<DutchGh0st> huh, its kind of interesting how this is working out
<DutchGh0st> and Im not even using traits!
wooter has joined #zig
very-mediocre has quit [Ping timeout: 256 seconds]
dewf has quit [Ping timeout: 245 seconds]
wooter has quit [Ping timeout: 250 seconds]
kristate has quit [Ping timeout: 250 seconds]
gunnarahlberg has quit [Ping timeout: 244 seconds]
scientes has quit [Ping timeout: 255 seconds]
wilsonk has joined #zig
marmotini_ has joined #zig
DutchGh0st has quit [Quit: - A hand crafted IRC client]
marmotini_ has quit [Ping timeout: 255 seconds]
<WilhelmVonWeiner> ...what is a group of Zig programmers called?
<andrewrk> off topic
<WilhelmVonWeiner> my momma would whoop my ass if I called a group of anyone "ziggers"...
<WilhelmVonWeiner> Also while it's being ported to OpenBSD I spun up an Ubuntu box to try the language out
<WilhelmVonWeiner> I work with an ISP doing VoIP (SIP) stuff and Python scripts are great and all but a robust compiled language would be better
<WilhelmVonWeiner> Are there any plans to implement associative arrays as a language feature?
<andrewrk> WilhelmVonWeiner, it's planned to never do that
<WilhelmVonWeiner> Lol.
<andrewrk> associative arrays are firmly in userland territory
<WilhelmVonWeiner> that's cool
<hg> mmmmmmmmmmmmmmmmmmmmassociativearrays
<hg> WilhelmVonWeiner: ziggies!
<tgschultz> this is a bit off topic, but is anyone aware of a comprehensive list of actively maintained llvm targets?
<andrewrk> tgschultz, is that different than the list of default targets that llvm builds?
<andrewrk> btw as of ade10387a5, `zig targets` will only show architectures that are compiled into LLVM
<tgschultz> I think so? I've found a few scattered github projects for architectures that aren't part of normal llvm's target list. Like dcpu-16 and z80.
<andrewrk> live coding stream starting in 5 minutes - implementing GeneralPurposeDebugAllocator, part 2:
<andrewrk> tgschultz, I see, so that would include third party projects that are not in llvm mainline
<andrewrk> I think the successful, well maintained ones usually end up getting merged upstream into llvm
<andrewrk> I'll be back after the stream
<tgschultz> that makes sense. too bad though. What I'm really looking for is a simple VM target. A non-physical architecture. Like, I dunno, CHIP8 only not so simple.
Akuli has quit [Quit: Leaving]
Ichorio has quit [Ping timeout: 250 seconds]
hg is now known as alot
alot has quit [Quit: WeeChat 2.4]
MajorLag has joined #zig
scientes has joined #zig