<andrewrk>
if a thread dies it's gonna either panic or segfault. in the former case it calls abort() killing the entire process, in the latter it again would kill the entire process
<marler8997>
OOM
<marler8997>
what would it do in that case?
<andrewrk>
if the process gets killed by the oom killer, the whole thing is dead
<andrewrk>
if error.OutOfMemory is returned from an allocator, then it will be handled appropriately
<marler8997>
ok, so then you're saying we don't think a thread will exit without killing all the threads?
<andrewrk>
I think that is one use case for threads, which is the use case in stage2
<andrewrk>
but I agree, if you're planning on having a thread join or call exit in the event of an error, then having references to its stack memory would be a problem
<andrewrk>
it is possible for an application to write a custom panic handler that calls exit on the thread. in this case references to that thread's stack data would be a problem
<andrewrk>
I think zig is general purpose enough that we shouldn't make it impossible to have a reference to a thread's stack data
<andrewrk>
even though it would be inappropriate for some applications
<marler8997>
so you're saying we should try to avoid interprocess stack references?
<marler8997>
*interthread
<marler8997>
specifically for the Zig compiler
<justin_smith>
marler8997: wouldn't an interprocess stack reference be a special case of stale stack references which can already exist in one thread?
<justin_smith>
in fact, since references are visible by default, I'm not picturing how you'd have special rules for inter process references
<justin_smith>
maybe I'm not thinking about this right
<justin_smith>
"shared nothing" by default helps with concurrency correctness, but I don't think that's straightforward without a VM / GC controlling liveness / visibility?
<marler8997>
the only way I can think to do something like that is with some sort of "pointer coloring" or borrow checker
<justin_smith>
marler8997: even then, when you make a new thread, all visible heap is now shared, I don't think what you are describing is straightforward with threads (but it might be straightforward with peer processes that only share file handles)
remby has quit [Quit: Konversation terminated!]
ur5us has quit [Ping timeout: 260 seconds]
<justin_smith>
unless the coloring you describe effects all pointers to stack locations, and recolors on fork...
<justin_smith>
I'm probably thinking about this incorrectly
<marler8997>
I'm hesistant to say anything about a language solution to prevent these types of errors, as I said earlier it's a very deep topic
a92 has joined #zig
hnOsmium0001 has quit [*.net *.split]
gazler has quit [*.net *.split]
jjsullivan has quit [*.net *.split]
jjsullivan1 has quit [*.net *.split]
ashby has quit [*.net *.split]
betawaffle has quit [*.net *.split]
wjlroe has quit [*.net *.split]
gonz_ has quit [*.net *.split]
bodie_ has quit [*.net *.split]
lucus16 has quit [*.net *.split]
euantorano has quit [*.net *.split]
dputtick has quit [*.net *.split]
guan has quit [*.net *.split]
Sahnvour has quit [*.net *.split]
denucat has quit [*.net *.split]
daurnimator has quit [*.net *.split]
urluck has quit [*.net *.split]
M-ou-se has quit [*.net *.split]
vesim has quit [*.net *.split]
jjsullivan has joined #zig
gonz_ has joined #zig
jjsullivan1 has joined #zig
gazler has joined #zig
hnOsmium0001 has joined #zig
betawaffle has joined #zig
ashby has joined #zig
wjlroe has joined #zig
bodie_ has joined #zig
lucus16 has joined #zig
euantorano has joined #zig
dputtick has joined #zig
guan has joined #zig
Sahnvour has joined #zig
denucat has joined #zig
M-ou-se has joined #zig
daurnimator has joined #zig
vesim has joined #zig
urluck has joined #zig
betawaffle has quit [Ping timeout: 249 seconds]
betawaffle has joined #zig
hnOsmium0001 has quit [Ping timeout: 260 seconds]
hnOsmium0001 has joined #zig
neptunepink has quit [Ping timeout: 264 seconds]
neptunepink has joined #zig
squeek502 has quit [Remote host closed the connection]
AlbinoDrought has quit [Remote host closed the connection]
a92 has quit [Quit: My presence will now cease]
radgeRayden has joined #zig
lucid_0x80 has joined #zig
chivay has quit [Remote host closed the connection]
chivay has joined #zig
bsrd has quit [Read error: Connection reset by peer]
bsrd has joined #zig
hspak has joined #zig
marnix has joined #zig
marnix has quit [Read error: Connection reset by peer]
marnix has joined #zig
cole-h has quit [Quit: Goodbye]
cole-h has joined #zig
waleee-cl has quit [Quit: Connection closed for inactivity]
squeek502 has joined #zig
benjif has quit [Ping timeout: 264 seconds]
a_chou has joined #zig
sord937 has joined #zig
marnix has quit [Ping timeout: 264 seconds]
marnix has joined #zig
earnestly has quit [Ping timeout: 256 seconds]
a_chou has quit [Quit: a_chou]
marnix has quit [Ping timeout: 268 seconds]
marnix has joined #zig
hf69 has quit [Ping timeout: 268 seconds]
marnix has quit [Read error: Connection reset by peer]
marnix has joined #zig
marnix has quit [Ping timeout: 256 seconds]
marnix has joined #zig
gpanders has quit [Ping timeout: 268 seconds]
semarie has quit [Ping timeout: 256 seconds]
gpanders has joined #zig
semarie has joined #zig
gpanders has quit [Ping timeout: 256 seconds]
xackus__ has joined #zig
marnix has quit [Read error: Connection reset by peer]
marnix has joined #zig
marnix has quit [Read error: Connection reset by peer]
marnix has joined #zig
Ekho has quit [Quit: CORE ERROR, SYSTEM HALTED.]
Ekho has joined #zig
xackus__ has quit [Quit: Leaving]
xackus has joined #zig
cole-h has quit [Ping timeout: 256 seconds]
FireFox317 has joined #zig
FireFox317 has quit [Quit: Leaving]
hnOsmium0001 has quit [Quit: Connection closed for inactivity]
waleee-cl has joined #zig
marnix has quit [Ping timeout: 240 seconds]
marnix has joined #zig
earnestly has joined #zig
marnix has quit [Read error: Connection reset by peer]
marnix has joined #zig
mokafolio has quit [Quit: Bye Bye!]
mokafolio has joined #zig
rzezeski has quit [Quit: Connection closed for inactivity]
cren has joined #zig
kenran has joined #zig
daurnimator has quit [Ping timeout: 260 seconds]
daurnimator has joined #zig
daurnimator has quit [Quit: WeeChat 2.9]
marnix has quit [Ping timeout: 264 seconds]
marnix has joined #zig
gpanders has joined #zig
dddddd has quit [Quit: dddddd]
dddddd has joined #zig
daurnimator has joined #zig
<ikskuh>
heya andrewrk! what's the current definition multi-line literals?
<ikskuh>
do they use os dependent things?
mokafolio has quit [Quit: Bye Bye!]
marnix has quit [Ping timeout: 240 seconds]
mokafolio has joined #zig
mokafolio has quit [Client Quit]
marnix has joined #zig
mokafolio has joined #zig
<rowbee>
hey, what can i use for something akin to python's set? should i use something like AutoHashMap with keys and values of the same type and just set the keys and values to the same value?
<rowbee>
i need fast existence checking
<rowbee>
AutoArrayHashMap*
marnix has quit [Read error: Connection reset by peer]
marnix has joined #zig
<daurnimator>
rowbee: you can use `void` as the value.
<rowbee>
i see
<rowbee>
so it would just keep the hashes and no values
<rowbee>
what about iterating over the values in it? then i would need to do what i first described yes?
<daurnimator>
that would just be iterating over the keys
<rowbee>
but would it return the original values?
<dutchie>
if you have an `AutoHashMap(Foo, void)` then iterating will give you a series of Entry structs like `struct { key: Foo, value: void }`
<dutchie>
(same for AutoArrayHashMap) you'd insert with something like `try hm.put(foo, {})`
<dutchie>
`var it = hm.iterator(); while (it.next()) |entry| // do stuff with entry.key`
nycex has joined #zig
nycex- has quit [Ping timeout: 240 seconds]
donniewest has joined #zig
<dch>
frank denis' talk, intro to zig's std.crypto, is quite possibly the best general crypto introduction i've seen. all the things naturally lead from one to the other. chapeau!
<dch>
and I learned about aegis cipher as well *winning*
<ifreund>
yeah it was awesome, he's certainly a well qualified speaker :D
notzmv has quit [Read error: Connection reset by peer]
marnix has quit [Read error: Connection reset by peer]
marnix has joined #zig
gpanders has quit [Ping timeout: 272 seconds]
marnix has quit [Ping timeout: 272 seconds]
wilsonk_ has quit [Ping timeout: 240 seconds]
marnix has joined #zig
frmdstryr has joined #zig
rzezeski has joined #zig
Astronothing has joined #zig
<Astronothing>
Hello. I have a question regarding licensing. I want to start from Andrew Kelley's tetris project (https://github.com/andrewrk/tetris) and attempt to implement deferred rendering. I want to keep the MIT license but change the copyright of the project. Is there a standard way of keeping Andrew's copyright and mentioning it's a derivative work?
gpanders has joined #zig
hf69 has joined #zig
<dch>
Astronothing: no. you can't change copyright of somebody else's contribution.
<dch>
Astronothing: *your* contributions go in, under *your* copyright.
<dch>
Astronothing: but you *can* *relicense* the work, in some circumstances. e.g. if the overall work is a *GPL variant then the MIT portion of that is a subset of GPL generally.
<dch>
I suspect thats what you actually wanted anyway, though. My rule of thumb with FLOSS is where possible to preserve the license of the original author, in the newer work. It just feels right
<dch>
and if this work is significant enough that licensing it correctly is important, then you need an actual lawyer and not some rando IRC opinion....
<Astronothing>
Yes, I want to keep the copyright and the license, but I also want to add my own. My question is: is there a standard way to do this?
<Astronothing>
Also, since this is a derivative, it will use the same root directory, it won't be packaged as a dependency
<dch>
the single best way to do this, is to put your & their code in separate files, and include them together. Use SPDX-License-Identifiers at the top of each file
<dch>
if you're modifying existing code, I generally add my copyright notice below the OG
<fengb>
There's no need to add license text to files that are missing them
<Astronothing>
Aight, thanks!
haliucinas has quit [Ping timeout: 265 seconds]
<dch>
^this is a good point, in general, this is what's been done in the past, however best practice is to ensure that every file has a whopping annoying licence blob at the beginning.
<fengb>
Zig proper has switched over to the license blob
<fengb>
Mostly because we've had some bad faith actors
<fengb>
If you're using the same MIT license, including the original license file as renamed should be fine
<dch>
#sadpanda
<fengb>
If you're doing something like GPL, it's technically fine but kinda bad form since there'd be an implicit relicense unless you split up the file structure
<fengb>
(MIT allows you to relicense as GPL, but it's kinda annoying to add more restrictions)
<Astronothing>
fengb: I understand, and I license all my open source contributions under MIT (used to use WTFPL but people were annoyed)
<dch>
I have a rather large body of ALv2 code that somebody relicenced to MPL, and removed copyright. In the end I just ignored it.
<ifreund>
:(
<dch>
I just checked, some of it is now BSD-2Clause...
<fengb>
The solution is writing code so shitty nobody wants to steal it
wilsonk has joined #zig
haliucinas has joined #zig
<companion_cube>
andrewrk: I don't know of any thread safety feature that doesn't rely on advanced type systems (linear types and borrowing like rust, or the weird capabilities of pony). In more restricted settings I think the Ada tasks seem like a pretty amazing form of concurrency that is known to work well even in bare metal or embedded settings.
marnix has quit [Ping timeout: 256 seconds]
marnix has joined #zig
marnix has quit [Read error: Connection reset by peer]
marnix has joined #zig
marnix has quit [Ping timeout: 240 seconds]
marnix has joined #zig
TheLemonMan has joined #zig
<TheLemonMan>
Windows CI is OOM-ing like crazy, again :(
tomku has quit [Ping timeout: 256 seconds]
marnix has quit [Read error: Connection reset by peer]
marnix has joined #zig
tomku has joined #zig
<TheLemonMan>
dch, you're running freebsd, right?
reductum has joined #zig
Akuli has joined #zig
benjif has joined #zig
<scientes>
fengb, nice solution
marnix has quit [Ping timeout: 272 seconds]
marnix has joined #zig
lucid_0x80 has quit [Ping timeout: 240 seconds]
<dch>
TheLemonMan: yes
hnOsmium0001 has joined #zig
riba has joined #zig
wootehfoot has joined #zig
cole-h has joined #zig
<andrewrk>
TheLemonMan (and anyone else who is interested) we've started doing weekly stage2 meetings/discussions on Thursdays. The next one is today, in 1 hour 30 minutes from now. If you want to join it's on Discord
<TheLemonMan>
I'll try to join later if I ever figure out how to use this discord thing
<TheLemonMan>
I feel old
<dch>
TheLemonMan: everybody aged 20 years during 2020.
<TheLemonMan>
that explains a lot
<TheLemonMan>
dch, if you ever feel bored you could try to enable the segfault handler on freebsd. The prerequisite is a translation of ucontext_t (or whatever you have in the BSD land) to zig, but that should be it
<dch>
will do - not for a few days yet until the paperwork dies down
<TheLemonMan>
paperwork?
<dch>
annual tax returns
<TheLemonMan>
great! I now need to rope in semarie for OpenBSD and somebody else (kubkon?) for the osx part
<ikskuh>
i have a test failing on windows because github CI has autocrlf
<andrewrk>
Astronothing, generally it's ok to copy+paste snippets of MIT licensed code. my intention with the tetris project is that you could use any of it without fear of breaking copyright
<ikskuh>
andrewrk: why i'm asking is that a test has two more characters than i expect and i suspect a sneaky CR somewhere
<andrewrk>
companion_cube, sounds like you're talking about compile-time safety, but I would settle for runtime safety checks with helpful diagnostics
riba has quit [Ping timeout: 264 seconds]
<andrewrk>
you should tell your version control system to stop mangling your code
<ikskuh>
mhm
<ikskuh>
git has horrible defaults
<ifreund>
0 clause BSD is my goto for example projects
<companion_cube>
andrewrk: sure. but still look at Ada :p
<companion_cube>
it's a nice abstraction afaict
<TheLemonMan>
I wonder when \r\n turned into \n alone, the former makes a lot of sense if you think of a terminal
<companion_cube>
if you think of a typewriter maybe
<TheLemonMan>
time to bring back the good old RS then
<TheLemonMan>
that's how you solve the crlf vs cr vs lf debate
<ikskuh>
yeah
<fengb>
EBCDICNL
<ifreund>
well I think a single cr is unambigously wrong
<TheLemonMan>
what about "NEWLINE"? you can't get any more explicit that that?
<ikskuh>
:D
<ikskuh>
> error: unable to build stage1 zig object: FileNotFound
<ikskuh>
huh, that's a new one
<ikskuh>
the CI triggers this error
<ifreund>
that means it cant find the source file it's supposed to build most likely
reductum has quit [Quit: WeeChat 2.9]
<ifreund>
I just opened a PR making it print the path when failing to open the path passed to --pkg-begin, probably could use something doing the samething for whatever case you've it
<ifreund>
*hit
<ifreund>
TheLemonMan: does the patch you just posted still allow passing pointers to zig types as the void* context of callbacks for example?
<TheLemonMan>
yeah, the check affects only the prototype
<ifreund>
ah, makes sense
ziguana[m] has joined #zig
ziguana[m] has quit [Quit: authenticating]
ziguana[m] has joined #zig
ur5us has joined #zig
gpanders has quit [Ping timeout: 256 seconds]
<ikskuh>
ifreund: a thanks! it's missing the recursive checkout
<ifreund>
heh, same thing happened to me which spurred the PR :D
marnix has quit [Read error: Connection reset by peer]
marnix has joined #zig
<ugla>
Is there anything I can use in build.zig to check if a library exists? I would like to support two different versions of a system C library.
tdeo has quit [Read error: Connection reset by peer]
tdeo has joined #zig
<ifreund>
ugla: how would you do this in a Makefile? You can of course shell out to pkg-config or something
gpanders has joined #zig
<ifreund>
we should probably have API for this though, similar to meson's found() thing
sord937 has quit [Quit: sord937]
TheLemonMan has quit [Quit: "It's now safe to turn off your computer."]
Pistahh has quit [Ping timeout: 256 seconds]
Pistahh has joined #zig
<ugla>
Would be nice :) for now I added an option to link with the old version.
Pistahh has quit [Ping timeout: 268 seconds]
xackus has quit [Ping timeout: 260 seconds]
wootehfoot has quit [Read error: Connection reset by peer]
marnix has quit [Ping timeout: 256 seconds]
kenran has quit [Quit: leaving]
ur5us has quit [Remote host closed the connection]
notzmv has quit [Remote host closed the connection]
xackus has joined #zig
notzmv has joined #zig
Pistahh has joined #zig
Astronothing has quit [Quit: WeeChat 1.9.1]
<nore>
hmmm, does anyone know whether there is a way to write n nested loops (for iterating over an n-dimensional array), when n is a comptime-known variable?
<nore>
I see how to do that with a recursive function, but then the contents of the loop needs to be a function as well, and cannot refer to existing free variable
<pjz>
the recursive function could be runtime, no?
<nore>
the problem with a recursive function is what to call in the bas case
<nore>
*base
<pjz>
call the function pointer you passed in, passing it the contents of each cell
<nore>
yes, but this doesn't work if the function pointer I would like to pass had free variables
<ifreund>
your array has a comptime-known total number of elements
<ifreund>
you only need one for loop over that number
<pjz>
oh, yeah, that'd do it too
<nore>
ah, it is not an array actually
<nore>
but yes, I could iterate like that, and get the values from there
<nore>
would work actually, hmmm
<nore>
although, I would like if there was a way to write reusable code for this
<nore>
I guess that's the role of an iterator
* nore
goes to see how to write one
<ifreund>
basically a struct with a next() function returning an optional
cren has quit [Quit: cren]
<ifreund>
then you do `var it = foo.iterator(); while (it.next()) |item| {...}`
<dominikh>
I wouldn't mind if we had a single, reusable Iterator type in the standard library
<ifreund>
what advantage would that give?
<dominikh>
fewer duplications of essentially the same thing, and generic helpers for working on iterators and chaining them, maybe even things like map and reduce
<ifreund>
Pretty sure andrew considers functional style chaining like that an anti-pattern
<dominikh>
unfortunate
<ifreund>
error handling in the functions you'd pass to things like map/reduce wouldn't be pretty
<dominikh>
how so?
<ifreund>
I don't think such functions would be able to return an error set
<ifreund>
but I could be wrong, I haven't looked at implementing something like that
<dominikh>
there's always anyerror?
<ifreund>
and then you have to handle errors even when none can occur
<dominikh>
well, I have to go sleep. maybe I'll remember to look into this in the future
<ifreund>
if #6965 were to be accepted they would likely be much more ergonomic
<karchnu>
it's been at least 20 minutes that I read the documentation and I don't see how to get an integer from a string representation
<fengb>
std.fmt.parseInt
<karchnu>
fengb: thanks
<karchnu>
I started to feel dumb
<viashimo>
I have found it takes a lot of reading the std code to see what functions are available and where they live, in part because not everything has doc strings yet.