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/
kristoff_it has joined #zig
kristoff_it has quit [Ping timeout: 244 seconds]
<marler8997> so, is "--strip" the opposite of "-g" in gcc?
kristoff_it has joined #zig
<daurnimator> marler8997: I think zig always emits debug info; and then removes it from the linker.
<daurnimator> I thought there was an issue open about not generating it in the first place; but I can't find it....
<scientes> there isn't much of a use case for that besides 1) being a little faster, 2) creating easier-to-read llvmir-
<scientes> anyways, that is my opinion
<marler8997> I'm just trying to translate GCC command-line to the equivalent zig command-line
kristoff_it has quit [Ping timeout: 248 seconds]
<daurnimator> marler8997: --strip is more the equivalent of -Wl,--strip-debug
<marler8997> ok
<marler8997> any idea if there is an equivalent for -g?
<daurnimator> -g is the default in zig and can't be turned off
<marler8997> next step is to be able to invoke the C preprocessor
<marler8997> I think in general, I'm going to need the ability to invoke clang, except after libc is built and with the arguments that are required to include it
<daurnimator> marler8997: like via `zig cc`?
<marler8997> "except after libc is built and with the arguments that are required to include it"
<marler8997> clang+libc
<marler8997> looks like there is a "zig libc" command, but it doesn't seem to print the same paths that I see when compiling C code with --verbose-cc
<daurnimator> marler8997: zig libc is more like a couple of select pieces of `gcc -dumpspecs`
<marler8997> I've got a bunch of different ideas to get this to work but I'm just not sure the right path at this point
<marler8997> The end goal is to be able to call zig like it's a normal C compiler
<marler8997> I wrote a small tool that will translate basic options to zig...but now I need to be able to inoke the preprocess (-E)
<daurnimator> marler8997: have you looked at the implementation of std/build's addCSource?
<marler8997> I've looked at what the compiler does when C files are added to the command-line. I assume it's the same result
<daurnimator> marler8997: note that your "c compiler" like gcc/clang is several tools in one: it's a preprocessor, compiler, linker and more: it's probably useful to break down the operations as such.
<marler8997> right, I'm at the preprocessor point right now
<daurnimator> marler8997: so trying to map `gcc -E` invocations?
<marler8997> right now yes
<marler8997> but it seems to me that the simplest way to support all the options would be to have a way to invoke zig's clang with libc
<marler8997> And then I can provide any clang options I want, along with the options for libc
<marler8997> Or if there was a way I could pull the libc options from zig
<marler8997> I could run a simple "build-exe" and "build-obj" and read/parse the options from zig's output
<marler8997> I think that would work, but I dont' want to go implement it since I'm sure there's something simpler
<marler8997> And if I did implement that, I would probably just run the compiler before every command, enable a "dry-run" mode where it doesn't generate any output, and then re-invoke it with the command-line I got and any options I want to add
<marler8997> another idea is to add a "--c-args" where zig adds those arguments to any clang invocations
<fengb> Is there a way to make a hybrid slice / ArrayList?
<fengb> Bleh I think I need a separate context to build the slice
kristoff_it has joined #zig
kristoff_it has quit [Ping timeout: 248 seconds]
nairou has quit [Quit: Leaving]
_whitelogger has joined #zig
kristoff_it has joined #zig
kristoff_it has quit [Ping timeout: 248 seconds]
<bgiannan> is there a way to import c macros too?
_whitelogger has joined #zig
_whitelogger has joined #zig
<daurnimator> bgiannan: at the moment *some* are translated. Its essentially a constantly improving set: we'll never get full coverage. But I think there's an issue around where you post your C macro and we try and make it work
<daurnimator> bgiannan: IIRC you can use --verbose-cimport to get a list of untranslateables
<bgiannan> ok. i ended up rewrite the equivalent in zig.
<bgiannan> Following the point 2 at https://ziglang.org/documentation/master/#Memory should i use the c allocator since i'm already linking 'c'?
<fengb> Yes, Zig doesn't have a general allocator yet
<daurnimator> bgiannan: yep. you can use the C heap allocator for now. one day we'll have our own....
<daurnimator> fengb: btw how did you go with your allocator. it was you I was teaching about allocators right?
<fengb> Yeah, it works™
<fengb> Test case of 1
<daurnimator> I should try and pick up my allocator again. I got sad by mismatches between C and zig allocation apis which means you actually need a worst-of-both-worlds approach
<daurnimator> (for C allocators you have a known max alignment but don't get the length passed in; for zig you get the length passed in but it can be any run-time alignment)
<fengb> I made some concessions. I have a TODO for allowing 16 bit+ alignment, but it works well enough(?) and it's much smaller than dlmalloc
<fengb> I adopted metadata right before the memory, which is where 8 bit alignment is stuck
<daurnimator> I got distracted trying to optimize for high alignment small size items.... and then went off and worked on other things
<fengb> (8 bit on wasm32)
<daurnimator> fengb: indeed. the problem with metadata before the memory is that you end up wasting.... a lot
<daurnimator> though in practice its safer....
<daurnimator> because people are much more likely to overrun the end of an allocation than use the area before
<fengb> Hmm I never thought about that
<daurnimator> With all these limitations I ended up thinking "I should just do it with a prefix tree instead"
<daurnimator> but then I thought "prefix trees are gnarly with threads; I should use a maple tree instead"
<daurnimator> and then I never wrote the maple tree implementation.
<fengb> Well I'm glad I don't care about threads or performance :P
<daurnimator> partially because there is no userspace RCU with a liberal license
<daurnimator> and so I went off to shave the RCU yak
kristoff_it has joined #zig
<fengb> Would it be worthwhile to port an existing allocator like dlmalloc or (sounds scary) jemalloc?
kristoff_it has quit [Ping timeout: 246 seconds]
<daurnimator> fengb: I don't think so. they don't allow the arbitrary alignment that zig does....
<daurnimator> nor do they usually allow multiple allocators in a single process
<daurnimator> I should just finish my "classic allocator" and put the metadata at the end
<daurnimator> so we have *something*
<fengb> I suppose I could try adopting mine to be more general purpose
<fengb> Damnit, nrdmn added my silly protobuf experiment. I was actually planning on punting on that because I can't do what I wanted :(
laaron- has quit [Remote host closed the connection]
laaron has joined #zig
<daurnimator> fengb: huh? added what where?
<hspak> anyone have a good resource for operations like 'ls' and 'cd' in zig? it's not super obvious to me from digging in the std lib
<hspak> found walkPath, looks like that's what I'm looking for
qazo has quit [Ping timeout: 272 seconds]
<hspak> interesting zig has an assert on paths that end in '/' https://github.com/ziglang/zig/blob/master/std/fs.zig#L843, I guess that's to enforce consistency?
<daurnimator> hspak: generally you should never need to `cd`... it's a bit of an antipattern
<daurnimator> hspak: but yes; for `ls` see std.fs.Dir and iterate with .next()
<daurnimator> hspak: note that walkPath is recursive (`ls` isn't)
<hspak> daurnimator: I see, thanks for the pointers!
laaron has quit [Remote host closed the connection]
laaron has joined #zig
lunamn has quit [Ping timeout: 246 seconds]
lunamn has joined #zig
ntgg has joined #zig
<bgiannan> I have a strange compile error: expected type '*.cimport:2:13.struct_SDL_Renderer', found '*.cimport:2:13.struct_
<bgiannan> SDL_Renderer'
lunamn has quit [Ping timeout: 244 seconds]
<bgiannan> complains that i give A when it expected... A
lunamn has joined #zig
casaca has quit [Ping timeout: 258 seconds]
LargeEpsilon_ has joined #zig
mmx870 has quit [Ping timeout: 245 seconds]
<bgiannan> i was doing 2 cImport of sdl
mmx870 has joined #zig
kristoff_it has joined #zig
casaca has joined #zig
kristoff_it has quit [Ping timeout: 246 seconds]
kristoff_it has joined #zig
<bgiannan> is there a for loop in the classical sense? `for (var i = 0; i < 10; i++) ...` ? I only see example of `for` over an array/slice
kristoff_it has quit [Ping timeout: 268 seconds]
kristoff_it has joined #zig
<bgiannan> if i understand the doc correctly, `for` is only used to iterate over array and slices so i should use `while`
<daurnimator> bgiannan: that's correct
<bgiannan> ah there's a continue expression
<bgiannan> so should be: `var i = 0; while (i < 10) : i += 1 {...}`
<bgiannan> ?
<daurnimator> yep. but you'll still need to declare your loop variable. `var i = usize(0); while (i < 10) : (i += 1) { .... }`
<daurnimator> note that you need parenthesis for the continue expression
<daurnimator> also that you'll need to pick the variable type of the index
<bgiannan> so there's no default arguments and i can define the same functions with different arguments either? do i have to declare several functions with different names which provide the default values?
<daurnimator> yes
<bgiannan> or maybe i could make those arguments optional? i would have to pass null but at least i'm not redefining X functions
<daurnimator> if you want to, sure
ltriant has quit [Quit: leaving]
return0e_ has quit [Ping timeout: 245 seconds]
laaron has quit [Remote host closed the connection]
laaron has joined #zig
ntgg has quit [Quit: Lost terminal]
redj has quit [Read error: Connection reset by peer]
marler8997 has quit [Read error: Connection reset by peer]
redj has joined #zig
<bgiannan> i do i get the size of an array?
<gonz_> `array.len`
<bgiannan> thx
<gonz_> I realize now that wasn't really an answer to getting the size, but I hope it made sense
laaron has quit [Remote host closed the connection]
laaron has joined #zig
kristoff_it has quit [Ping timeout: 258 seconds]
casaca has quit [Ping timeout: 258 seconds]
casaca has joined #zig
laaron has quit [Remote host closed the connection]
casaca has quit [Ping timeout: 245 seconds]
laaron has joined #zig
casaca has joined #zig
<bgiannan> how do i print a string when its a [*]const u8 (coming from C)?
mattmurr has left #zig ["User left"]
tiehuis has joined #zig
<tiehuis> bgiannan: use '{s}' to print a null-terminated pointer/string
<bgiannan> ah thx
tiehuis has quit [Quit: WeeChat 2.5]
NI33 has joined #zig
samtebbs has joined #zig
LargeEpsilon_ has quit [Ping timeout: 248 seconds]
LargeEpsilon_ has joined #zig
LargeEpsilon_ has quit [Ping timeout: 244 seconds]
return0e has joined #zig
LargeEpsilon_ has joined #zig
kristoff_it has joined #zig
kristoff_it has quit [Ping timeout: 246 seconds]
LargeEpsilon_ has quit [Ping timeout: 244 seconds]
LargeEpsilon has joined #zig
laaron has quit [Remote host closed the connection]
laaron has joined #zig
laaron has quit [Remote host closed the connection]
laaron has joined #zig
kristoff_it has joined #zig
kristoff_it has quit [Remote host closed the connection]
kristoff_it has joined #zig
laaron has quit [Quit: ZNC 1.7.1 - https://znc.in]
laaron has joined #zig
laaron has quit [Client Quit]
laaron has joined #zig
laaron has quit [Client Quit]
laaron has joined #zig
laaron has quit [Client Quit]
laaron has joined #zig
laaron has quit [Client Quit]
laaron has joined #zig
laaron has quit [Client Quit]
laaron has joined #zig
laaron has quit [Remote host closed the connection]
laaron has joined #zig
waleee-cl has joined #zig
<fengb> Is there a way to add a declaration to a struct at comptime?
halosghost has joined #zig
<scientes> fengb, you can have two versions of the struct chosen at comptime
<scientes> yeah, you could probably do that
<scientes> oh, except its a const
<scientes> and it kinda has to be a const
<scientes> because other code gen depends on the way the struct is layed out
<fengb> I need a separate struct declaration not a field. I want to add a "tag" to a struct
<scientes> yeah i don't know what you mean by tag
<fengb> Only needed for comptime reflection uses
<scientes> that would be really problematic to implement
<scientes> because you are creating dependency issues
<scientes> reading is fine
<scientes> but writing is complicated
<fengb> Alright
<fengb> My other solution is shove the number into the type when I create it. It's less elegant but that's fine
<scientes> if we want a comptime database, then create a comptime database
<fengb> It's just to emulate Go tags or Java annotations
laaron has quit [Remote host closed the connection]
<fengb> I mean, yes I'll create a comptime lookup of sorts, but this localizes the data so I don't have to cross reference it
<scientes> oh weird
laaron has joined #zig
<fengb> Yeah they're just reflection data that has no natural code meaning
<scientes> I get the use case, but I'm not sure its worth it
<scientes> it seems like an abuse of a turing complete language
<scientes> that such data should be in a non-turing complete language
<fengb> Then this generated code would be hideous
<fengb> Again, I can create a manual mapper, but then it'd be write-only
<fengb> I really just need the field number. Zig represents everything else pretty well
<scientes> well if we had comptime file handling, then you could even write your own parser
<scientes> maybe....
<fengb> I plan on doing that too
<fengb> But I still like the generated code to be readable
<scientes> then just name the fields by the name of the tag
<fengb> The field number is the problem
<scientes> the number could be the name
<fengb> But then it's not named
<fengb> And at that point, it's adhoc tags
<scientes> if they really are numbered then you can access them with typeinfo
<scientes> cause the compiler numbers them
<fengb> The numbers aren't always sequential
<fengb> And they can be missing
<scientes> oh ok
<fengb> I'd like a tagging system, but I'm okay without them if I can figure out a decent way around them
<samtebbs> fengb: I haven't followed the conversation but does this help? http://rants.tgschultz.com/A%20Brief%20Tour%20of%20the%20Comptime%20Pseudo-Struct.txt
<fengb> I looked at that and got scared
<scientes> samtebbs, >Zig can't (and probably won't ever) infer return types.
<scientes> there is a bug for that, and I kinda need it for doing SIMD stuff in user-space instead of the compiler
<fengb> Yeah I'm not a big fan of inferred return types
<fengb> At least... not without a working IDE
<scientes> yeah I get the complaint
lunamn has quit [Ping timeout: 268 seconds]
<scientes> but how else am I suppose to concatenate two vectors?
<scientes> otherwise it ends up as a compiler builtin, and I'm trying to avoid those as much as possible
<mq32> scientes, can't you just query vector size?
<mq32> so two-step return type inferring?
<scientes> that would be really ugly
<mq32> fn(a : var, b : var) inferReturnTypeForTwoVecs(a,b) { }
<scientes> but yeah that would work
lunamn has joined #zig
<scientes> the actual concatenation is done with @shuffle
<scientes> there is also a patch in that series where you can do arr[idxs] = vector
<scientes> where idxs is a vector of indexes
<scientes> which i thought was pretty slick
<scientes> but only when arr is a vector right now and idxs is constant
<scientes> i'm working on doing it with arrays
<scientes> multiple concurrent assignment
<scientes> and load
<mq32> scientes: as you're working on vectors: is swizzling possible (maybe even @shuffle is swizzling)?
<scientes> not exactly sure what swizzling is, but i'm pretty sure that is shuffle
<scientes> @shuffle is very versitile
<scientes> and I made the zig version even more versitile
<scientes> as the vector sizes don't have to match
<mq32> swizzling is the shader coding term for
<mq32> "vec.xyz = vec.wzz"
<mq32> so indexing a vector with kinda arbitrary indizes
<scientes> if the index is variable then @shuffle can't do that
<scientes> and such instructions are only really available on x86 AFAIU
<mq32> GPUs do it even in assembler
<scientes> I'm pretty sure swizzling is supported
<mq32> so you can just expand a float to a vec4 by using "f.xxxx"
<scientes> one float?
<scientes> that would be @splat()
<scientes> (which is implemented in llvm with @shuffle)
<mq32> hmm
<scientes> but ppc for example has a special instruction for that
<scientes> *special instructions
<mq32> do you plan to index .x, .y and such for vector types?
<scientes> there was a guy doing that type of stuff with what is already there
<mq32> the documentation on what is there for vectors is a bit sparse ^^
<scientes> mq32, are you working from my patch series?
<scientes> cause I did add documentation
<mq32> ah
<scientes> not any examples
<mq32> then i have to look that up!
<mq32> do you have a link?
laaron has quit [Remote host closed the connection]
laaron has joined #zig
LargeEpsilon has quit [Ping timeout: 245 seconds]
LargeEpsilon has joined #zig
casaca has quit [Ping timeout: 246 seconds]
halosghost has quit [Quit: WeeChat 2.5]
halosghost has joined #zig
casaca has joined #zig
qazo has joined #zig
qazo has quit [Read error: Connection reset by peer]
laaron has quit [Remote host closed the connection]
avoidr has joined #zig
LargeEpsilon has quit [Ping timeout: 245 seconds]
Akuli has joined #zig
wilsonk__ has quit [Ping timeout: 258 seconds]
LargeEpsilon has joined #zig
casaca has quit [Ping timeout: 245 seconds]
casaca has joined #zig
LargeEpsilon has quit [Ping timeout: 244 seconds]
wootehfoot has joined #zig
<andrewrk> daurnimator, --strip prevents debug info from being generated, as well as setting a comptime global constant, which the std lib notices and avoids trying to dump a stack trace when it knows there's no debug info
<andrewrk> there's one little issue left, where *some* debug info is generated. the feature is almost complete
<andrewrk> oh I don't think marler knows that you can pass any C cli args between --c-source and the next positional argument
wilsonk_ has joined #zig
LargeEpsilon has joined #zig
andersfr has joined #zig
andersfr has quit [Client Quit]
FireFox317 has joined #zig
kristoff_it has quit [Ping timeout: 248 seconds]
<Tetralux> Is std.Buffer.appendByte meant to panic if .len == 0?
kristoff_it has joined #zig
<Tetralux> Only I was under the impression that it was just a zero-terminated array.
kristoff_it has quit [Ping timeout: 245 seconds]
slice has quit [Ping timeout: 252 seconds]
slice has joined #zig
marler899776 has joined #zig
<marler899776> andrew just saw your message about --c-source...
<marler899776> I'm not sure I understand though, how would I pass say "-E"?
<marler899776> oh wait, you're saying until you see an argument without a "-" in front of it
<marler899776> got it
plumm has joined #zig
<Tetralux> Should you be able to do this: `var x: EnumType = if (cond) .A else .B;`
<Tetralux> Only I feel like I should, since I gave it the type.
<Tetralux> And if you shouldn't be able to, why not?
<fengb> Peer type inference overwrites result type inference right now
<fengb> So yes you should be able to but no it’s not working right now
<FireFox317> This PR solves that: https://github.com/ziglang/zig/pull/2867
<fengb> Oh it’s a PR already?
<FireFox317> Yes, but i'm not sure if my implementation is correct, it does pass the tests tho
<fengb> I think this is a different issue: https://github.com/ziglang/zig/issues/2749
<plumm> quick question, any reason why @typeName(@typeOf(A.B.c)) (where A is a struct and B is a nested struct, with c being a boolean property of B)
<plumm> does not compile?
<andrewrk> B.c is not valid, there is no instance of B to access c from
<andrewrk> there is a way to do what you're trying to do however
<andrewrk> marler899776, it's not perfect because if any C cli args take a positional argument then it'll get messed up. we'll need to adjust that CLI at some point to handle this
<marler899776> yeah
<marler899776> --c-args-start ... --c-args-end ?
<fengb> plumm: std.meta.fieldInfo(A.B, "c")
<plumm> thx!
<marler899776> hmmm, I don't see the --c-source arguments getting forwarded to "zig cc"
<marler899776> zig build-exe --name a.out --library c --c-source hello.c --verbose-cc --c-source -E
<marler899776> .4.0+3f7f5200/lib/zig/libc/include/x86_64-linux-gnu -isystem /home/marler8997/bin/zig-linux-x86_64-0.4.0+3f7f5200/lib/zig/libc/include/generic-glibc -isystem /home/marler8997/bin/zig-linux-x86_64-0.4.0+3f7f5200/lib/zig/libc/include/x86_64-linux-any -isystem /home/marler8997/bin/zig-linux-x86_64-0.4.0+3f7f5200/lib/zig/libc/include/any-linux-any -mar
<marler899776> ch=native -g -fno-omit-frame-pointer -D_DEBUG -fstack-protector-strong --param ssp-buffer-size=4 -fPIC -o zig-cache/tmp/Tm_l3etbxNYV-hello.o -c hello.c
<andrewrk> marler899776, the args go between --c-source and hello.c
<andrewrk> it's hard to read that output, might be time for a pastebin-like service
<marler899776> ok thanks, I'll try to remember to use pastebin in the future as well
<marler899776> cool, now I'm able to pass -E to "zig cc", but of course not it fails because zig is expecting the output file to be an object file
<marler899776> there's a couple ways I can think of to get this "Zig C Compiler Emulation" tool to work, I'm wondering which route we should go
<marler899776> The best idea I have so far is to be able to run "zig cc", but then have a way to signal it to add any applicable libc arguments as well
<marler899776> Or if there was some way to query the zig compiler for what those libc arguments might be?
<marler899776> That way we could expose any clang functionality without also having to have an equivalent in zig
LargeEpsilon has quit [Ping timeout: 245 seconds]
wootehfoot has quit [Read error: Connection reset by peer]
<FireFox317> andrewrk: I see you merged my PR and added a way to specify the target for the compiler error tests, but since it generates a compiler error on every target and no assembly, does it make sense to specify a target?
<andrewrk> FireFox317, I actually thought it would be an error if the assembly mismatched the target, but I see now that the other error is checked first. so either way would be fine in this case. but the idea is to isolate only the one error, for each compile error test, so I do think this is better
<FireFox317> Uhm yes, but for the test that I added it is not a target specific compiler error, so the target shouldn't be specified right? And right now we get an LVVM error when the assembly is not valid on a target.
<FireFox317> The compiler error I added checks if the variable (thing inside %[..]) is actually specified in the inputs or outputs of the inline assembly.
<andrewrk> it is a target specific test case because it has inline assembly
<andrewrk> there's no requirement for the compiler to check whether or not the parameter exists before checking that the assembly matches the target
<Tetralux> Is std.meta.isSlice(type) meant to return false for []const u8?
<Tetralux> That seems wrong to me.
<FireFox317> Well, I think that we always first have to check if a variable inside a inline assembly template is not defined, because if it is not then the inline assembly doesn't make any sense. That is how I see it
<FireFox317> But for now it is fine anyway, it works and for the self hosted compiler it could be better
<andrewrk> FireFox317, thanks for the patch
<andrewrk> FireFox317, it's not out of the question for zig to gain more intelligent understanding of assembly; in this case the compiler could participate more in the syntax and awareness of inline assembly semantics
<FireFox317> andrewrk: You are welcome!
FireFox317 has quit [Read error: Connection reset by peer]
FireFox317 has joined #zig
kristoff_it has joined #zig
waleee-cl has quit [Quit: Connection closed for inactivity]
kristoff_it has quit [Ping timeout: 246 seconds]
FireFox317 has quit [Remote host closed the connection]
<marler899776> quick question, how do you access the "tag" field of a tagged union?
jrudolph has joined #zig
<andrewrk> marler899776, implicit cast to the enum tag type
<marler899776> thanks
Tetralux has quit [Ping timeout: 272 seconds]
bheads has quit [Ping timeout: 246 seconds]
plumm has quit [Quit: leaving]
Tetralux has joined #zig
halosghost has quit [Quit: WeeChat 2.5]
Akuli has quit [Quit: Leaving]
Tetralux__ has joined #zig
Tetralux has quit [Ping timeout: 272 seconds]
kristoff_it has joined #zig
kristoff_it has quit [Ping timeout: 244 seconds]
marijnfs has joined #zig
marijnfs_ has joined #zig
marijnfs has quit [Ping timeout: 252 seconds]
_whitelogger has joined #zig
_whitelogger has joined #zig
<Tetralux__> Q: What's the best way to deal with a situation where you do a fn call to start something, you get back a token of some sort, and you `defer token.finish()` or whatever.
<Tetralux__> Problem is, both starting and finishing the thing can fail.
Tetralux__ is now known as Tetralux
<Tetralux> So you can't defer it.
_whitelogger has joined #zig
<Tetralux> Yes, BUT, because you're returning it, it'd copy it into the `thing`.
<fengb> It wouldn't disappear. Previously it creates a copy upon return, and copy it into the result location
<Tetralux> fengb: *finger guns*
tgschultz has quit [Read error: Connection reset by peer]
<donpdonp> ah, the Self{..} in init would be in the init callstack memory, then copied into the spot inthe callstack for the return value.
tgschultz has joined #zig
<fengb> yep
<donpdonp> but now its copied into the address of what its being assign to.
<Tetralux> Indeed.
<Tetralux> Except "copy" = "write"
<Tetralux> So there's no copy.
<donpdonp> well that helps a lot thx.
<Tetralux> o7
<donpdonp> i not saying I would write it but ive toyed with the idea of a zig basics document and came up with a title: "Zig Pointers" get it?
<donpdonp> to answer my own other question about the "address" of the return value of init, there is no other address other than &thing because the struct is copied into the ram that was created on the stack for thing (being a var thing: OtherThing and not a pointer)
<donpdonp> it really does work more like a param to init() than thing = init()
<andrewrk> yes
<Tetralux> Indeed - though that part about it really working like a param to init; I should note that's _because_ init returns a _value_. ;)
<Tetralux> Any fn that returns a value will work like that.
<donpdonp> aaand my problem is fixed now by using allocator.create() \o/ \o/ im getting nice unique structs at OtherThing()@21f6590 OtherThing()@2342100. Otherthing is actually a Mastodon Toot for https://donpdonp.github.io/zootdeck/
<Tetralux> Curious :3
kristoff_it has joined #zig
<donpdonp> that shows the two kinds of inits. if I var thing = allocator.create(OtherThing) and thing = OtherThing.init() could I keep using fn init() Self{ return Self{} } and it would be copied into the heap?
<Tetralux> YES
<donpdonp> id argue that that shortcut is actually not a great idea because here I am reassigning it and yet its dependent on the previous value
<Tetralux> The thing you get back from .create is undefined.
<andrewrk> donpdonp, for the heap one it should be `const thing_ptr` not `var thing`
<Tetralux> So you HAVE to set it.
<donpdonp> oh. interesting.
<Tetralux> And yes, as andrewrk said, you get a *OtherThing back from create.
<andrewrk> and then to initialize it you would do thing_ptr.* = init()
<Tetralux> ^^
<Tetralux> andrewrk: beat me to it :p
<donpdonp> okay so THATS the pattern Im missing.
<Tetralux> HUZZAH
<Tetralux> BY JOVE I THINK THEY HAVE IT.
<andrewrk> donpdonp, does it make sense why it would be const?
kristoff_it has quit [Ping timeout: 268 seconds]
<donpdonp> well if thing_ptr were only assigned to once, that would keep later code from changing it?
<andrewrk> correct
<andrewrk> just one less accident to worry about
<donpdonp> 'The thing you get back from .create is undefined.' thats still puzzling.