ChanServ changed the topic of #zig to: zig programming language | ziglang.org | be excellent to each other | channel logs: https://irclog.whitequark.org/zig/
porky11 has quit [Quit: Leaving]
mnoronha has quit [Ping timeout: 240 seconds]
return0e has quit []
renatorabelo has quit [Quit: Leaving]
mnoronha has joined #zig
mnoronha has quit [Ping timeout: 244 seconds]
noonien has quit [Quit: Connection closed for inactivity]
mnoronha has joined #zig
mnoronha has quit [Ping timeout: 252 seconds]
mnoronha has joined #zig
davr0s has quit [Read error: Connection reset by peer]
qazo has joined #zig
qazo has quit [Ping timeout: 240 seconds]
qazo has joined #zig
qazo has quit [Ping timeout: 260 seconds]
Elronnd has joined #zig
<Elronnd>
I'm looking at zig and I see in one place pub main() !void and in another pub main() void. What does the ! mean?
<scientes>
Elronnd, an error can be returned
<scientes>
Elronnd, if an error is returned in main, it generates a stack trace (in debug mode)
<Elronnd>
ahh
<Elronnd>
why is '\t' a disallowed character?
<scientes>
you have to use spaces
<Elronnd>
yes, but why?
<dirkson>
That's a long story. Short version is that the language designer hates tabs. Longer version involves some explanation about wanting the compiler to know the screenspace position of all keywords for some reason. I don't understand it yet, but there's a github issue about it
<scientes>
I have a pet peeve of people that question stuff that can be easily worked around
<scientes>
bikeshedding
<dirkson>
scientes: I have a pet peeve of people that force others to use their tab conventions. Somehow we must coexist :D
<dirkson>
There has been some indication that tabs will be allowed through some pre-compiler formatter. It's unclear if this will allow complex things, like erroring when tabs are used somewhere other than the start of a line.
<dirkson>
There's a language called 'nim' that uses the same formatter approach. As someone who prefer tabs-for-indent, I found it annoying, but acceptable.
<Elronnd>
I like the way ante does it
<Elronnd>
if you don't have any braces, it will use whitespace for indentation and error if you don't do it right
<Elronnd>
if you do have braces, then it ignores all whitespace
<dirkson>
Actually, thinking about Nim makes me remember why I gave up on it - Namely, the fact that arguments could be implicitly typed, and return values could be implicitly typed, leading to an insane amount of searching to find out what any function actually did. I really worry about Zig in this regard, as it seems these are planned features. I struggle to imagine good enough tool integration to make that tolerable.
<scientes>
yeah I see implicit typing in places, like siphash
<scientes>
its confusing
<scientes>
I am also confused on how it even works
<dirkson>
I think I've got a rough idea how it works. It's just that it's not really human-readable when looking at code you didn't write. You've got to have some tool to dig down and find the types that a function can potentially operate on
<c15ade4>
dirkson: implicitly typed arguments are deprecated in nim
<dirkson>
c15ade4: Oh. Interesting!
<dirkson>
c15ade4: Do you know why, offhand?
<c15ade4>
who gives a shit about tabs btw, just run the automatic formatter and forget about it
<c15ade4>
probably the reason you said
mnoronha has quit [Ping timeout: 240 seconds]
<c15ade4>
its pretty silly to go through the trouble to learn a whole new programming language
<c15ade4>
but not be able to readjust to invisible characters being diferent
<c15ade4>
*rant mode off*
<dirkson>
I've not been able to get my editor (vim) to treat X number of spaces and a tab identically. Which seems odd, given how often people bicker about it. So that means I need some third party tool to use tabs, like the formatter, which is another arbitrary things I have to memorize and get right in every file. It's also a bit of a code smell - If someone cares strongly enough about tabs vs spaces to force you to use
<dirkson>
one over the other, they will probably care deeply about other trivialities too - And not all of those are as harmless as invisible characters. This seems particularly salient when the language doesn't use whitespace as meaning, as Zig doesn't.
renatorabelo has joined #zig
<dirkson>
So like... It's minor, and there's plenty of stuff I hate more about other languages, so the tab thing isn't going to scare me off... But it's a definite, if small, negative mark.
<c15ade4>
its not a triviality - it makes git diffs better, it makes code search easier, it makes things consistent
<c15ade4>
If zig fmt could support either it might be nice
<c15ade4>
but you need one canonical form
<dirkson>
What's 'it' here? Using spaces in place of tabs?
<c15ade4>
enforcing one or the other
<dirkson>
Ah, gotcha
<c15ade4>
if you chose tabs then you just will have space people complaining
<c15ade4>
at least with space the compiled can say col 7
<Elronnd>
c15ade4: yes exactly, so where do you draw the line? And how do you decide that a line must be drawn in the first place?
<andrewrk>
until this is closed, zig has no general purpose allocator in the standard library
<Elronnd>
andrewrk: so I should just link against libc and use that?
<Elronnd>
ok
<andrewrk>
however we do have some special purpose allocators. for example if you are making a command line application, an ArenaAllocator would be appropriate
<andrewrk>
but there's no shame in linking libc to get a feature missing from the standard library
<andrewrk>
that said, zig does plan to have all the stuff so you'd never need to do that :)
<dirkson>
Hmm. No, printing out meaningful column numbers is doable with both tabs and spaces. Vim, at least, outputs a number in the lower right that corresponds to a column number if you counted each tab as a single character.
<dirkson>
(And also a screenspace column number that counts each tab as $TabWidth characters)
<Elronnd>
I'm using readFileAlloc. So, just to be clear, I have to call freeFn on the memory it gives me once I'm done with it?
<andrewrk>
Elronnd, that's right, unless you are ok with the memory leaking
<andrewrk>
generally, every call to readFileAlloc will be followed by either a `defer` or an `errdefer`
<andrewrk>
and if it's followed by errdefer, then there will be an additional place where the cleanup code goes
<Elronnd>
defer means defer until end of lexical scope? Or function?
<dirkson>
And I lack the knowledge of nano or emacs to make either of them print out any kind of column number at all :D
<andrewrk>
Elronnd, lexical scope
<andrewrk>
note that go defer is different; it appends the defer expression to a list to execute at the end of the function. if you do this in a loop it requires memory allocation and therefore it can fail
<Elronnd>
dirkson: vim will show you the column number by default if you set ruler ;)
<scientes>
I noticed that stack allocation in linked to the function, not lexical scope, however
<dirkson>
Elronnd: Yeah, I must have set that up at some point.
<andrewrk>
scientes, indeed, although I don't see the analogy
<andrewrk>
consider the behavior of stack allocation in a loop
<andrewrk>
if you declare a variable in a loop, it's not actually stack allocating at each iteration. "stack allocation" is as simple as subtracting the total number of needed stack bytes from a register at the beginning of the function
<scientes>
well c89 allows variable declarations at every lexical scope, so always assumed the stack would get extended at each lexical scope, until i saw otherwise
<andrewrk>
you can think of it as a union
<scientes>
will it at least reuse the stack for differn't lexical scopes that are independent of each other, in a function?
<andrewrk>
yes: {var a: i32; {var b: i32;} {var c: i32;}} - the size needed for the stack is 8 bytes, not 12
<scientes>
ah ok, so what i saw was just the side-effect of the in-function allocation growing upwards, while entering a function allocates downwards
<Elronnd>
scientes: I always thought that it just moved those to the top transparently
<scientes>
so if a function over-flows the stack, it will get SIGSEGV on the first variable
<scientes>
(if it in initialized)
<andrewrk>
it's possible for the stack frame to be larger than the guard page, in which case it's possible to not get a sigsegv
<andrewrk>
some targets such as windows have solutions to that problem
<scientes>
you will still most likely get SIGSEGV beyond the guard page
<andrewrk>
one would hope
<andrewrk>
even better than a SIGSEGV, is determining at compile-time the upper bound stack requirements
<scientes>
is there a reason variables are alloocated upwards in a function?
<scientes>
i would think you would be more likely to hit the guard page if you did it the other way around
<andrewrk>
I'm not sure. that's a decision made by LLVM's lowering code
<andrewrk>
good night
<scientes>
the other way also means you allocate less lazy memory
<scientes>
good night
<Elronnd>
is there a way to convert a string literal to a slice? I tried putting [0..] after it but that complained that it's a const []u8, not plain []u8
<scientes>
Elronnd, its still a slice
<scientes>
just a const slice
<scientes>
you mean []const u8
<Elronnd>
err, yeah
<Elronnd>
is there something like .? but for error types?
qazo has joined #zig
qazo has quit [Ping timeout: 240 seconds]
darithorn has quit [Quit: Konversation terminated!]
MajorLag has quit [Read error: Connection reset by peer]
MajorLag has joined #zig
mnoronha has quit [Remote host closed the connection]
qazo has joined #zig
sepisoad has joined #zig
sepisoad has quit [Quit: Page closed]
noonien has joined #zig
qazo has quit [Read error: Connection reset by peer]
qazo has joined #zig
qazo has quit [Read error: Connection reset by peer]
porky11 has joined #zig
qazo has joined #zig
qazo has quit [Read error: Connection reset by peer]
qazo has joined #zig
qazo has quit [Read error: Connection reset by peer]
qazo has joined #zig
return0e has joined #zig
qazo has quit [Read error: Connection reset by peer]
qazo has joined #zig
qazo has quit [Read error: Connection reset by peer]
qazo has joined #zig
qazo has quit [Read error: Connection reset by peer]
<andrewrk>
DutchGh0st, over 4GB you might expose bugs where the size is stored as a 32 bit integer rather than 64 (perhaps in LLVM it does this)
<andrewrk>
zig makes it easier to avoid these kind of bugs... but the compiler is not written in zig yet :)
<DutchGh0st>
but it compiled, ...
<DutchGh0st>
I got onto this idea, because in Rust there was an integer overflow resulting in a buffer overflow with string::repeat
<DutchGh0st>
in the stdlib
<andrewrk>
DutchGh0st, zig is pretty immature right now. if you go looking for bugs you're going to find them
<andrewrk>
it's not really time to start fuzzing yet
<andrewrk>
once all the breaking changes are done and all the new proposals land and there are no more planned proposals, then it's time to start fuzzing
<DutchGh0st>
I'd be interested in helping with fuzzing once the time is there :)
<andrewrk>
and I mean fuzzing metaphorically - e.g. looking for all bugs, even ones that are not blocking practical use of the language
Ichorio has joined #zig
davr0s has joined #zig
<andrewrk>
1 more bug until 0.3.0
<andrewrk>
(and a lot of release notes to type up)
<DutchGh0st>
documentation, thats always fun...
<DutchGh0st>
BUT HEY, ITS ALMOST FRIDAY, SOO THATS COOL! :D
davr0s has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
very-mediocre has quit [Ping timeout: 256 seconds]
davr0s has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
allochi has joined #zig
allochi has quit [Client Quit]
davr0s has joined #zig
urluck has joined #zig
jmiven has quit [Quit: co'o]
tom1998 has joined #zig
<tom1998>
Hey!
<tom1998>
I'm trying to figure out the zig build system - how can I execute arbitrary system commands within zig? (i.e., I want the build system to clone some dependencies and compile them with cmake)
<tom1998>
Is the idea just to call into C at the moment for anything that either isn't implemented / isn't documented?
davr0s has quit [Ping timeout: 246 seconds]
davr0s has joined #zig
wink_ has joined #zig
tom1998 has quit [Ping timeout: 244 seconds]
return0e has joined #zig
return0e has quit [Client Quit]
unique_id has joined #zig
noonien has quit [Quit: Connection closed for inactivity]