ChanServ changed the topic of #crystal-lang to: The Crystal programming language | http://crystal-lang.org | Crystal 0.23.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
DTZUZO has quit [Ping timeout: 248 seconds]
Disrecollection has joined #crystal-lang
<FromGitter> <faustinoaq> Hi I'm trying to implement `crystal tool rename` ⏎ ⏎ I have a question: How can I handle ambiguous code on Crystal? I mean , some words can be a variable or function call or macro call, Does exist a way to differentiate them? ⏎ ⏎ ```code paste, see link``` ... [https://gitter.im/crystal-lang/crystal?at=59ee9c2f8808bed73d1da0fa]
<FromGitter> <faustinoaq> applying refactoring from last line
<FromGitter> <pnloyd> Maybe you should through an error.
<FromGitter> <pnloyd> Saying it's ambiguous.
<FromGitter> <pnloyd> End possible add a switch to pick which one to rename.
<FromGitter> <pnloyd> And*
<FromGitter> <pnloyd> @faustinoaq or what if there are method defs in seperate classes/modules or what have you with the same name.
<FromGitter> <pnloyd> Maybe make a menu to choose from if you can, with the first line of the defintion. like.. ⏎ ⏎ Symbol "foobarbaz" was has ambiguous defintions. Please choice from the following: ⏎ ⏎ 1) macro foobarbaz ... [https://gitter.im/crystal-lang/crystal?at=59eea250210ac269202282b3]
<FromGitter> <faustinoaq> @pnloyd Yeah, Good idea, Thanks you for your comments! 😄
<FromGitter> <pnloyd> Are you able to take advantage of the compiler/AST?
<FromGitter> <pnloyd> Renaming a symbol doens't seem like it would be trivial at all @faustinoaq
alex`` has joined #crystal-lang
<FromGitter> <faustinoaq> Yeah, I'm reading some examples about Crystal AST, seems to be easier that I thought. ⏎ ⏎ I was watching a conference (https://www.youtube.com/watch?v=RT46MpK39rQ&feature=youtu.be&t=25m11s) about C++ tooling and I thought Crystal would have same problem 😅
<FromGitter> <faustinoaq> Hi Crystal community crystal-mode is now available on MELPA (https://melpa.org/#/crystal-mode) ✨ 👏
alex`` has quit [Ping timeout: 240 seconds]
<FromGitter> <HCLarsen> Hey guys, I'm looking through the Int documentation, and I can't find anything like the Ruby between? method. Am I looking in the wrong place, or does it not exist?
<FromGitter> <pnloyd> what does the Ruby between method do?
<FromGitter> <HCLarsen> Checks that your number is between two other numbers.
<FromGitter> <HCLarsen> Pretty much what it says on the package.
<FromGitter> <pnloyd> Searching the repo shows the method does exist but it's in the compilers source code.
<FromGitter> <pnloyd> ``` def between?(min, max) ⏎ min <= self && self <= max ⏎ end``` [https://gitter.im/crystal-lang/crystal?at=59eeb8ed210ac2692022d484]
<FromGitter> <pnloyd> If there's no other occurrences of `min <= self && self <= max` either
<FromGitter> <HCLarsen> The compilers source code? So it's not in any class?
<FromGitter> <pnloyd> It's in a class called location.cr
<FromGitter> <pnloyd> I just don't think it's available from the stdlib. I barely know anything about crystal though..
<FromGitter> <GrgDev> Can you pass a module in to a method as an argument?
<FromGitter> <HCLarsen> Then it sounds like I should add a new issue to the repo.
<FromGitter> <HCLarsen> Or maybe wait for an answer from someone who knows the language better.
<FromGitter> <pnloyd> @GrgDev consider that everything that's a variable is also an object. If you could pass modules into methods there would be a special object to contain meta data about the module. I'm guessing since there's nothing in the docs like that it's not possible.
<FromGitter> <GrgDev> *sigh* Okay then, more complications to add to the list of things to consider when porting Ruby to Crystal
<FromGitter> <pnloyd> also consider that I might be wrong lol
<FromGitter> <GrgDev> but you are right that the docs don't show that ability and generally speaking anything that falls into Ruby's meta-programming category was explicitly NOT included in Crysta
<FromGitter> <HCLarsen> @pnloyd , if you barely know anything about Crystal, why do you keep answering questions instead of asking them?
<FromGitter> <pnloyd> But this does exist ⏎ ⏎ ``` class ModuleDef ⏎ property! resolved_type : ModuleType ⏎ end``` [https://gitter.im/crystal-lang/crystal?at=59eebb92d6c36fca318bbf76]
<FromGitter> <pnloyd> I know enough about languages that I can infer the answers using my general knowledge plus my crystal knowledge.
<FromGitter> <pnloyd> And I can search the crystal repo
<FromGitter> <HCLarsen> So can everyone else.
<FromGitter> <pnloyd> Ya
snsei has joined #crystal-lang
<FromGitter> <GrgDev> So this is what I've found from playing around. ⏎ https://play.crystal-lang.org/#/r/2yal ⏎ You can pass a module, but it gets passed as a Class type object that doesn't seem to respond to the module's own defined methods.
<FromGitter> <GrgDev> If you uncomment either line in the given example, you get an undefined error
<FromGitter> <pnloyd> @GrgDev you almost figured it out.
<FromGitter> <pnloyd> Nice
<FromGitter> <pnloyd> I guess I was wrong
<FromGitter> <pnloyd> `extend self` is what I added btw
<FromGitter> <GurgDev_twitter> wait, I never saw an extend keyword defined in the docs
<FromGitter> <GurgDev_twitter> was I just blind?
<FromGitter> <pnloyd> I can't remember if I saw that in the docs or not.
<FromGitter> <pnloyd> I think so.
<FromGitter> <pnloyd> I think it said something along the lines of.. "`extend self` is a common pattern blah blah blah"
<FromGitter> <pnloyd> Now I'm wondering if you can pass classes around as well
DTZUZO has joined #crystal-lang
<FromGitter> <GurgDev_twitter> https://crystal-lang.org/docs/syntax_and_semantics/modules.html yeah, it explains the extends self at the bottom
<FromGitter> <pnloyd> Or even methods, like in many languages how you can give a method definition in place of function argument. Accept in Crystal the method get's called without the () so there's no way to type it.
<FromGitter> <GurgDev_twitter> I just assumed extend only... well, extends. Like, normally what would you intuitively get by extending self with self?
<FromGitter> <pnloyd> The extend same thing lol
<FromGitter> <pnloyd> Nothing about the Module thing is intuitive in my opinion.
<FromGitter> <pnloyd> Like how it is dual purposed.. can act as an interface by describing abstract methods, or as a mixin. But I'd accept a module to be something that behaves like what is *does* behave like if you do `extend self`
<FromGitter> <pnloyd> Very interesting lol
<FromGitter> <GurgDev_twitter> Okay, that actually makes my problems a LOT easier
<FromGitter> <GurgDev_twitter> I can sleep well tonight
rohitpaulk has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 248 seconds]
rohitpaulk has joined #crystal-lang
gewo has joined #crystal-lang
gewo has quit [Quit: WeeChat 1.6]
gewo has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 255 seconds]
rohitpaulk has joined #crystal-lang
snsei has quit [Remote host closed the connection]
DTZUZO has quit [Ping timeout: 248 seconds]
<FromGitter> <bew> @pnloyd you can use `min <= some_var <= max`
<FromGitter> <HCLarsen> @bew that was my question, not his.
<FromGitter> <bew> Ah, there you go anyway ;)
<FromGitter> <HCLarsen> Yup, thanks. I did submit an issue though. I think it'd be nice to have the syntactic sugar of a proper between method.
alex`` has joined #crystal-lang
<FromGitter> <bew> @GrgDev to access module's methods just add `self.` to them! (https://play.crystal-lang.org/#/r/2ybs)
<FromGitter> <bararchy> how does Windows compiling works in regard to static\dynamic (not Crystal specific)
Papierkorb_ has joined #crystal-lang
alex`` has quit [Quit: WeeChat 1.9.1]
<Papierkorb_> Morning
<FromGitter> <yxhuvud> moin
<Groogy> Morning!
claudiuinberlin has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 255 seconds]
rohitpaulk has joined #crystal-lang
<FromGitter> <Rinkana> Is there a way to map bytes directly to a self-defined struct?
<FromGitter> <Rinkana> Something like: ⏎ ⏎ `````` [https://gitter.im/crystal-lang/crystal?at=59eeef03614889d475f2364c]
alex`` has joined #crystal-lang
<FromGitter> <sdogruyol> morning everyone
<Papierkorb_> Rinkana, not with a struct like that.
<FromGitter> <bew> @Rinkana you could do sth like this https://carc.in/#/r/2yc3 but I'm not sure if it's the best way
<Papierkorb_> it's the most robust way
rohitpaulk has quit [Ping timeout: 248 seconds]
gcds has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
claudiuinberlin has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
claudiuinberlin has joined #crystal-lang
rohitpaulk has joined #crystal-lang
gcds has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 240 seconds]
sz0 has joined #crystal-lang
mark_66 has joined #crystal-lang
rohitpaulk has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 252 seconds]
rohitpaulk has joined #crystal-lang
DTZUZO has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 264 seconds]
alex`` has quit [Quit: WeeChat 1.9.1]
flaviodesousa has joined #crystal-lang
alex`` has joined #crystal-lang
rohitpaulk has joined #crystal-lang
claudiuinberlin has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<Papierkorb_> ... What the hell, according to Wireshark a HTTP::Server server tool (no kemal or w/e) replies with multiple HTTP response headers under high-ish load.
<FromGitter> <sdogruyol> what?
<FromGitter> <bararchy> Papierkorb_ I saw something similar, Or at least, from the client side (sending multile requests when a single was called)
<Papierkorb_> Mh or it might be somewhere else. It's a proxy, and uses HTTP::Client on the other end, which does actually shares connections
<FromGitter> <bararchy> I found HTTP::Client to the issue from my side
<Papierkorb_> Yes seems to be for me too. The cached answer also contains the http response headers
<FromGitter> <bararchy> Take a look here: https://github.com/crystal-lang/crystal/issues/4867
<Papierkorb_> oh that 100 Continue stuff
<FromGitter> <bararchy> I thought it was that
<FromGitter> <bararchy> but further reserch seems to indicate the client can handle 100 quite well
<FromGitter> <bararchy> It seems I just got back 2 responds where one was supposed to be returned
<FromGitter> <bararchy> it only happen in highload though
<FromGitter> <bararchy> Can't recreate in single requests
<Papierkorb_> yeah I tried a `curl &` loop, didn't do it either. But a ruby client is already enough
<Papierkorb_> in a non-benchmark scenario even, if those request actually are made to the backend, they take a few ms to finish
<Papierkorb_> Oh wait, shit
<FromGitter> <bararchy> ?
<Papierkorb_> Ever wondered what would happen if you do asynchronous requests using the same open http client at once?
<FromGitter> <bararchy> HTTP is async, so the requests get jumbeled up ?
<Papierkorb_> that'd be a reasonable explanation wouldn't it?
<FromGitter> <bararchy> well, it shouldn't be possible to send multiple request simutensly via the same HTTP::Client then, as this is never a good behavior
<FromGitter> <sdogruyol> might be related to fiber scheduling
<Papierkorb_> sdogruyol, do you happen to know if the HTTP Server spawns a fiber for incoming requests?
<FromGitter> <bararchy> Papierkorb_ It does
<Papierkorb_> Then that's your answer
<FromGitter> <bararchy> But, what about the client ?
<FromGitter> <bararchy> does the client do the same ?
<FromGitter> <bararchy> it makes no sense that a client will send more then one request each time
<Papierkorb_> no how could it, I use it to have an open connection
<FromGitter> <bararchy> Oh ... I see
<Papierkorb_> if you don't use that feature, it wouldn't occur
<FromGitter> <bararchy> So, you do something like ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=59ef2bc932e080696e1beb32]
<FromGitter> <bararchy> so that multiple requests might happend
<FromGitter> <bararchy> I see
<FromGitter> <sdogruyol> @Papierkorb_ yes
<Papierkorb_> ah well, I'll teach it how to spin up new clients if needed
<FromGitter> <bararchy> I guess HTTP::Client needs an internal lock for each call, or just you should not re-use the same client
<FromGitter> <yxhuvud> that reminds me of the RADIUS protocol. Each current request have a unique request id 0-255. Which puts a fine limit on the server as if too many clients try at once or if the server isn't fast enough there won't be IDs for everyone. Nice little protocol bug, that.
<FromGitter> <bararchy> I'll check if I might have the same issue
<FromGitter> <sdogruyol> that reminded me of slow client attack @yxhuvud
<FromGitter> <sdogruyol> now wondering if we're vulnerable to that :P
<FromGitter> <ansarizafar> Is it possible to create an Enum from DB RecordSet?
<FromGitter> <bararchy> nha, not the same flow :)
<Papierkorb_> sdogruyol, if there's no timeout, we are
<FromGitter> <sdogruyol> we probably don't have that
<FromGitter> <sdogruyol> I need to check how Go handles that
<Papierkorb_> Kind of ironic that my speed-up refactoring of a ruby tool triggered a race condition in a crystal tool
<FromGitter> <bararchy> XD
<FromGitter> <sdogruyol> I couldn't find a slow attack stuff related to Go
<FromGitter> <sdogruyol> maybe they haven't tried yet?
<FromGitter> <bararchy> So, what with https://github.com/crystal-lang/crystal/tree/0.24.0 this is getting really frustrating
<Papierkorb_> sdogruyol, who knows, but with "fast languages" these kind of attacks go out of mind for many. "Ruby is slow, so it's affected. $CoolLang is fast, so it can't be!"
<FromGitter> <bararchy> coolnag
<FromGitter> <bararchy> hahah
<FromGitter> <sdogruyol> lol
<FromGitter> <bararchy> Who can announce a new version btw ?
<FromGitter> <bararchy> RX14 ? @asterite ?
<Papierkorb_> whoat ruby does thread dead-lock detection? And it actually works!
<FromGitter> <bew> no it was someone else iirc @bararchy (don't remember who though)
<FromGitter> <bararchy> @ysbaddaden ? for shards I guess, or @mgarciaisaia ?
<Papierkorb_> Someone from Manas, maybe @bcardiff?
<FromGitter> <bararchy> It's kinda wierd we don't even know who is version manager :\
<Papierkorb_> Should be put into the README
<FromGitter> <bararchy> Yap, major roles should all be public (main dev, core team, community manager, etc..)
<FromGitter> <sdogruyol> Ruby has a release manager
<FromGitter> <sdogruyol> they're long 1.0 though :P
<Papierkorb_> It took them a decade too *cough*
<FromGitter> <sdogruyol> hahaha
<FromGitter> <sdogruyol> you're right :P
<FromGitter> <sdogruyol> Ruby has a great community and support in Japan
<FromGitter> <sdogruyol> hope we something like that too 👍
mgarciaisaia has joined #crystal-lang
<FromGitter> <bararchy> for now a vague date for 0.24 would be good enough for me
<FromGitter> <bararchy> hahah
<FromGitter> <bararchy> and not needing to ask "wait, who decids that?"
<FromGitter> <mgarciaisaia> 👋 We're preparing the build, we'll publish it as soon as we have it - as usual :)
<FromGitter> <bew> 🎉
<FromGitter> <bararchy> Good enough for me :)
<FromGitter> <bararchy> 🎉
<FromGitter> <bararchy> btw, @mgarciaisaia who is the release manager for Crystal, you ?
<FromGitter> <mgarciaisaia> I wouldn't say we *have* a release manager
<FromGitter> <mgarciaisaia> I've been doing the last few releases, with support from the folks
<FromGitter> <mgarciaisaia> And will probably do this one
<FromGitter> <mgarciaisaia> But I won't tattoo that title in my arms :P
<FromGitter> <bararchy> XD I see
<FromGitter> <bararchy> so do you have an estimation for 0.24 ? as in like , today, tomorow, next week ?
<FromGitter> <bararchy> just so I can plan my release sched with the new version
<FromGitter> <mgarciaisaia> It's my first release involving a new shards release, so you'll have to be *even more* patient with me this time :)
<FromGitter> <mgarciaisaia> We're going to publish 0.24.0 as a RC in the draft release on GH
<FromGitter> <mgarciaisaia> And after some testing and that, we'll then make the official release via the usual repos
<FromGitter> <mgarciaisaia> We'll eventually have some unstable distribution channel - namely, different repos for beta releases -, but we haven't done that yet, so this is our poor-man's version
<FromGitter> <bararchy> it makes sense
mgarciaisaia has left #crystal-lang [#crystal-lang]
<FromGitter> <bararchy> last time (0.23.0) would have been avoided if we would have walked the same path
<FromGitter> <bararchy> good thinking
<FromGitter> <mgarciaisaia> At least partially..
<FromGitter> <bararchy> Cool, thanks for taking the time to answer :)
<FromGitter> <mgarciaisaia> np :)
<FromGitter> <bew> "involving a new shards release" which shard is it? ;)
<FromGitter> <bararchy> I think it's shards, as in "crystal deps"
<FromGitter> <bararchy> That's cool: https://crystal.libhunt.com/ didn't even know this was a thing
<FromGitter> <mgarciaisaia> @bew yeah - `shards` itself
<FromGitter> <bew> ah ok! :p great!
<crystal-gh> [crystal] MakeNowJust opened pull request #5174: `run` macro shows stderr when succeeded but there is stderr output (master...fix/crystal/macro-run-show-stderr) https://git.io/vdhXr
<FromGitter> <faustinoaq> Interesting first Joy (I mean Crystal) commit 👉 https://github.com/asterite/crystal/commit/50db22908a11b070c56524cc9bbd74332ad3a7c7
claudiuinberlin has joined #crystal-lang
<FromGitter> <bararchy> XD
<Papierkorb_> The name puns would've been much worse than they're with Crystal, so good change
<FromGitter> <sdogruyol> lol
<Papierkorb_> "Joy - A joy to type" It really only goes downhill from here
<FromGitter> <sdogruyol> why does macro runs take some much time especially for ecr?
<FromGitter> <sdogruyol> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=59ef455c614889d475f42d96]
<FromGitter> <sdogruyol> 1) 69 seconds...this is just running the specs.
snsei has joined #crystal-lang
claudiuinberlin has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
snsei has quit [Remote host closed the connection]
snsei has joined #crystal-lang
snsei has quit [Ping timeout: 246 seconds]
flaviodesousa has quit [Ping timeout: 240 seconds]
claudiuinberlin has joined #crystal-lang
claudiuinberlin has joined #crystal-lang
alex`` has quit [Ping timeout: 252 seconds]
<FromGitter> <unreadable> What are the major news in .24?
<crystal-gh> [crystal] MakeNowJust opened pull request #5176: Formatter: correctly indent implicit exception handler of do/end block (master...fix/crystal-format/indent-implicit-exception-handler-with-do-end) https://git.io/vdhN2
claudiuinberlin has quit [Quit: Textual IRC Client: www.textualapp.com]
<FromGitter> <ansarizafar> Why I am getting this error ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=59ef52ded6c36fca318ee5a5]
<FromGitter> <bew> you don't need `{{` and `}}`, `rs` is a variable in the generated code, not in the macro
snsei has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 240 seconds]
<FromGitter> <ansarizafar> @bew I want to create an Enum values from result set row. Now getting this error ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=59ef542bb20c64242940a7d0]
DTZUZO has quit [Ping timeout: 248 seconds]
rohitpaulk has joined #crystal-lang
noblehelm has joined #crystal-lang
snsei has quit [Remote host closed the connection]
Papierkorb_ has quit [Quit: Konversation terminated!]
cyberarm has quit [Ping timeout: 240 seconds]
cyberarm has joined #crystal-lang
<gcds> How I can hide property from pretty print?
<Yxhuvud> define your own inspect (or to_s, depending on exactly how you print).
<FromGitter> <martinos> I am on OS X and when I run `!crystal run %` in vim, my display does not refresh properly and I need to restart vim. It does that even if I remove my vim config files. Anyone is having this issue ?
alex`` has joined #crystal-lang
<FromGitter> <martinos> I does that even if I run `! crystal run --no-color %`
DTZUZO has joined #crystal-lang
<crystal-gh> [crystal] MakeNowJust opened pull request #5178: Parser: correctly parse local variable in implicit block exception handler (master...fix/crystal/5177-local-variable-in-implicit-block-exception-handler) https://git.io/vdjJb
<FromGitter> <bew> @ansarizafar you can't run arbitrary code in macros like this, you may need to use macro run for that
<FromGitter> <MakeNowJust> sorry, I should have taken care before merged #5114. #5176 and #5178 are my apology. thank you so much @straight-shoota
<DeBot_> https://github.com/crystal-lang/crystal/pull/5114 (Allow flat rescue/ensure/else block in do/end block) | https://github.com/crystal-lang/crystal/pull/5176 (Formatter: correctly indent implicit exception handler of do/end block) | https://github.com/crystal-lang/crystal/pull/5178 (Parser: correctly parse local variable in implicit block exception handler)
claudiuinberlin has joined #crystal-lang
noblehelm has quit [Ping timeout: 246 seconds]
claudiuinberlin has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<FromGitter> <GrgDev> Is there an equivalent of `#responds_to?` that works on structs instead of methods?
<FromGitter> <GrgDev> I have a case where a module is being passed in and I can use `#responds_to?` to see what methods are defined in the module as long as it extends self but I need to find out if it also defines a struct with an expected name.
claudiuinberlin has joined #crystal-lang
<FromGitter> <ansarizafar> Is it possible to convert JSON::Type to Int32?
<crystal-gh> [crystal] straight-shoota opened pull request #5179: Proper implementation of Dir.glob (master...jm-glob) https://git.io/vdjLR
saadq has quit [Ping timeout: 248 seconds]
<FromGitter> <straight-shoota> @MakeNowJust I was actually surprised that #5114 was merged so fast. There was some serious doubt if this feature should be added at all and then it suddenly got merged - obviously without an in-depth review. I mean it was formally ok, two core members approved it...
<DeBot_> https://github.com/crystal-lang/crystal/pull/5114 (Allow flat rescue/ensure/else block in do/end block)
saadq has joined #crystal-lang
<FromGitter> <vonKingsley> @martinos i believe its related to https://github.com/crystal-lang/crystal/issues/2713
z64 has joined #crystal-lang
mark_66 has quit [Remote host closed the connection]
sz0 has quit [Quit: Connection closed for inactivity]
rohitpaulk has quit [Ping timeout: 248 seconds]
gcds has quit [Ping timeout: 240 seconds]
rohitpaulk has joined #crystal-lang
noblehelm has joined #crystal-lang
<FromGitter> <martinos> @vonKingsley , thanks it's probably that.
noblehelm has quit [Quit: leaving]
martinium has joined #crystal-lang
gcds has joined #crystal-lang
gcds has quit [Client Quit]
hightower4 has joined #crystal-lang
linuksz has joined #crystal-lang
alex`` has quit [Ping timeout: 252 seconds]
hightower3 has quit [Ping timeout: 252 seconds]
gcds has joined #crystal-lang
gcds has quit [Client Quit]
<linuksz> why doesn't it work? https://carc.in/#/r/2yei
<linuksz> shouldn't it print "child" also?
<Yxhuvud> no, it exits before that
<linuksz> why
<Yxhuvud> because it reaches the end of the program.
<linuksz> doesn't the child run the if statement?
<Yxhuvud> sure, but then the parent ends and kill all child processes on exit
<linuksz> so adding a sleep maybe works?
<Yxhuvud> yes, or explicitly waiting for the child.
<linuksz> so
<linuksz> child = fork
<linuksz> child.wait
<linuksz> ?
<FromGitter> <unreadable> if the crystal concurrency is based on the Go model, does that mean that the parallelism will be based on the Go model as well?
<crystal-gh> [crystal] maxpowa opened pull request #5180: Change properties key to _properties_ to reduce chance of conflict (master...change-json-named-args) https://git.io/vdjWz
claudiuinberlin has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
claudiuinberlin has joined #crystal-lang
<linuksz> I want to write a program that uses a socket for inter-process communication, but i don't understood how to work with sockets in Crystal. Does the program use UNIXServer, and the client use UNIXSocket class?
<oprypin> probably
<linuksz> But the example provided in Crystal docs doesn't work
<FromGitter> <ansarizafar> oprypin Is it possible to convert JSON::Type to Int32?
alex`` has joined #crystal-lang
<oprypin> linuksz, send it here to check, and file a bug if that's true
<linuksz> oprypin, What should I send?
<oprypin> ansarizafar, yes
<oprypin> linuksz, i mean say in this chat which exact example "doesn't work" and how you can tell that
<FromGitter> <pnloyd> @oprypin can look at this? https://github.com/oprypin/crystal-raw-gl/pull/2
<linuksz> https://crystal-lang.org/api/0.23.1/UNIXServer.html the first example on the page
<oprypin> pnloyd, sure. hmm why didnt i notice it
<FromGitter> <ansarizafar> oprypin Could you please show me, How to convert JSON::Type to Int32 or JSON::Any
<FromGitter> <pnloyd> @oprypin, I didn't know if I had to mention you or not in the request for you to get a notification so I figured I'd just tell you.
<FromGitter> <bew> Linuksz hmm seems to be a `client = server.accept` missing
<linuksz> @bew, how can where should i insert this code?
<oprypin> ansarizafar, that.as(Int32) is the short answer
claudiuinberlin has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<FromGitter> <ansarizafar> oprypin getting this error ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=59ef883fd6c36fca319036e0]
<oprypin> ansarizafar, sorry, that's right. so you do .as(Int64).to_i
<FromGitter> <bew> Linuksz after the first line
alex`` has quit [Quit: WeeChat 1.9.1]
<FromGitter> <bew> Then you'd use `message = client.gets` instead of `message = server.gets`
claudiuinberlin has joined #crystal-lang
<linuksz> and what should i do in the client?
<FromGitter> <bew> (note that I'm on my phone, so I didn't test that since some time)
<FromGitter> <bew> For the client, the example should work https://crystal-lang.org/api/0.23.1/UNIXSocket.html
alex`` has joined #crystal-lang
<oprypin> agree
<linuksz> @bew, thanks
<FromGitter> <ansarizafar> oprypin Thanks
<FromGitter> <bew> I won't pr a doc fix tonight (it's 8pm here), so if someone wants to do it, go ahead!
rohitpaulk has quit [Remote host closed the connection]
Disrecollection has quit [Quit: Leaving.]
<FromGitter> <bew> @straight-shoota your revamped glob looks great!
claudiuinberlin has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<FromGitter> <straight-shoota> thanks @bew
<FromGitter> <sdogruyol> good job @straight-shoota 👍
claudiuinberlin has joined #crystal-lang
martinium has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
claudiuinberlin has quit [Quit: Textual IRC Client: www.textualapp.com]
<crystal-gh> [crystal] petoem opened pull request #5181: Fix UNIXServer example in docs (master...fix-unixserver-docs) https://git.io/vdjov
<FromGitter> <petoem> I made a PR for the UNIXServer doc fix.
<FromGitter> <sdogruyol> thanks @petoem
alex`` has quit [Quit: WeeChat 1.9.1]
linuksz has quit [Ping timeout: 248 seconds]
<FromGitter> <pnloyd> If you do `sleep` in main fiber after you've spawned other fibers, will the program exit automatically when the spawned fibers exit?
<FromGitter> <bew> nop (did you tried? :) )
<Papierkorb> No, the process is exited once the main fiber ends
<FromGitter> <pnloyd> I have code like this now but the program appears to keep running after the spawned fibers should have exited
<Papierkorb> You can still use `#exit` of course to force a process end
<FromGitter> <pnloyd> So simple solution is just to have spawned fiber's call exit
<FromGitter> <pnloyd> before they expect to exit
<Papierkorb> Or use a `Channel` to effectively lock your main fiber (`Channel#receive`), until someone sends something into it
<FromGitter> <pnloyd> For a more granular solution, I see thanks @Papierkorb
<Papierkorb> The channel lock is probably the "cleanest" solution in the long term. You can also use it to e.g. clean up after your algorithm decided it's time to quit
<FromGitter> <unreadable> Is there something similar like sync.Waitgroup{} in crystal to manage concurrency better?
<FromGitter> <bew> currently, no
<Papierkorb> What's that supposed to do?
<Papierkorb> Wait on what?
<FromGitter> <bew> to wait multiple fibers
<Papierkorb> `channels.each(&.receive)`
<Papierkorb> There's your wait group
<FromGitter> <bew> like in go (someone posted that same request some time ago here)
<FromGitter> <bew> like in `Fiber.wait_group(fiber1, fiber2)`
<FromGitter> <unreadable> Thanks!
martinium has joined #crystal-lang
<RX14> @bew I think that such control flows are often better modeled by promises
<RX14> since the fibers you're waiting on often want to return a value
<RX14> promise encapsulates that whole concept
<RX14> and you can always promise a Nil type if you only need synchronization
<RX14> plus you get stuff like Promise.any as well as Promise.all
<FromGitter> <bew> yeah probably! (the original asker was thinking at sth like https://golang.org/pkg/sync/#WaitGroup)
<RX14> i should really revamp promises and bring them back
<FromGitter> <bew> for crystal you mean?
<RX14> yep
<RX14> CSP is fantastic for modelling mostly-linear code
<RX14> which is the majority of code
<RX14> but sometimes you really want to just spin off tiny tasks in parallel
<RX14> we don't need stuff like .then from JS though
<RX14> i don't think
<FromGitter> <bew> there's the macro `parallel` iirc
<RX14> that should probably be removed and replaced with promises
<FromGitter> <bew> yes, it's a better approach to the problem imo
<RX14> hopefully people coming from JS won't reach for them first though
<RX14> they're not the primary means of concurrency by any means
<RX14> their usage is actually quite rare
Disrecollection has joined #crystal-lang
<FromGitter> <bew> we'll need good documentation to reflect that ;)
<FromGitter> <pnloyd> Is there any method to format numbers? To make debug output look pretty.
DTZUZO has quit [Ping timeout: 248 seconds]
<FromGitter> <pnloyd> I found printf now.
<FromGitter> <pnloyd> is `struct String::Formatter(A)` the same as like the linux prinf formatting syntax?
<FromGitter> <bew> yes, it uses snprintf under the hood if I remember correctly
<FromGitter> <pnloyd> formatter.cr appears to be some implementation in pure crystal
<FromGitter> <pnloyd> Just has `# :nodoc:` up at the top
<FromGitter> <pnloyd> lol
martinium has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<FromGitter> <pnloyd> Oh I see it makes calls to snprintf
<RX14> hopefully only in some cases
<RX14> i.e. when it's too complex to be implemented in crystal (yet)
<FromGitter> <bew> yes, seems to be for floating only
<RX14> ok
<FromGitter> <bew> but now we have proper floating number printer, it could use this, no?
<FromGitter> <pnloyd> But besides that, are parts implemented in crystal a re-implementation of the libc printf format?
<RX14> yes
<FromGitter> <pnloyd> Awesome, thanks
<RX14> no docs tho
<RX14> that sucks
<FromGitter> <mixflame> hi guys we're starting a Crystal consultancy, so if you're doing Crystal and you need help, let me know
<FromGitter> <mixflame> 💎
<FromGitter> <sdogruyol> @mixflame that's interesting, good luck 👍
<FromGitter> <mixflame> thanks @sdogruyol :)
<FromGitter> <pnloyd> @RX14 couldn't some libc printf docs be quickly copied/re-purposed at some point though.
<RX14> @mixflame that's cool, how did you/your company get enough experience using crystal to be comfortable consulting for other people?
<FromGitter> <simaoneves> quick question everyone, when we compile a program with the --release flag, its shards that are also used should be compiled aswell correct? no need for another flag when compiling right?
<FromGitter> <mixflame> I wrote an app called LivePost with Crystal to teach myself how... https://livepost.mixflame.com
<FromGitter> <simaoneves> asking this because i compiled a program today a and sent it to a friend, but it said a lib was missing
<FromGitter> <mixflame> other developer hasnt started on Crystal yet but im not afraid of that
<FromGitter> <mixflame> he's a Ruby guy
<RX14> @mixflame cool
<FromGitter> <mixflame> ty ty
<FromGitter> <mixflame> :D
<RX14> @simaoneves all crystal code is compiled into one executable however we depend on some C libraries
<RX14> the problem is likely that the person you sent the app to didn't have the same packages installed
<FromGitter> <simaoneves> hmm right, but still, it should work no?
<RX14> no
<FromGitter> <simaoneves> the shard in question was Termbox for crystal
<RX14> and thats why im telling you its a problem
<FromGitter> <mixflame> i got the test, it worked lol (on livepost)
<RX14> and you're asking
<RX14> instead of it working and this conversation never happening
<FromGitter> <simaoneves> true :P
<RX14> it might not even be a shard
<RX14> it might be crysta's stdlib
<FromGitter> <simaoneves> i believe it said termbox lib specifically
<RX14> oh ok
<FromGitter> <simaoneves> i tought that when we compile the C libs would go into the final executable
<RX14> well then
<RX14> nope
<RX14> C libs are linked dynamically
<oprypin> RX14, but there is a way to achieve that, right?
<RX14> not without being a wizzard
<FromGitter> <simaoneves> oh ok
<FromGitter> <bew> ahah
<FromGitter> <simaoneves> so in this case, my executable has a dependency on that C lib, on the computers who try to run it then
<RX14> yep
<RX14> the solution is static binaries but you really need alpine for that
<FromGitter> <bew> yes, you can check the dependencies of a program using `ldd <the_program>` (on linux)
<FromGitter> <pnloyd> @simaoneves is using Docker an ok solution for you?
<FromGitter> <bew> for what?
<FromGitter> <bew> ah no sorry
<FromGitter> <pnloyd> Giving his program to his friend.
<FromGitter> <simaoneves> ermm dont think so, even tho i never used Docker
<FromGitter> <bew> and the friend would have to install docker..
<FromGitter> <simaoneves> @bew using MacOS here eheh
<FromGitter> <simaoneves> im building a text editor in crystal
<FromGitter> <bew> I'm sure there's a macos version of ldd!
<FromGitter> <simaoneves> i guess Docker would not be good in this case?
<FromGitter> <simaoneves> ok, ill check, thanks :)
<FromGitter> <pnloyd> Well Docker is easy to use in simple cases
<FromGitter> <bew> oh cool!
<RX14> just get the other person to install termbox C @simaoneves
<RX14> assuming they're a developer
<RX14> you must have installed termbox's C library somehow
<RX14> so you should send the same instructions
<FromGitter> <simaoneves> yep, another options is to use ncurses maybe, probably thats more widely available
<FromGitter> <pnloyd> Someone posted this magical one liner on a manas employee's gist. ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=59efbaf8b20c642429430bb7]
<FromGitter> <bew> or rewrite termbox in pure-crystal (really want to do that since some time ^^)
<FromGitter> <pnloyd> In can be used to create tiny docker images for crystal programs
<FromGitter> <simaoneves> @RX14 yep exactly, thanks :)
bmcginty has quit [Ping timeout: 260 seconds]
<RX14> @pnloyd im not sure how that helps
<FromGitter> <simaoneves> @pnloyd cool, will check that out, one more thing to learn :)
bmcginty has joined #crystal-lang
<RX14> no please don't do what @pnloyd says
<FromGitter> <pnloyd> I'm not suggesting it's a good solution.
<FromGitter> <simaoneves> @bew eheh, lots of hardwork
<RX14> i wouldnt have thought it even worked
<RX14> at least not witjhout context
<RX14> it's for docker
<RX14> i mean it has the libs anyway
<RX14> why is it copying them?
<FromGitter> <pnloyd> It does work, I was surprised too and it's confusing, it works even *without* basing off alpine.
<RX14> but it's for docker
<RX14> it should work no problems without that
<RX14> i don't understand
<FromGitter> <pnloyd> Err
<FromGitter> <pnloyd> After compiling the crystal binary it does `FROM scratch`
<FromGitter> <pnloyd> And copies only the crystal executable and needed libs
<RX14> ok so it's a technique for minimizing docker images
<RX14> which is largely unrelated
<RX14> to what the question was
<FromGitter> <pnloyd> Well I mean if they were both pre-existing Docker users it could potentially offer a convenient solution..
<RX14> but docker is the solution
<RX14> all this does is make the image smaller
<RX14> it's portable with or without this snippet
<FromGitter> <pnloyd> True but sending around 50MG+ files is kinda annoying/tedious
<RX14> plus you leave off the crucial context of `FROM scratch` and building in a previous container
<FromGitter> <pnloyd> Sorry I just wanted to share that line because I thought it was interesting/neat.
<FromGitter> <simaoneves> thanks for the suggestion anyway, it was interesting, even tho i dont see it as the definite solution in the long run
<FromGitter> <simaoneves> :)
<RX14> yeah
<RX14> hopefully we have better tools in the future
<RX14> to make static complication easy
<RX14> compilation*
<FromGitter> <bew> lol
<FromGitter> <simaoneves> 👍
<FromGitter> <drosehn> Hmm. Is there a compile-time constant which gives the version of the crystal compiler the program was compiled with? Maybe `__CRYSTAL_VERSION__` ?
<watzon> I need some examples of crystal being faster than c++
<watzon> Anything?
<FromGitter> <bew> That'll be hard imo, only the `Array#sort` implementation is faster iirc
Disrecollection has quit [Ping timeout: 240 seconds]
Disrecollection has joined #crystal-lang
latemus has joined #crystal-lang