ChanServ changed the topic of #crystal-lang to: The Crystal programming language | http://crystal-lang.org | Crystal 0.31.1 | Fund Crystal's development: http://is.gd/X7PRtI | GH: https://github.com/crystal-lang/crystal | Docs: http://crystal-lang.org/docs/ | API: http://crystal-lang.org/api/ | Gitter: https://gitter.im/crystal-lang/crystal
<FromGitter> <Daniel-Worrall> I got this ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5dcdee9ceeb63e1a83b50e0e]
<FromGitter> <Daniel-Worrall> I kinda feel like this should have been easier with the stdlib
Liothen has quit [Ping timeout: 250 seconds]
jetpack_joe has quit [Ping timeout: 252 seconds]
melthelesbian has quit [Ping timeout: 252 seconds]
<FromGitter> <christopherzimmerman> @kinxer awesome! Yea anything you have time to do would be much appreciated. Anything in particular you are interested in implementing?
melthelesbian has joined #crystal-lang
jetpack_joe has joined #crystal-lang
Liothen has joined #crystal-lang
duane has joined #crystal-lang
duane has quit [Remote host closed the connection]
Human_G33k has quit [Ping timeout: 245 seconds]
f1refly has joined #crystal-lang
hightower3 has quit [Ping timeout: 240 seconds]
f1reflyylmao has joined #crystal-lang
f1refly has quit [Ping timeout: 252 seconds]
f1refly has joined #crystal-lang
f1reflyylmao has quit [Ping timeout: 250 seconds]
f1reflyylmao has joined #crystal-lang
f1refly has quit [Ping timeout: 250 seconds]
Stephie has quit [Quit: Fuck this shit, I'm out!]
Stephie has joined #crystal-lang
_whitelogger has joined #crystal-lang
_whitelogger has joined #crystal-lang
badeball_ has joined #crystal-lang
ht_ has joined #crystal-lang
yukai has quit [*.net *.split]
return0e has quit [*.net *.split]
woodruffw has quit [*.net *.split]
dostoyevsky has quit [*.net *.split]
DTZUZO has quit [*.net *.split]
MasterdonX has quit [*.net *.split]
Flipez has quit [*.net *.split]
coderobe has quit [*.net *.split]
raz has quit [*.net *.split]
olbat has quit [*.net *.split]
ht_ is now known as _ht
davic has quit [Ping timeout: 262 seconds]
_ht is now known as 59NAAZNEM
davic has joined #crystal-lang
return0e has joined #crystal-lang
yukai has joined #crystal-lang
woodruffw has joined #crystal-lang
DTZUZO has joined #crystal-lang
dostoyevsky has joined #crystal-lang
MasterdonX has joined #crystal-lang
coderobe has joined #crystal-lang
raz has joined #crystal-lang
olbat has joined #crystal-lang
Flipez has joined #crystal-lang
dostoyevsky has quit [Max SendQ exceeded]
dostoyevsky has joined #crystal-lang
yukai has quit [*.net *.split]
return0e has quit [*.net *.split]
woodruffw has quit [*.net *.split]
DTZUZO has quit [*.net *.split]
MasterdonX has quit [*.net *.split]
Flipez has quit [*.net *.split]
coderobe has quit [*.net *.split]
raz has quit [*.net *.split]
olbat has quit [*.net *.split]
coderobe has joined #crystal-lang
return0e has joined #crystal-lang
woodruffw has joined #crystal-lang
DTZUZO has joined #crystal-lang
MasterdonX has joined #crystal-lang
Flipez has joined #crystal-lang
raz has joined #crystal-lang
olbat has joined #crystal-lang
yukai has joined #crystal-lang
return0e has quit [Ping timeout: 268 seconds]
hemite has left #crystal-lang [#crystal-lang]
59NAAZNEM has quit [Quit: 59NAAZNEM]
return0e has joined #crystal-lang
Vexatos has joined #crystal-lang
yukai has quit [Ping timeout: 268 seconds]
<repo> i wrote a tiny rust lib that basically just exposes a few functions globally. I then wrote bindings for this in crystal. When i try linking a project that uses the shard get the following error: https://p.jokke.space/HHQm2/
<repo> i should also say that i'm statically linking the rust lib, everything else is dynamically linked
<FromGitter> <mavu> just stumbled on this: https://github.com/omarroth/invidious ⏎ Written in Crystal - alternate frontend for youtube. looks awesome.
<repo> yeah
<repo> until you read the code :D
<repo> hmm
<repo> it seems like i should pass the static rust lib as the last argument
<repo> is there a way to influence the order of linker flags in crystal?
return0e has quit [Read error: Connection reset by peer]
return0e has joined #crystal-lang
alex```77 has joined #crystal-lang
return0e_ has joined #crystal-lang
return0e has quit [Ping timeout: 245 seconds]
manveru has joined #crystal-lang
<FromGitter> <straight-shoota> repo, I'm not sure
<FromGitter> <straight-shoota> But you can just pass `--cross-compile` and the compiler will print the linker command instead of executing it. Then you can modify it to your needs.
<FromGitter> <straight-shoota> It's not nice, but maybe a useful workaround
<repo> straight-shoota: i found a way around this. I used objcopy to strip the conflicting symbol from the rust lib
<FromGitter> <yxhuvud> I mean, if you get a link error (which needs to be improved BTW) you get the command printed anyhow
<repo> yeah
<FromGitter> <yxhuvud> I'll file an issue about linker error messages when I get around to it.
<FromGitter> <bajro17> @routes[route.to_s].call(block)
<FromGitter> <bajro17> give me error Error: no overload matches 'Proc(HTTP::Server::Context)#call' with type Proc(HTTP::Server::Context, Nil)
<FromGitter> <bajro17> I dont know how to fix it
<FromGitter> <bajro17> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5dce9e1e4adf071a8433df9e]
<FromGitter> <bajro17> this is my method
<repo> is it possible to read from an io with a timeout?
return0e_ has quit [Read error: Connection reset by peer]
return0e_ has joined #crystal-lang
<repo> to be more precise: i have a fifo i read from. i want to block for a maximum amount of N seconds before timeouting on a gets
<repo> oh ok
<repo> seems that there's IO::Evented
<repo> not sure how to use that with IO::Filedescriptor though
livcd has joined #crystal-lang
<repo> hmm
<repo> i could use a unix socket as well but i'd need to be able to timeout on accept
<FromGitter> <straight-shoota> `IO::FileDescriptor` includes `IO::Evented`. It's just not obvious because it goes through `Crystal::System::FileDescriptor` which is nodoc
<repo> ahh
<repo> sweet thanks
alex```77 has quit [Quit: The Lounge - https://thelounge.chat]
alexherbo2 has joined #crystal-lang
alexherbo2 is now known as alex```
return0__ has joined #crystal-lang
return0e_ has quit [Ping timeout: 252 seconds]
return0__ has quit [Read error: Connection reset by peer]
return0e_ has joined #crystal-lang
duane has joined #crystal-lang
DTZUZO has quit [Ping timeout: 268 seconds]
DTZUZO has joined #crystal-lang
ternarysolo has joined #crystal-lang
olbat[m] has joined #crystal-lang
beepdog has joined #crystal-lang
erdnaxeli has joined #crystal-lang
<FromGitter> <kinxer> @christopherzimmerman Actually, I'm most interested in improving and refining the API documentation, naming, and code structure. I think the work you've done on actual implementation is really fantastic, but those other factors will heavily affect actual shard usage. Also, I'm not a data scientist, and I don't really work with machine learning, so I'm not confident about my ability to implement actual features.
<FromGitter> ... I do really care about API usability and software maintainability, though, hence my stated intention.
<FromGitter> <christopherzimmerman> That would be great. Yea I pretty much have been focused on getting the core functionality implemented more than anything. Docs are a huge weakness right now. I wish Crystal let you modify the documentation templates, the alternative is docs by hand
<FromGitter> <Daniel-Worrall> docelic: Looking at your `crystallabs/event_handler`, is there a reason handler procs need to return a Bool instead of Nil? Is there any distinction made between true or false?
hightower4 has joined #crystal-lang
Raimondi has quit [Ping timeout: 240 seconds]
Raimondi has joined #crystal-lang
Raimondi has quit [Ping timeout: 240 seconds]
Raimondi has joined #crystal-lang
Raimondi has quit [Client Quit]
ht_ has joined #crystal-lang
<FromGitter> <Souravgoswami> Hi guys hope you all are doing well!! ⏎ ⏎ So I have a question... ⏎ https://stackoverflow.com/questions/58877088/killing-a-thread-in-crystal-lang ⏎ ... [https://gitter.im/crystal-lang/crystal?at=5dcee60292a84f79fe71feac]
<FromGitter> <tenebrousedge> that's a bit of a weird sieve
<FromGitter> <Souravgoswami> Better if I can get a stackoverflow answer (and not downvotes please 😆), that's the first google result of searching killing threads in crystal lang
<FromGitter> <Souravgoswami> @tenebrousedge, yeah but it's just sieve... Benchmarked with Eratosthenes in Ruby, works fast enough ... :D
<FromGitter> <Souravgoswami> Benchmarked with Benchmark in Ruby, and compared with Eratosthenes btw...
<FromGitter> <tenebrousedge> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5dcee68cfd6fe41fc08dd733]
<FromGitter> <Souravgoswami> I am really missing the `.methods` method in crystal to learn more about classes! Is there any performance issue with .methods method?
<FromGitter> <tenebrousedge> no, but it's a macro method
<FromGitter> <Souravgoswami> @tenebrousedge that's great... Shorter code! But I wanted to add animation like in the question! So I need a thread to run the loop to print, I am also printing % done
<FromGitter> <Souravgoswami> @tenebrousedge , then it's really gets messed up... I can't use `spawn do ... end` because the print in loop stays paused!!?
<FromGitter> <tenebrousedge> interesting
<FromGitter> <Souravgoswami> This for example...
<FromGitter> <Souravgoswami> It will just work fine if I can do `t.kill` as in Ruby...
<FromGitter> <Souravgoswami> Assuming t = Thread.new { }
<FromGitter> <tenebrousedge> I'm not sure that's the way to go in Crystal
<FromGitter> <Souravgoswami> 😅😅😅😅
<FromGitter> <Souravgoswami> Another thing...
<FromGitter> <Souravgoswami> Just a screenshot (sorry, but ...)
<FromGitter> <tenebrousedge> Have you read this? https://crystal-lang.org/reference/guides/concurrency.html
<FromGitter> <tenebrousedge> especially with `channel.send` ?
<FromGitter> <Souravgoswami> Yes, but I haven't done the channel thing though... I implemented fiber, but that didn't work...
<FromGitter> <Souravgoswami> Let me try channel...
<FromGitter> <Souravgoswami> So my code: ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5dceeb0cea7d147cb385b5f0]
<FromGitter> <Souravgoswami> Doesn't update the print method in the spawn method
<FromGitter> <Souravgoswami> Also, I tried putting the channel.send(nil) to just beneath the spawn method: ⏎ ⏎ ```spawn do ⏎ channel.send(nil) ⏎ . ⏎ . ⏎ .``` [https://gitter.im/crystal-lang/crystal?at=5dceeb52ca778c1fbf0bcc8d]
<FromGitter> <Souravgoswami> Which doesn't print anything
dannyAAM has quit [Quit: znc.saru.moe : ZNC 1.6.2 - http://znc.in]
dannyAAM has joined #crystal-lang
<FromGitter> <Souravgoswami> Oh sorry for my terrible mistake, I wrote the channel.send() in the loop as well, I have removed that, and the loop do end is working fine, but it stuck in an infinite loop
<FromGitter> <jwoertink> I'm running in to this issue https://play.crystal-lang.org/#/r/80xl
<FromGitter> <jwoertink> I thought there was an issue open on the repo, but I'm having trouble finding it
<FromGitter> <jwoertink> Has anyone else run in to this?
<FromGitter> <jwoertink> or do I have to define map like I do for each?
<FromGitter> <tenebrousedge> I don't think you should have to define `map`
<FromGitter> <kinxer> @jwoertink You're trying to call a method on the `Enumerable` object on the thing `yield`ed by that object.
<FromGitter> <jwoertink> OH
<FromGitter> <tenebrousedge> and I don't know that you can use `Object` as your `Enumerable` type
alex``` has quit [Quit: The Lounge - https://thelounge.chat]
<FromGitter> <jwoertink> because map calls to `each`
<FromGitter> <tenebrousedge> if you want a generic, that's a thing
<FromGitter> <jwoertink> My actual code is a lot more complicated, but this was the smallest I could make it
<FromGitter> <jwoertink> ok, I think I understand now
<FromGitter> <jwoertink> Kind of a strange error if that's the case though
<FromGitter> <tenebrousedge> https://play.crystal-lang.org/#/r/80xy
<FromGitter> <tenebrousedge> it is a strange error
<FromGitter> <jwoertink> I'm surprised it wasn't "undefined method `id` for Int32" in this case
<FromGitter> <jwoertink> or something along those lines
<FromGitter> <tenebrousedge> but you were telling it you were yielding `Object`, not `Int32`
<FromGitter> <kinxer> Well, `Enumerable(T)#each` yields `T`.
<FromGitter> <asterite> I think we allow `include T(Object)` for reasons I can't remember, but that should be a compile-error at some point (until we allow `Object` there)
alexherbo2 has joined #crystal-lang
alexherbo2 is now known as alex```
<FromGitter> <jwoertink> A compile error would be good. I'm now thinking I can just get rid of including enumerable in my code
<FromGitter> <jwoertink> Thanks for the help all!
<FromGitter> <asterite> @Souravgoswami use `spawn` and try compiling with `-Dpreview_mt`
alex``` has quit [Client Quit]
alexherbo2 has joined #crystal-lang
alexherbo2 is now known as alex```
<FromGitter> <asterite> @Souravgoswami also `Thread` is not public API
<FromGitter> <Souravgoswami> Sure...
Raimondi has joined #crystal-lang
<FromGitter> <Souravgoswami> After changing `t = Thread.new` to `t = spawn` and compiling it like: ⏎ ⏎ ```crystal build -Dpreview_mt sieve.cr ``` ⏎ ⏎ And running ./sieve ... [https://gitter.im/crystal-lang/crystal?at=5dcefa85eeb63e1a83bca31a]
<FromGitter> <Souravgoswami> Same question, how can I stop execution of the loop? ⏎ Surely I can set a boolean value to true and false, and get my job done...
<FromGitter> <Souravgoswami> Kind of like this... And this works because the thread exits when while is false... 😂😂 ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5dcefbbaea7d147cb38634df]
<FromGitter> <kinxer> I believe you could also do that with a `Channel(Nil)` and `while channel.empty`.
<FromGitter> <Souravgoswami> yeah, that would be amazing
<FromGitter> <asterite> Does this work for you? https://play.crystal-lang.org/#/r/80xz
<FromGitter> <asterite> you can use `select` then `ch.receive` and `else`. The `else` will be exeuted if the channel doesn't have anything in it
<FromGitter> <asterite> (compile with `-Dpreview_mt`)
Raimondi has quit [Read error: Connection reset by peer]
Raimondi has joined #crystal-lang
<FromGitter> <Souravgoswami> It just prints the number and it just avoids the loop!
<FromGitter> <Souravgoswami> -Dpreview_mt works!
Raimondii has joined #crystal-lang
Raimondi has quit [Read error: Connection reset by peer]
Raimondii is now known as Raimondi
<FromGitter> <asterite> yes, I think without `-Dpreview_mt` it doesn't work because the main loop won't switch to another fiber (there's no sleep nor IO) so the `spawn` never gets to run
<FromGitter> <asterite> with `-Dpreview_mt` it works fine because `spawn` likely runs in a separate thread
<FromGitter> <kinxer> FYI, @Souravgoswami, this is a little prettier than your current iteration method: ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5dceffd1e75b2d5a19dbc138]
<hightower4> Hm I declared @x : Hash(String,Int) and this worked. Then when I actually did @x = Hash(String,Int16).new, it told me that type must be Hash(String,Int), not Hash(String,Int16). Is this known/expected behavior, or?
<FromGitter> <kinxer> I think a variable restricted to `Klass(T)` doesn't allow an instance of `Klass(U)` where `U` is a subclass of `T`.
<FromGitter> <kinxer> If you're using just `Int16`, you should restrict the `Hash` to `Int16`. If you're planning on using different subtypes of `Int`, I think the way to go is to make your class generic.
<hightower4> yeah switched to Int16
<FromGitter> <Souravgoswami> @kinxer That's good, but doesn't that uses more processing... I mean...
<FromGitter> <Souravgoswami> Well btw... Same thing! :D
duane has quit [Ping timeout: 265 seconds]
ht_ has quit [Quit: ht_]
<FromGitter> <Meloncon> Hi! I have a `process = Process.run(cmd, args, output: Process::Redirect::Pipe)` which returns a Process::Status object. I can check the status, etc. But how do I get the output of the cmd that was ran?
<FromGitter> <tenebrousedge> use backticks
<FromGitter> <tenebrousedge> would be the easy answer
<FromGitter> <Souravgoswami> Hi again, can anyone tell, why can I write: ⏎ ⏎ ```In p.cr:2:1 ⏎ Error: Unterminated string array literal``` [https://gitter.im/crystal-lang/crystal?at=5dcf2e394adf071a84380eaa]
<FromGitter> <Meloncon> Hi @tenebrousedge : I tried that, but I think I'm running into a buffer problem. I only get partial output returned from the backticks and then it throws an unhelpful error.
<FromGitter> <tenebrousedge> I would assume you're escaping `)` @Souravgoswami
<FromGitter> <Souravgoswami> I didn't get it :(
<FromGitter> <Souravgoswami> Oh I need one space! Don't mind but that's weird! I even get the space included!
<FromGitter> <tenebrousedge> yeah, apparently
<FromGitter> <tenebrousedge> that's odd
<FromGitter> <Souravgoswami> In ruby, though: ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5dcf2ee56ba2347d2d9ebdb5]
<FromGitter> <tenebrousedge> yeah, I wonder if that's technically a bug in Crystal
<FromGitter> <Souravgoswami> Shouldn't that be like: ⏎ ⏎ ```> puts %W(| / - \\) ⏎ | ⏎ / ⏎ - ⏎ \``` [https://gitter.im/crystal-lang/crystal?at=5dcf2f1a52b73c7cb2256f15]
<FromGitter> <tenebrousedge> something like that
<FromGitter> <Souravgoswami> Yeah... I hope so...
<FromGitter> <tenebrousedge> maybe check the issues list to see if there's anything (open or closed) relating to string array literals
<FromGitter> <tenebrousedge> @Meloncon what error is thrown?
<FromGitter> <Souravgoswami> Nope, this is the code with screenshot:
<FromGitter> <tenebrousedge> uh, I mean check the Crystal issues list to see if there are any open or closed issues related to this
<FromGitter> <tenebrousedge> we only rarely fix Ruby bugs here
<FromGitter> <Souravgoswami> Sorry, from later on, I will post the https://play.crystal-lang.org/ links ... I didn't know that I could share crystal codes like that, so instead posted screenshots btw...
<FromGitter> <tenebrousedge> you can also use github-style markdown code blocks
<FromGitter> <Souravgoswami> Sure... But I don't think this should happen... Because %w() should create an array of the elements, except, you can't put the \ as the last element, that looks a bit odd...
<FromGitter> <Souravgoswami> Yeah sure @tenebrousedge ...
<FromGitter> <tenebrousedge> it is odd. Check to see if someone has reported it to the Crystal devs as a bug already
<FromGitter> <Souravgoswami> I don't think so! Another question, I had a pretty bad time compiling crystal for ArchLinux ARM for the raspberry pi 3 model B. Is there any ways to get that running? Currently I don't maintain apps for ARM, and compiling is a bit problematic for myself ...
<FromGitter> <tenebrousedge> I think people have done this but I don't know anything about it
<FromGitter> <Souravgoswami> Anyways: ⏎ https://github.com/crystal-lang/crystal/issues/5879 ⏎ ⏎ Here's the report from 2018 about %w() but it's not been fixed [https://gitter.im/crystal-lang/crystal?at=5dcf31a792a84f79fe74282c]
<FromGitter> <tenebrousedge> there's also https://github.com/crystal-lang/crystal/issues/5418
<FromGitter> <Souravgoswami> No doubt, ⏎ ⏎ ```code paste, see link``` ⏎ ⏎ is fixed, it works fine... [https://gitter.im/crystal-lang/crystal?at=5dcf3303add5717a8815fe5f]
Raimondii has joined #crystal-lang
Raimondi has quit [Read error: Connection reset by peer]
Raimondii is now known as Raimondi
<FromGitter> <Souravgoswami> I am asking too many questions, I have got another question: ⏎ ⏎ 1) Is there any safe navigation operator kind of thing? ⏎ ⏎ For example: ... [https://gitter.im/crystal-lang/crystal?at=5dcf382bca778c1fbf0e0c2c]
<FromGitter> <tenebrousedge> safe navigator is `try`
<FromGitter> <Souravgoswami> Thanks!
<FromGitter> <tenebrousedge> and I'm not sure what you're asking, precisely. You can iterate over an infinite range, but you can't count to infinity
<FromGitter> <Souravgoswami> I mean, I need to clamp a number from 1000 to infinity. For example, if you enter 999 the number will be 1000, and the highest value can be any number or a bigint...
<FromGitter> <Souravgoswami> I can use if else, but clamp is another way..
<FromGitter> <Blacksmoke16> is `HTTP::Client` not MT safe?
<FromGitter> <tenebrousedge> there's `Float64::INFINITY`
<FromGitter> <tenebrousedge> or you can use an unbounded range
<FromGitter> <Blacksmoke16> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5dcf397feeb63e1a83be60b3]
<FromGitter> <Blacksmoke16> is what im doing
<FromGitter> <tenebrousedge> `num.clamp(0..)`
<FromGitter> <tenebrousedge> that *should* work, I think o.o
<FromGitter> <Blacksmoke16> it *works* but are some exceptions like
<FromGitter> <Blacksmoke16> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5dcf39c4ca778c1fbf0e1bf7]
<FromGitter> <Blacksmoke16> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5dcf39cf68ad1c4a0fd3377b]
<FromGitter> <Blacksmoke16> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5dcf39d9add5717a88162d3a]
<FromGitter> <tenebrousedge> SSL is my kryptonite
<FromGitter> <Blacksmoke16> works fine without the MT
<FromGitter> <straight-shoota> @Blacksmoke16 Almost nothing in stdlib is threadsafe. Except for some explicitly thread-related types like `Mutex`.
<FromGitter> <tenebrousedge> that suggests that either it's not thread safe or SSL is vicious and spiteful and has a personal grudge against you
<FromGitter> <Blacksmoke16> ah fair enough
<FromGitter> <Blacksmoke16> so doing HTTP requests in MT mode == bad idea atm?
<FromGitter> <straight-shoota> Currently, we only have the basic implementation for MT, and even that's still got some rough edges. It's going to be along way for the entirety of Crystal being ready for MT.
<FromGitter> <Blacksmoke16> 👍 fair enough
<FromGitter> <straight-shoota> No, you should be able to do requests. But maybe not on the same client instance.
<FromGitter> <Blacksmoke16> ah let me try that
<FromGitter> <straight-shoota> Btw. that's even problematic with single threaded concurrency IIRC
<FromGitter> <Blacksmoke16> seemed to work fine w/o MT
<FromGitter> <Daniel-Worrall> Yeah I have problems using the same client for multiple requests
<FromGitter> <Daniel-Worrall> In concurrency
<FromGitter> <straight-shoota> > seemed to work fine w/o MT ⏎ ⏎ That's surprising