ChanServ changed the topic of #crystal-lang to: The Crystal programming language | https://crystal-lang.org | Crystal 0.35.0 | 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
rocx has joined #crystal-lang
<FromGitter> <fenicks> > `puts "foo".bytes.join " " { |b| b.to_s(2).rjust(8, '0') }` ⏎ ⏎ Thanks
<FromGitter> <watzon> Well I've never seen this before ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5ee578365dcbb760b6eab6fa]
<FromGitter> <Blacksmoke16> add an `--error-trace`
<FromGitter> <watzon> That is the error trace haha
<FromGitter> <Blacksmoke16> oh
<FromGitter> <Blacksmoke16> grep for that exception message then maybe?
<FromGitter> <watzon> Yeah that's an idea
<FromGitter> <Blacksmoke16> looks like its in string?
<FromGitter> <watzon> Yep
<FromGitter> <watzon> Seems like it's the exception that gets thrown with `String#*` if the argument is negative
<FromGitter> <Blacksmoke16> makes sense
<FromGitter> <watzon> That is the least helpful stack trace I've ever seen though
DTZUZU has joined #crystal-lang
<FromGitter> <watzon> There we go, that's where it's happening
<FromGitter> <watzon> Reproducing is going to be a bitch though
<FromGitter> <Blacksmoke16> `" " * (0 + 0) - `?
<FromGitter> <Blacksmoke16> gl :p
<FromGitter> <watzon> Well I mean coming up with a reproducible example with my current code haha. But they should definitely be doing some checking there to make sure the number isn't negative.
<FromGitter> <Blacksmoke16> heres a plan
<FromGitter> <Blacksmoke16> fix the code in the compiler, then run your code again to see what the actual error is then try to reproduce that error with a small example
<FromGitter> <watzon> There's an idea
<FromGitter> <Blacksmoke16> you know it
<FromGitter> <watzon> Well using the compiled compiler without any changes I already have a bigger stack trace ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5ee57e2e7c64f31f115ca982]
<FromGitter> <watzon> Now time to see how the changes work
<FromGitter> <watzon> Would you look at that, I actually got an error
<FromGitter> <Blacksmoke16> 🎉
<FromGitter> <watzon> There must be an error in the compiler when it comes to counting lines and columns though
<FromGitter> <watzon> Because that never should've happened
<FromGitter> <Blacksmoke16> prob not
<FromGitter> <Blacksmoke16> try against an older version too maybe as well?
<FromGitter> <Blacksmoke16> iirc was some refactors of error related stuff
<FromGitter> <watzon> Well at least I figured out the issue in the library I'm using
<FromGitter> <Blacksmoke16> boo
maxpowa has quit [Ping timeout: 260 seconds]
maxpowa has joined #crystal-lang
gangstacat has quit [Quit: Ĝis!]
zorp has quit [Ping timeout: 260 seconds]
alexherbo2 has joined #crystal-lang
<FromGitter> <lodenos> Hello Guy's,
<FromGitter> <lodenos> `Undefined symbols for architecture x86_64: ⏎ "_BIO_get_data", referenced from: ⏎ ⏎ ```code paste, see link``` ⏎ ... [https://gitter.im/crystal-lang/crystal?at=5ee5e3517c64f31f115d65fd]
<FromGitter> <lodenos> ``````
<FromGitter> <lodenos> When I have migrate crystal 0.34.0 to 0.35.0 and I use this dependence https://github.com/kalinon/mongo.cr I have this problem of link ⏎ ⏎ But this file doesn't exist ⏎ .cache/crystal/crystal-run-main.tmp ⏎ And this folder doesn't exist too ... [https://gitter.im/crystal-lang/crystal?at=5ee5e4c724a3382d5d66fdca]
<FromGitter> <naqvis> clear the cache `rm -rf $(crystal env CRYSTAL_CACHE_DIR)`
<FromGitter> <636f7374> Undefined symbols | macOS 10.12.6 Brew installation failed Crystal 0.35.0 #9476
<DeBot> https://github.com/crystal-lang/crystal/issues/9476 (Undefined symbols | macOS 10.12.6 Brew installation failed Crystal 0.35.0)
<FromGitter> <636f7374> Undefined symbols | macOS 10.12.6 Brew installation failed Crystal 0.35.0 #9476
<DeBot> https://github.com/crystal-lang/crystal/issues/9476 (Undefined symbols | macOS 10.12.6 Brew installation failed Crystal 0.35.0)
<FromGitter> <636f7374> I encountered this strange problem and I am trying to solve it.
<FromGitter> <636f7374> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5ee5ec9a5dcbb760b6eb9498]
<FromGitter> <636f7374> For help.
<FromGitter> <naqvis> linker problems are usually due to invalid cache, so ensure you remove the cache and try again
<FromGitter> <636f7374> @naqvis Okay, thanks, let me try. 🙏
<FromGitter> <naqvis> `rm -rf $(crystal env CRYSTAL_CACHE_DIR)`
<FromGitter> <636f7374> @naqvis `$ rm -rf $(crystal env CRYSTAL_CACHE_DIR) ⏎ -bash: crystal: command not found`
<FromGitter> <naqvis> are you using custom compiled crystal?
<FromGitter> <naqvis> `./bin/crystal env CRYSTAL_CACHE_DIR` and then remove that manually
<FromGitter> <636f7374> @naqvis I uninstalled Crystal after installation failed.
<FromGitter> <636f7374> @naqvis Then reinstall.
<FromGitter> <naqvis> which OS?
<FromGitter> <naqvis> OSX?
<FromGitter> <636f7374> @naqvis macOS 10.12.6
<FromGitter> <naqvis> and you installed via `homebrew` ?
<FromGitter> <636f7374> @naqvis yes.
<FromGitter> <636f7374> @naqvis #9476
<DeBot> https://github.com/crystal-lang/crystal/issues/9476 (Undefined symbols | macOS 10.12.6 Brew installation failed Crystal 0.35.0)
<FromGitter> <naqvis> homebrew installation should reside under `/usr/local/Cellar/crystal` folder and that should also add that path
<FromGitter> <naqvis> aahh
<FromGitter> <naqvis> you better upgrade OSX
<FromGitter> <636f7374> @naqvis Yes, it cannot be installed again after uninstalling , Yes, I think Crystal or LLVM may no longer support macOS 10.12.6
<FromGitter> <636f7374> @naqvis thank you for your help.
<FromGitter> <naqvis> ywc 👍
<FromGitter> <lodenos> My version of macOS is 10.13.6, I have completly uninstall Crystal and delete all cash and reinstall with homebrew
<FromGitter> <lodenos> Doesn't work again
<FromGitter> <lodenos> Because this file .cache/crystal/crystal-run-main.tmp doesn't exist
<raz> why do you guys stick with these ancient OSX versions?
<FromGitter> <lodenos> @raz my macbook pro has 10 year's old
<raz> i'm afraid when homebrew stops supporting it, you're out of luck not just with crystal but with many things
<FromGitter> <lodenos> And we can't update, I have try for the latest version, Impossible doesn't work for upgrade, I do upgrade the machine for going the apple store, money money lol
<raz> if money is tight, maybe consider switching to linux ;) - easier to keep it up to date even on old hardware
<FromGitter> <lodenos> ^^
<FromGitter> <lodenos> But I can compile an Hello World with crystal 0.35.0
<FromGitter> <lodenos> And that's works
<raz> in fairness, OSX itself *does* have pretty good backwards compat story. they even still released a security update for 10.12 (Sierra) last year. but probably the last one, as that version went EOL three years ago.
<raz> however, homebrew usually only supports the latest (and sometimes the one before it)
<FromGitter> <lodenos> I go try compiling in Docker
<FromGitter> <lodenos> Maybe the problem is the Crypto
<f1refly> is there an easy way to export the crystal gitbook to epub? The whole gitbook system is somewhat confusing, gitbook itself says they abandoned the cli tool in favor of their website, but I can't find the crystal gitbook there, neither is there an option to export it on crystal-lang itself
alexherbo2 has quit [Quit: Ping timeout (120 seconds)]
alexherbo2 has joined #crystal-lang
<jhass> I only know there's thoughts about migrating away from gitbook, I guess you found a couple of the reasons :)
<raz> yea, gitbook is kinda a love/hate thing
<raz> their web editor is really nice. but everything else is largely a pain
<raz> then again, the alternatives tend to be even less pleasant. (been trying with asciidoc, mkdocs, sphinx... it's all very messy)
deavmi has quit [Quit: Eish! Load shedding.]
deavmi has joined #crystal-lang
<FromGitter> <jwaldrip> @Blacksmoke16 here we go: https://github.com/jwaldrip/http_cache_handler
<FromGitter> <Blacksmoke16> could the store getter just be `getter store : Cache::Store(String, String)`?
<FromGitter> <Blacksmoke16> then supports custom types as well
<f1refly> I wonder if crystal could copy whatever rust is doing with their docs. They seem to work with gitbook as well and their docs are available as epub no problem (published, but still)
<FromGitter> <Blacksmoke16> and/or just have one initializer where the user creates it and passes it in?
<FromGitter> <Blacksmoke16> as if i create a `PgCache` i cant use it
<FromGitter> <Blacksmoke16> `=== "GET"` 🙈, too much JS/PHP lately :P
<FromGitter> <Blacksmoke16> be nice if there was an API in the cache shard to stream the data back as an IO
<FromGitter> <Blacksmoke16> then the string wouldnt have to be loaded into memory at all but :shrug:, turned out pretty nice 👍
<jhass> f1refly: it's at https://github.com/crystal-lang/crystal-book in case you figure it out :)
<FromGitter> <ImAHopelessDev_gitlab> hi
deavmi_ has joined #crystal-lang
deavmi has quit [Read error: Connection reset by peer]
<FromGitter> <asterite> we'll migrate to docusaurus
ua_ has quit [Ping timeout: 264 seconds]
<FromGitter> <ImAHopelessDev_gitlab> why migrate away from gitbook
ua_ has joined #crystal-lang
rocx has quit [Quit: 👏 developers 👏 developers 👏 developers 👏 developers 👏 developers]
alexherbo20 has joined #crystal-lang
alexherbo2 has quit [Ping timeout: 246 seconds]
alexherbo20 is now known as alexherbo2
<FromGitter> <asterite> it's no longer maintained
<FromGitter> <kinxer> @f1refly I'm pretty sure Rust uses mdbook (https://github.com/rust-lang/mdBook), which is itself written in Rust.
<f1refly> kinxer: it wouldn't be bad to use a doc system thats written in rust, would it?
<f1refly> jhass: I built it with the npm docbook tool, yeah. Gotta say it really isn't too bad of a read on my eink device
<FromGitter> <kinxer> I mean, I don't think we have a doc system written in Crystal, so we're gonna have to use something written in some other language anyway. I agree that a tool in Rust probably wouldn't be that bad, especially since it probably wouldn't require actually writing any Rust.
<FromGitter> <kinxer> Certainly the primary benefit would be using something that is still maintained.
<FromGitter> <kinxer> But it sounds like the core team has already decided on Docusaurus, which sounds fine to me.
zorp has joined #crystal-lang
<FromGitter> <watzon> Has a compact rescue block ever been discussed? Something that would rescue an exception and just return nil?
<FromGitter> <watzon> I'm thinking something like `foo = rescue { something_that_might_throw }`
alexherbo2 has quit [Quit: Ping timeout (120 seconds)]
alexherbo2 has joined #crystal-lang
<FromGitter> <Blacksmoke16> pretty sure you can do like `foo = something_that_might_throw rescue nil`
<FromGitter> <kinxer> I mean, usually you can use `obj.try { |o| something_that_might_throw }`.
<FromGitter> <kinxer> Oh, nice. That's a cool shorthand.
<FromGitter> <watzon> > pretty sure you can do like `foo = something_that_might_throw rescue nil` ⏎ ⏎ Can you? That's cool.
<FromGitter> <watzon> We need to document these things haha
<FromGitter> <watzon> => "abc".to_i rescue nil
<FromGitter> <watzon> Damn how do you make the bot work? Lol
<FromGitter> <Blacksmoke16> > > "abc".to_i rescue nil
<FromGitter> <Blacksmoke16> i think you have to be on irc
<FromGitter> <watzon> Ahh poo
<FromGitter> <watzon> Oh well, I already tested it in icr
<FromGitter> <watzon> It works, which is really nice to know
<FromGitter> <Blacksmoke16> could have just did `"abc".to_i?` 😉 :trollface:
alexherbo2 has quit [Quit: Ping timeout (120 seconds)]
<FromGitter> <watzon> Well yeah...
<FromGitter> <watzon> Lol
<FromGitter> <kinxer> If you want a block to rescue, you could do a helper method: ⏎ ⏎ ```code paste, see link``` ⏎ ⏎ But that only saves you two lines in that case. [https://gitter.im/crystal-lang/crystal?at=5ee6618d29d8bc28f9f7656e]
<FromGitter> <kinxer> E.g. ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5ee662867a7f8d2d63356d42]
<FromGitter> <Blacksmoke16> couldnt you just do
<FromGitter> <Blacksmoke16> ```value.try do |v| ⏎ v // 0 ⏎ rescue ⏎ nil ⏎ end``` [https://gitter.im/crystal-lang/crystal?at=5ee663937b6da9126a95116a]
<FromGitter> <watzon> Being able to rescue a block is nice
<FromGitter> <kinxer> @Blacksmoke16 I don't understand what your example is for. I thought @watzon was trying to avoid those extra `rescue\n nil` lines.
<FromGitter> <watzon> Really it's more about just having a shorter syntax in general rather than ⏎ ⏎ ```foo = begin ⏎ do_something ⏎ rescue ⏎ nil ⏎ end``` [https://gitter.im/crystal-lang/crystal?at=5ee66521035dfa12611e37ec]
<FromGitter> <watzon> All of these examples are nice
<jhass> tbh I don't quite follow what you want. There's a single line. For anything more than a single line you'll at least need a block around these lines. def and do serve as an implicit begin, so it's the exact same amount of lines
alexherbo2 has joined #crystal-lang
<FromGitter> <jwaldrip> Can you forward block to another macro?
<FromGitter> <jwaldrip> ```macro(&block)```
<raz> everything should be made as simple as possible. but not simpler.
<raz> some guy said that a while ago, i think he had a point
<FromGitter> <jwaldrip> When block is called to the other macro its a Nop
<FromGitter> <Blacksmoke16> got an example
<FromGitter> <jwaldrip> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5ee66cc130401c1f2457bfcb]
<FromGitter> <jwaldrip> I need the block from root to forward to the get macro
<FromGitter> <Blacksmoke16> {{block}}?
<FromGitter> <jwaldrip> tried that... then some really strange things happen
<FromGitter> <jwaldrip> you would still need the & to forward
<FromGitter> <Blacksmoke16> {{&block}}?
<jhass> make sure to do foo() {{block}} not foo(.., {{block}}) nor foo(.., &{{block}})
<jhass> nor {{&block}} :D
<FromGitter> <jwaldrip> right so thats why this works
<FromGitter> <jwaldrip> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5ee66ddf7b6da9126a952970]
<FromGitter> <jwaldrip> or am I still doing it wrong
<FromGitter> <jwaldrip> I see, you can just append the block as block
maxpowa has quit [Remote host closed the connection]
maxpowa has joined #crystal-lang
rocx has joined #crystal-lang
alexherbo2 has quit [Ping timeout: 258 seconds]
coderobe has quit [Ping timeout: 256 seconds]
<FromGitter> <Blacksmoke16> heres a data modeling question
<FromGitter> <Blacksmoke16> i have a table `contracts`, then i have child tables for specific "types" of contracts, like auction versus courier
<FromGitter> <Blacksmoke16> however there are some columns that not all contracts have, depending on where the courier object originated, i.e. public versus authenticated context. public ones wont have an `assignee_id`
<FromGitter> <Blacksmoke16> contract object*
HumanGeek has joined #crystal-lang
<FromGitter> <Blacksmoke16> im debating what to do with these columns, since they're not included in one context but are in the other. Current plan is to just define them as nullable, and do the rest on the ORM side. I.e. have a type specific for each "origin"
<FromGitter> <Blacksmoke16> I.e. `PublicContract` wouldnt include `assignee_id`, `PrivateContract` would and would be not nilable
<FromGitter> <Blacksmoke16> any other ideas?
Human_G33k has quit [Ping timeout: 256 seconds]
<raz> yup, i tend to keep it in the same table (with an enum for the type) if they're similar enough. if it gets too unwieldy it's time to split them into separate entities (owner has_many public_contracts, has_many private_contracts)
<jhass> some check constraints in addtion to nullable fields? CHECK ( (type = 'private_contract' AND assignee_id IS NOT NULL) OR type != 'private_contract')
<FromGitter> <Blacksmoke16> that'll prob help
<FromGitter> <Blacksmoke16> jhass: oo good idea, at least would get some DB checks in there
<raz> which you then have to duplicate in the ORM and in the client
<raz> programming is so much fun!
<FromGitter> <Blacksmoke16> luckily its a backend construct, wont be any user input
<FromGitter> <Blacksmoke16> just consuming an API and storing the data
<raz> ah yea, that's easy then
<raz> well, easier at least ;)
<FromGitter> <Blacksmoke16> just feels hacky to me to have a bunch of required properties be nullable just because the other "type" of contract doesnt have it, but also feels hacky to make each one its own table
<FromGitter> <Blacksmoke16> but i suppose its not a big deal either way, since its not user supplied so less chance for it to get borked
<raz> ORM is always hacky. impedance mismatch
<raz> at one point someone had a great idea to fix it, and so he went and invented mongodb
<raz> but that was a mistake. so now we're back to ORM.
<FromGitter> <Blacksmoke16> xD
<FromGitter> <Blacksmoke16> and ORM that supports MTI/STI?
<FromGitter> <Blacksmoke16> cant say iv'e seen any for the former
<raz> well, they exist... there's rumors some poor souls even tried the whole polymorphic route
<raz> but no one ever heard from them again
<FromGitter> <Blacksmoke16> in crystal i mean*
<raz> jennifer does it
<raz> but i don't think you want to. you're too young, you still have your whole life ahead of you!
<FromGitter> <Blacksmoke16> looks like it has STI, not MTI tho
<raz> lol
<FromGitter> <Blacksmoke16> ill prob just hack granite to get it to work :S
<raz> good luck... (or shall i say "farewell" :D)
<raz> but srsly, that way lies madness
<FromGitter> <Blacksmoke16> i think it would be possible with a module to share the common columns
<FromGitter> <Blacksmoke16> otherwise you run into https://github.com/amberframework/granite/issues/123 :roll_eyes:
<FromGitter> <Blacksmoke16> Actually I realized that I don't actually need to support those other contract types.
<FromGitter> <Blacksmoke16> At this moment at least, premature optimization am I right ha
<FromGitter> <j8r> @kinxer +1 for mdbook
<FromGitter> <j8r> I have mentioned it on the crystal-book issue
<FromGitter> <j8r> Hum actually I didn't, maybe in another one
<FromGitter> ... instead of an array or slice. However, compiling for release now takes ~5-8 minutes, where it used to take ~10-20 seconds. I mentioned this before as well, but I don't remember what the conclusion was there. I'll likely stick with a staticarray because it allows me to get sdl bindings working, but the super long compile ti ... [https://gitter.im/crystal-lang/crystal?at=5ee6b8017c64f31f115f3962]
<FromGitter> <mattrberry> Hey! I was in this channel a week or two ago sharing the weird issue I was having with passing arrays/slices to c-bindings to SDL. Last time I brought it up here, we seemed to arrive at the conclusion that it had something to do with garbage collection, but we couldn't figure out how to fix it. I've been playing around with it some more, and it seems like I've gotten it to work better by using a staticarray
<FromGitter> <mattrberry> Maybe I could just put these staticarrays somewhere else in global scope and in their own file so that crystal won't need to recompile them every time? That could mitigate the issue, but it's definitely not a solution
<FromGitter> <mattrberry> My static array is only 4096 floats long 😬
<FromGitter> <ImAHopelessDev_gitlab> 10-20 seconds to 5-8 minutes, wtf
<FromGitter> <mattrberry> All I've changed is ⏎ ⏎ ```@buffer = StaticArray(Float32, 4096).new 0_f32``` [https://gitter.im/crystal-lang/crystal?at=5ee6b97cef5c1c28f022c5d4]