ChanServ changed the topic of #crystal-lang to: The Crystal programming language | https://crystal-lang.org | Fund Crystal's development: https://crystal-lang.org/sponsors | GH: https://github.com/crystal-lang/crystal | Docs: https://crystal-lang.org/docs | Gitter: https://gitter.im/crystal-lang/crystal
ur5us has quit [Ping timeout: 240 seconds]
<FromGitter> <mjfiano:matrix.org> Might be a dumb question, but specs gives an internal error when i switch my code to use struct instead of class, saying `same?` method is undefined, probably from using the spectation `should be`.
<FromGitter> <Blacksmoke16> yes
<FromGitter> <Blacksmoke16> makes sense
<FromGitter> <mjfiano:matrix.org> Yeah thought so, since they are pbv
<FromGitter> <mjfiano:matrix.org> ok
<FromGitter> <Blacksmoke16> you could use `should be` if your struct implemented that method
<FromGitter> <Blacksmoke16> but at that point its basically the same as `should eq`
<FromGitter> <mjfiano:matrix.org> Right
<FromGitter> <Blacksmoke16> 👍
<FromGitter> <mjfiano:matrix.org> I'm just experimenting by removing all those "into" methods and making the types structs
<FromGitter> <mjfiano:matrix.org> It would surely be a lot less code to maintain and probably less room for user error
<FromGitter> <Blacksmoke16> indeed
ua_ has quit [Ping timeout: 272 seconds]
ua_ has joined #crystal-lang
ur5us has joined #crystal-lang
sagax has joined #crystal-lang
ur5us has quit [Ping timeout: 272 seconds]
echoSMILE has left #crystal-lang [#crystal-lang]
f1refly has quit [Read error: Connection reset by peer]
f1refly has joined #crystal-lang
Nik- has joined #crystal-lang
<FromGitter> <manveru:matrix.org> is there a better way to write this? ⏎ ⏎ ```code paste, see link``` ⏎ ⏎ I think there must be a better way to convert the string back... [https://gitter.im/crystal-lang/crystal?at=61052d8623956a5aa466914c]
<FromGitter> <HertzDevil> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=61052e371a1db149e9ef7e65]
<FromGitter> <manveru:matrix.org> oh, nice :)
<FromGitter> <manveru:matrix.org> i really wish there was a finished libgit2 crystal binding... but for now this'll have to do
<FromGitter> <manveru:matrix.org> finally got cloning and checking out a commit working :D
f1refly has quit [Quit: see ya in hell]
f1refly has joined #crystal-lang
<FromGitter> <Blacksmoke16> https://github.com/rust-lang/rust/pull/43170 is this something we should also do?
<FromGitter> <mjfiano:matrix.org> heh this library is only 1500 lines, but test boilerplate is about 5000
deavmi has quit [Ping timeout: 240 seconds]
deavmi has joined #crystal-lang
<FromGitter> <Blacksmoke16> :P sounds about right
<FromGitter> <mattrberry> `out` just creates an uninitialized variable for whatever type is being pointed to, right?
<FromGitter> <mattrberry> So `out` for an argument that's a `Pointer(Char)` effectively just creates an `uninitialized Char` then passes its pointer as an argument, right?
oprypin has quit [Quit: Bye]
oprypin has joined #crystal-lang
<FromGitter> <mattrberry> If I want to allocate space for a string, I'd need to allocate that myself using something like Pointer.malloc or just `buffer = " " * 512` then pass the pointer
<FromGitter> <mattrberry> When I just use `out` in the case where I *know* it's filling many characters it's still working, but I'm guessing that it's just writing to memory that's still addressable so it's getting lucky and not segfaulting. I just wanted to make sure the Crystal compiler wasn't doing anything tricky with the `out` syntax that I wasn't expecting
<FromGitter> <mattrberry> So I'll stick to just allocating space myself first
<FromGitter> <Blacksmoke16> could you do something with a slice?
<FromGitter> <Blacksmoke16> like `Bytes.new size`, then pass a pointer to that buffer to fill it?
<FromGitter> <Blacksmoke16> then you'd be able to do `String.new bytes`
<FromGitter> <mattrberry> The benefit of just setting `buffer = " " * n` is that to_unsafe already gives me a Pointer(UInt8), so I can just pass it directly to the c binding, and in Crystal it's already a string so I don't need to do anything funky with it
<FromGitter> <Blacksmoke16> thats fair, the other option would be to `maloc` a pointer and use the `String.new ptr, size` constructor
<FromGitter> <Blacksmoke16> `malloc`*
<FromGitter> <mattrberry> Yeah that was my other thought too. Any thought if there's any perf concern with `" " * n`? It's not in a hotpath so I'm not overly concerned, but worth considering at least
<FromGitter> <mattrberry> Currently I'm just sticking with this since it's pretty simple ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=6105d69e8587b302bfd5b82a]
<FromGitter> <Blacksmoke16> prob be fine
<FromGitter> <Blacksmoke16> :shrug:
<FromGitter> <mattrberry> Yeah same haha
Guest13 has joined #crystal-lang
<Guest13> hi all. i am wondering if constants can be defined with leading underscores. For example are both Hmm, and __Hmm both considered constants
<Guest13> i saw there are psudo constants such as __LINE__ defined so i would think such a variable definition would be considered a constant?