ChanServ changed the topic of #crystal-lang to: The Crystal programming language | http://crystal-lang.org | Crystal 0.24.2 | 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> <faustinoaq> @girng Scry is a magic crystal ball that help you to program your "crystals" XD
<FromGitter> <faustinoaq> Nah, Scry is something better, is an amazing tool, is a code analysis server for Crytal, is THE language server protocol implementation for crystal ✨
<FromGitter> <faustinoaq> Scry + Ameba is 🚀
<FromGitter> <Blacksmoke16> that doenst work for Intella-J :(
<FromGitter> <Blacksmoke16> or however you spell it
<FromGitter> <Blacksmoke16> :p
<FromGitter> <faustinoaq> @Blacksmoke16 I gonna try Intellij-Idea right now, let me test it 😉
<FromGitter> <faustinoaq> Intellij-idea package download size is 637M 😟
<FromGitter> <faustinoaq> Well, at least is smaller than VS on Windows 😅
<FromGitter> <faustinoaq> VSCode package is just 44MB on Linux and around 30 MB on Windows 😄
DTZUZU has quit [Quit: WeeChat 1.9]
<FromGitter> <Blacksmoke16> hehe
<FromGitter> <faustinoaq> Already downloaded! 💪
<FromGitter> <j8r> Maybe because od gui stuff
<FromGitter> <Blacksmoke16> \o/
<FromGitter> <j8r> Electron on mac on windows can use shared libs, on linux not except maybe glibc
<FromGitter> <girng> @faustinoaq can i use it for my game server, what does it do
hightower2 has quit [Ping timeout: 248 seconds]
<FromGitter> <j8r> That's for your IDE
<FromGitter> <girng> so like intellisense?
<FromGitter> <girng> but 4 crystal?
<FromGitter> <faustinoaq> @girng Yep
<FromGitter> <faustinoaq> @j8r Almost done 😉
<FromGitter> <girng> only works under vs code?
<FromGitter> <girng> or which editors
<FromGitter> <j8r> Wow 1.270 GB
<FromGitter> <faustinoaq> @girng Well, Scry should work on every editor with LSP client support, see https://github.com/crystal-lang-tools/scry/issues/56
<FromGitter> <faustinoaq> We need some guides about configuring scry, though
<FromGitter> <faustinoaq> Right now Scry works pretty well on Atom and VSCode 😄
<FromGitter> <girng> maybe that gives me a good reason to use vs code? :D
<FromGitter> <faustinoaq> Well, Scry should work on Sublime Text as well 😉
<FromGitter> <girng> O_O
<FromGitter> <faustinoaq> Let me try Sublime Text and see if the sublime issues are already fixed with latest changes, see:https://github.com/crystal-lang-tools/scry/issues/34
<FromGitter> <faustinoaq> @girng Well, If you're using sublime text on windows I guess you should create a `scry.bat` file like this: ⏎ ⏎ ```@echo off ⏎ bash.exe -c '/path/to/scry'``` [https://gitter.im/crystal-lang/crystal?at=5aed0383db299d4004d1c025]
<FromGitter> <faustinoaq> And put that file inside `C:\Programs Files\Crystal\`
<FromGitter> <girng> lol
<FromGitter> <girng> im scared to try atm but will try it l8er ^^
<FromGitter> <asterite> How do I install scry? I tried but failed. There were no clear instructions. Well, si installed the VS code plug in, but then it didn't work. I couldn't figure out how to install the server.
<faustinoaq> @asterite Yeah, We need to write some guides on Scry Wiki, I guess we can do that after v0.8.0 is published, this new release will include a bunch of new features and bugfixes ;-)
<faustinoaq> I wrote some instructions on vscode-crystal-lang wiki, see: https://github.com/crystal-lang-tools/vscode-crystal-lang/wiki/Settings#server
<faustinoaq> @asterite Oh, you can try atom as well, scry was embedded by default on atom-ide-crystal by @keplersj :-)
<faustinoaq> I'm thinking on include scry by default on vscode-crystal-lang too :D
<FromGitter> <asterite> That would be awesome
<FromGitter> <girng> you're awesome
<faustinoaq> lol, I installed the enterprise edition of Intellij-Idea, now I'm getting a 30 days trial XD
<FromGitter> <bew> you should use the community edition
<FromGitter> <bew> !
<faustinoaq> Yeah, I just uninstalled it and now I'm downloading 500MB more for community edition :)
<FromGitter> <bew> \o/
<FromGitter> <faustinoaq> Wow, Sublime text package is just 7.86MB!!! 😃
<FromGitter> <faustinoaq> Is almost like VIM or Emacs but easier to use 😉
<FromGitter> <girng> ``` master_server.send "helo", "hey" ⏎ ^~~~```` [https://gitter.im/crystal-lang/crystal?at=5aed1c3bdb299d4004d1ee71]
<FromGitter> <girng> i can't get my app to compile, i've been stuck for 2 hours now im getting really sad
<FromGitter> <girng> client class: https://paste.ee/p/VH7xm ⏎ GameServer class: https://paste.ee/p/C7TfQ
<FromGitter> <girng> all i'm trying to do is make a reference to my `master_server`, once that connection has been authenticated
<FromGitter> <girng> you see that reference created at `@master_server = client` line 20
<FromGitter> <girng> why does it say `undefined method 'send' for Nil ` when I am EXPLICITLY checking for the type: `is_a? Client`
<FromGitter> <girng> If it's a Client, it cannot be nil.... it's already referenced
<FromGitter> <Blacksmoke16> try ⏎ ⏎ ```master_server.send "helo", "hey" ⏎ end``` [https://gitter.im/crystal-lang/crystal?at=5aed219053ceca3604b28c2e]
<FromGitter> <girng> it works!
<FromGitter> <girng> wait, where is `ms` coming from??
<FromGitter> <Blacksmoke16> is a variable declaration happening in the if statement if master_server is not null
<FromGitter> <girng> but i'm already doing that..
<FromGitter> <girng> !master_server.nil?
<FromGitter> <girng> i am so confused...
<FromGitter> <Blacksmoke16> what happens if you get rid of the `&& master_server.is_a? Client`
<FromGitter> <girng> same error
<FromGitter> <girng> that's why i added it cuz it hought i had to check for that too
<FromGitter> <girng> i mean honestly. i did everything right
<FromGitter> <girng> WHY does this happen to me
<FromGitter> <girng> what is wrong with me
<FromGitter> <Blacksmoke16> is master_server always for sure going to be not nil in your use case there?
<FromGitter> <Blacksmoke16> or will you have to sometimes handle if it is nil
<FromGitter> <girng> yep. if master_server becomes nil again, abort is run
<FromGitter> <girng> exits the app
<FromGitter> <girng> i guess, in this case what's the difference between: ⏎ ⏎ ```if !master_server.nil?``` ⏎ ⏎ ? [https://gitter.im/crystal-lang/crystal?at=5aed236200dc48880497a41f]
<FromGitter> <girng> what did i do wrong
<FromGitter> <Blacksmoke16> afaik (correct me if im wrong)
<FromGitter> <Blacksmoke16> hm
<FromGitter> <Blacksmoke16> what if you do `if master_server`
<FromGitter> <girng> `in src/GameServer.cr:92: undefined method 'send' for Nil (compile-time type is (Client | Nil))` lol
<FromGitter> <girng> why does it say for Nil
<FromGitter> <girng> when the `.send` is being excuted inside the if statement, that is only executed when the master_server is NOT nil
<FromGitter> <Blacksmoke16> what happens if you `p typeof(master_server)` in the if block
<FromGitter> <Blacksmoke16> oh
<FromGitter> <Blacksmoke16> shouldnt you be doing `@master_server`?
<FromGitter> <Blacksmoke16> no
<FromGitter> <Blacksmoke16> yea
<FromGitter> <Blacksmoke16> since its an instance var of your gameserver class
<FromGitter> <bew> @girng what is `master_server` ? a method or a local variable?
<FromGitter> <bew> I guess it's a method
<FromGitter> <Blacksmoke16> is a class variable
<FromGitter> <Blacksmoke16> er instance*
<FromGitter> <Blacksmoke16> https://paste.ee/p/C7TfQ#s=0&l=5
<FromGitter> <bew> in that case you need to assign it first to a local variable
<FromGitter> <bew> then use the local var for the nil check and the .send
<FromGitter> <bew> a `if some_var` or `if some_var.nil?` or `if `some_var.is_a? Client` works ONLY on local variables
<FromGitter> <Blacksmoke16> which is why the ms = master_server works
<FromGitter> <bew> exactly
<FromGitter> <Blacksmoke16> why is that?
<FromGitter> <Blacksmoke16> technical limitation or something?
<FromGitter> <bew> no
<FromGitter> <bew> because maybe on the next method call the return value will be different
<FromGitter> <girng> how do i assign an instance variable to a local variable?
<FromGitter> <bew> so you can't rely on calling the method twice and expect that it won't be nil
<FromGitter> <Blacksmoke16> ```if ms = master_server ⏎ ms.send "helo", "hey" ⏎ end``` [https://gitter.im/crystal-lang/crystal?at=5aed27ac40f24c430453eb2b]
<FromGitter> <Blacksmoke16> right since in between calls something could have changed that instance vars values, gotcha
<FromGitter> <bew> yes
<FromGitter> <bew> and the same with instance vars, maybe between first and second access the value changed
<FromGitter> <Blacksmoke16> that if statement you are assigning master_server to local var ms in the if statement, since nil is falsy value ms is assured to be not nil
<FromGitter> <bew> I can't find the language doc for this behavior though, if anyone find it I'm interested
<FromGitter> <girng> if i do ⏎ ⏎ ``` loop do ⏎ sleep 0.5.seconds ⏎ puts master_server ⏎ end``` ⏎ ⏎ it will print blanks. but once master_server is assigned, line 20 (in above paste.ee). it then prints `#<Client:0x1350e40>` [https://gitter.im/crystal-lang/crystal?at=5aed28ae6f9af87e0444188f]
<FromGitter> <Blacksmoke16> prob nil at that point
<FromGitter> <girng> hmm
<FromGitter> <Blacksmoke16> puts master_server.nil?
<FromGitter> <Blacksmoke16> `it will print blanks. but once master_server is assigned` ofc since you declare it as Client or Nil
<FromGitter> <Blacksmoke16> if you call it before you assign it, it'll ofc be nil
<FromGitter> <girng> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5aed29036d98e53e04532dd8]
<FromGitter> <girng> but it's in a LOOP
<FromGitter> <Blacksmoke16> using fibers
<FromGitter> <girng> doesn't it re-check it every other loop iteration????
<FromGitter> <Blacksmoke16> prob what happens is the fibers get created before it gets set
<FromGitter> <Blacksmoke16> maybe add a like puts "is master_server nil? #{@master_server.nil?}" outside the loop but inside the spawn.do
<FromGitter> <girng> @Blacksmoke16 shows `is master_server nil? true`
<FromGitter> <Blacksmoke16> yea so when the fiber is created master_server is nil
<FromGitter> <girng> but that's understandable and correct, because master_server isn't assigned
<FromGitter> <Blacksmoke16> so when it gets executed it is nil in your loop
<FromGitter> <girng> but every loop iteration, it's checking the if statement
wmoxam has joined #crystal-lang
<FromGitter> <girng> no it becomes not nil
<FromGitter> <girng> though.
<FromGitter> <girng> see the true true true true, false false above. it becomes not nil
<FromGitter> <girng> so it changes
<FromGitter> <Blacksmoke16> you didnt have it in the if statement when you did `puts master_server`
<FromGitter> <girng> 1 second let me make s/s
<FromGitter> <Blacksmoke16> and? that would be expected
<FromGitter> <Blacksmoke16> you dont have the if block there, so it can be null when it gets printed
<FromGitter> <girng> ``` if !master_server.nil? ⏎ puts "I GET CALLED" ⏎ end``` [https://gitter.im/crystal-lang/crystal?at=5aed2ba603cafa797b2a72b7]
<FromGitter> <girng> THAT GETS CALLED
<FromGitter> <girng> each loop.
<FromGitter> <Blacksmoke16> hm
<FromGitter> <Blacksmoke16> well yea, we talked about this you have to assign master_server to a local variable first
<FromGitter> <girng> if !master_server.nil? ⏎ ⏎ ``` puts master ⏎ end``` [https://gitter.im/crystal-lang/crystal?at=5aed2bec00dc48880497b33b]
<FromGitter> <girng> ``` if !master_server.nil? ⏎ puts master_server ⏎ end``` ⏎ ⏎ this prints the client. i should be able to access the .send then [https://gitter.im/crystal-lang/crystal?at=5aed2c0403cafa797b2a76ec]
<FromGitter> <bew> What are you trying to do/prove?
<FromGitter> <girng> how is that code not right?
<FromGitter> <girng> im trying to figure out what i did wrong
<FromGitter> <bew> @girng
<FromGitter> <girng> because quite frankly im getting really depressed and fed up with spending HOURS trying to fix something that seems perfectly reasonable
<FromGitter> <girng> and I did everything, the correct way.
<FromGitter> <girng> is_a? Client, and check if it;s NOT NIL
<FromGitter> <Blacksmoke16> you need to either use ⏎ ⏎ ```if ms = master_server ⏎ ms.call(xxx) ⏎ end``` [https://gitter.im/crystal-lang/crystal?at=5aed2c6b6d98e53e045333e7]
<FromGitter> <Blacksmoke16> or
<FromGitter> <girng> i know what i need to do to make it work. but i don't understand why.
<FromGitter> <bew> You need to assign your server to a local var, on which you do the nil check then call what you want on it
<FromGitter> <Blacksmoke16> ```ms = master_server ⏎ if ms ⏎ ms.call(xx) ⏎ end``` [https://gitter.im/crystal-lang/crystal?at=5aed2c7f5cf0b8300459dee0]
<FromGitter> <bew> What's not clear in my previous explanation?
<FromGitter> <girng> @bew why does it need to be a "local variable" when it prints the client address, etc. why can't we use .send on that?
<FromGitter> <bew> (see @Blacksmoke16's screenshot)
<FromGitter> <Blacksmoke16> `since in between calls something could have changed that instance vars values, which could be Nil`
<FromGitter> <girng> but how can something change when it's inside an if block checking if it's NOT NIL...........
<FromGitter> <Blacksmoke16> because the compiler doesnt know that
<FromGitter> <Blacksmoke16> prob
<FromGitter> <Blacksmoke16> since is why it didnt compile vs just not getting executed
<FromGitter> <bew> The compiler can't be sure (and won't ever) that a call to `master_server` in the if will give the same thing as the call to do the nil check
<FromGitter> <girng> and besides, even you do if ms=master_server, the master_server can still become nil, and then that if block will then not execute. same exact logic as checking if it's not nil
<FromGitter> <Blacksmoke16> master_server cant, but since you are assigning it to the local variable ms it captures the type and value of master_server at that point in time
<FromGitter> <bew> So maybe the first time (at the nil check), the `master_server` method will return something that is not nil (entering the if), then on the next call (in the if), the method could return nil, and you'd have a runtime crash..
<FromGitter> <bew> You can't hace this problem when using a local var
<FromGitter> <bew> have*
<FromGitter> <bew> @girng do you understand?
<FromGitter> <bew> Oh sorry didn't see you messages ><
<FromGitter> <bew> if `@master_server` changes to nil in the if block, the local var will still have the previous value (not nil), that is still valid!
<FromGitter> <girng> ``` if !master_server.nil? ⏎ puts master_server ⏎ end``` ⏎ ⏎ it shows: #<Client:0x19ece40> ⏎ ⏎ why can't i access anything with `master_server`? ... [https://gitter.im/crystal-lang/crystal?at=5aed2ee600dc48880497b845]
<FromGitter> <Blacksmoke16> the compiler doesnt know, so in order to prevent a runtime crash it disallows you from doing it on compile
<FromGitter> <Blacksmoke16> since the value cannot be assured to be not nil when you go to access the method/property
<FromGitter> <girng> but i am checking if it's not nil to prevent the crash..
<FromGitter> <girng> if i check if it's not nil, and that's true. then i have access to master_server
<FromGitter> <girng> i should be able to use it however i please, no?
<FromGitter> <Blacksmoke16> at this point just accept its something that you cant do
<FromGitter> <Blacksmoke16> ```code paste, see link```
<FromGitter> <Blacksmoke16> another fiber *could* set it to nil and it would cause a crash
<FromGitter> <girng> if another fiber sets it to nil, then my if block would not execute
<FromGitter> <Blacksmoke16> not to say you *are* but since it is possible, it doesnt compile to prevent a runtime crash
<FromGitter> <Blacksmoke16> assuming it got set before getting to your if statemetn
<FromGitter> <Blacksmoke16> if it gets set while it is inside it would error out
<FromGitter> <girng> what do you mean?
<FromGitter> <girng> "got set before getting to your if statements"
<FromGitter> <Blacksmoke16> sec
<FromGitter> <girng> "if it gets set while it is inside it would error out" i meant to quote this not the other my bad
<FromGitter> <Blacksmoke16> fiber 1 - master_server not nil ⏎ fiber 1 - if statement executes and passes ⏎ fiber 2 - sets master_server to nil ⏎ fiber 1 - goes to call method [https://gitter.im/crystal-lang/crystal?at=5aed31606d98e53e04533cef]
<FromGitter> <Blacksmoke16> something like that afaik
<FromGitter> <girng> ok fiber 2 and the one below it
<FromGitter> <bew> @girng https://carc.in/#/r/406s
<FromGitter> <girng> where im confused. i understand the other order
<FromGitter> <girng> fiber 2 - sets master_server to nil ⏎ fiber 1 - goes to call method
<FromGitter> <Blacksmoke16> check his carc, is basic what i was trying to get across in a better method
<FromGitter> <bew> in my example I've setup a method that return 1, then nil, then 1, then nil, etc
<FromGitter> <bew> to simulate that the value returned by `master_server` could change from call to call
<FromGitter> <girng> https://carc.in/#/r/406v
<FromGitter> <girng> WTF
<FromGitter> <Blacksmoke16> first time it gets called for the if statement expression, it returns 1 so it passes
<FromGitter> <Blacksmoke16> next time it gets called INSIDE the if statement , it is nil
<FromGitter> <Blacksmoke16> so just because it wasnt Nil the first time it was called doesnt mean it wont be the 2nd, or 3rd, 4th time etc
<FromGitter> <girng> i need to take a break
<FromGitter> <Blacksmoke16> sleep on it :p
<FromGitter> <Blacksmoke16> maybe it'll sink it
<FromGitter> <bew> and one day his mind will unlock (I'm sure it will :P)
<FromGitter> <girng> ok i understand what's going on now
<FromGitter> <Blacksmoke16> power nap ftw?
<FromGitter> <bew> hehe ✨
<FromGitter> <girng> that compile error is actually really good then. because if the master_server disconnects (and becomes nil) and then a method is called in that if statement
<FromGitter> <girng> could crash correct
<FromGitter> <Blacksmoke16> yes
<FromGitter> <bew> it's coming :D
<FromGitter> <girng> so an if statement really means fvck all
<FromGitter> <Blacksmoke16> it prevents runtime errors by catching possible crashes at compile time
<FromGitter> <Blacksmoke16> no
<FromGitter> <girng> local variables is safety
<FromGitter> <Blacksmoke16> that is only the case when you use an instance/class far with the if statement
<FromGitter> <girng> for safety, over if statements
<FromGitter> <Blacksmoke16> yes, local variables catch the value of the instance var so if the instance var changes in future the local var will be the same as it was when it was assigned
<FromGitter> <girng> "that is only the case when you use an instance/class far with the if statement"
<FromGitter> <girng> ok that's important to know =]
<FromGitter> <Blacksmoke16> also doesnt work with `variables bound in a closure`
<FromGitter> <Blacksmoke16> from the docs
<FromGitter> <Blacksmoke16> limitations section
<FromGitter> <girng> so, what happens when you do if ms = master_server, then use the local variable ms, and master_server becomes nil? it'll just jump out of that block and not crash?
<FromGitter> <girng> which is a good thing (no crash)
<FromGitter> <Blacksmoke16> it would still work because ms holds the value of master_server before it was set nil
<FromGitter> <Blacksmoke16> if master_server got set to nil *just* before ms = master_server, it would be safe since ms would be nil and would fail the if statement
<FromGitter> <girng> ooooo like a stored mini reference, for that block
<FromGitter> <girng> to safely execute
<FromGitter> <girng> so no crash happens
<FromGitter> <Blacksmoke16> yes
<FromGitter> <girng> ok, got it
<FromGitter> <girng> ty @Blacksmoke16 and @bew
DTZUZU has joined #crystal-lang
<FromGitter> <bew> @girng for a value type (e.g:: a struct, an int, etc) the local var will be a copy, and for a reference type (e.g: a class), the local var will have a reference to the data (like a pointer to it, internally)
<FromGitter> <girng> https://crystal-lang.org/docs/syntax_and_semantics/if_var.html i should have read this
<FromGitter> <Blacksmoke16> prob
<FromGitter> <girng> but i like your help better
<FromGitter> <Blacksmoke16> docs are there for a reason
<FromGitter> <Blacksmoke16> only lost a handful of hair in the process
<FromGitter> <bew> 😛
<FromGitter> <girng> @bew i see. hence no crash if it becomes nil
<FromGitter> <girng> @Blacksmoke16 where u find that image from?
<FromGitter> <Blacksmoke16> https://crystal-lang.org/
<FromGitter> <Blacksmoke16> literally on the homepage
<FromGitter> <girng> thx
<FromGitter> <girng> i feel like htat example isn't what i had though
<FromGitter> <girng> because that's based on randomness, i would never do that. i was checking for not nil
<FromGitter> <Blacksmoke16> not really, but shows a similar concept
<FromGitter> <girng> mine had to do more of the local variable
<FromGitter> <Blacksmoke16> yea, same concept tho
<FromGitter> <Blacksmoke16> that at a given time the exact type/value of `my_string` cannot be known
<FromGitter> <Blacksmoke16> so to prevent runtime errors it gets caught on compile
<FromGitter> <girng> now my question is
<FromGitter> <girng> if you do a if !master_server.nil? end block, why doesn't the language use the master_server inside that block as a local variable internally?
<FromGitter> <Blacksmoke16> :shrug:
rohitpaulk has joined #crystal-lang
<FromGitter> <Blacksmoke16> prob because you arent explicitly telling it to,
<FromGitter> <Blacksmoke16> how would it know to use a local variable or the actual instance var
<FromGitter> <girng> because you're checking if it's not nil
<FromGitter> <girng> LOL
<FromGitter> <bew> No, better to explicit instead of the compiler doing too much magic
<FromGitter> <bew> And you have more control when you're explicit
<FromGitter> <bew> And just a note: `if !expr.nil?` is the same as `if expr`
<FromGitter> <bew> (unless `expr` can be a boolean but that's not very common)
<FromGitter> <girng> yea undeerstandable i was being a bit facetious i apologise
<FromGitter> <bew> So you can simply write `if var = method` instead of `if !(var = method).nil?`
<FromGitter> <girng> i actually did not know the values could change inside an if block
<FromGitter> <girng> i always just thought, if it's not nil or if you're using an if statement, you should be fine
<FromGitter> <girng> how do other languages manage this?
<FromGitter> <girng> just local variables everywhere?
<FromGitter> <bew> Most of them have runtime crashes when you're not very careful
<FromGitter> <bew> (you as the programmer)
<FromGitter> <Blacksmoke16> that is only possible if using concurrent/parallel methods tho?
<FromGitter> <Blacksmoke16> night
<FromGitter> <girng> gn
<FromGitter> <girng> can channels communicate with other crystal processes?
rohitpaulk has quit [Ping timeout: 240 seconds]
<FromGitter> <faustinoaq> Hey @/all crystal community, new gitter channel for SushiChain 👉 https://gitter.im/SushiChain/Lobby 🎉 ✨ 😄
<FromGitter> <faustinoaq> This room has a bridge bot between slack/discord/gitter, I guess telegram as well 😉
<FromGitter> <faustinoaq> SushiChain is a nice crypto implemented initially on crystal, see the official and beautiful website 👉 https://sushichain.io/ 😍
<FromGitter> <bararchy> @girng no, channels need to be in same process and share memory
<FromGitter> <girng> thx
<FromGitter> <bararchy> You can communicate between processes via IPC methods like sockets, files, and message-queues
<FromGitter> <girng> http://stefanwille.github.io/crystal-redis/doc/Redis.html#open%28host%3D%26quot%3Blocalhost%26quot%3B%2Cport%3D6379%2Cunixsocket%3Dnil%2Cpassword%3Dnil%2Cdatabase%3Dnil%2C%26block%29-class-method
<FromGitter> <girng> ```code paste, see link``` ⏎ ⏎ how can i implement something to check if there is any connection or not [https://gitter.im/crystal-lang/crystal?at=5aed471c97e5506e049bb703]
<FromGitter> <girng> i see that it has a http://stefanwille.github.io/crystal-redis/doc/Redis/DisconnectedError.html but it's not being raised
<FromGitter> <bararchy> @girng you can TCP connect to the redis port
<FromGitter> <girng> oh
<FromGitter> <girng> good idea
ssvb has quit [Quit: Leaving]
__marty__ has joined #crystal-lang
<FromGitter> <girng> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5aed49e6b982f08504f5af9d]
<FromGitter> <girng> Got it :D
<FromGitter> <girng> `abort "Failed to connect to Redis Server: #{e}"` is better! Redis is mandatory =]
<FromGitter> <girng> i go bed now
<FromGitter> <girng> gn ttyl im tired.. very stressful have wonderful day see u in 5-6,7 hours =]
rohitpaulk has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 260 seconds]
<FromGitter> <Qwerp-Derp> Is it possible to check if a class includes a module?
__marty__ has quit [Read error: Connection timed out]
<FromGitter> <bararchy> @girng just make sure that if connection has been achieved you close the socket
<FromGitter> <Qwerp-Derp> Also why does Crystal use `require` like Ruby? I personally prefer something like Python's import, but there are definitely reasons for doing this
<FromGitter> <Qwerp-Derp> Is it just to make Crystal more similar to Ruby?
<FromGitter> <bararchy> @Qwerp-Derp I guess so, I quite love the `require`
<FromGitter> <Qwerp-Derp> But the way `require` works just feels so... clunky compared to Python's `import Class from foo`, you can fetch select parts of a file from Python's import but you can't do that with `require`
<FromGitter> <Qwerp-Derp> it just straight-up copy-pastes the required file
__marty__ has joined #crystal-lang
<FromGitter> <faustinoaq> @Blacksmoke16 I just got Intellij-crystal working with Scry 🎉 😄
<FromGitter> <bararchy> @faustinoaq geanny ?
<FromGitter> <bararchy> Oh!
<FromGitter> <bararchy> Does it means we can integrate this with Rubymine ?
<FromGitter> <faustinoaq> I fixed a bunch of stuff on Scry protocol but working now 💪 I will send a PR soon ✨
<FromGitter> <Qwerp-Derp> whoa :D
<FromGitter> <faustinoaq> @bararchy Yeah, both Intellij-Crystal and Intellij-LSP plugins are compatible with Rubymine 👏
<FromGitter> <Qwerp-Derp> Is it possible to bundle this together into one big plugin? IDM downloading two but 1 is better
<FromGitter> <bararchy> @faustinoaq great job!
<FromGitter> <bararchy> oprypin, you here by any chance?
<FromGitter> <faustinoaq> Well, I think is possible but my knowledge on Intellij plugin development is very vague, I almost go crazy trying to modify https://github.com/intellij-crystal/intellij-crystal 😅
sz0 has quit [Quit: Connection closed for inactivity]
<FromGitter> <faustinoaq> Using two plugins, is not that bad, lsp-plugin can be useful to add support for others lsp servers, just like sublime text does, (you need 2 packages on sublime as well)
<FromGitter> <faustinoaq> So, On next release of Scry, I think We can get, formatting, go to implementation, method, class, module completion and diagnostics out-the-box 🎉
<FromGitter> <faustinoaq> Symbols listing still doesn't work on Intellij-idea because Scry doesn't support Workspace symbols yet (Intellij-lsp only supports listing symbols per workspace)
<FromGitter> <codenoid> it's from Chuniibyo @xmonader
That_Guy_Anon has joined #crystal-lang
<FromGitter> <Qwerp-Derp> What's the difference between `name` and `to_s` for `Class`?
<FromGitter> <Qwerp-Derp> The only difference is that `to_s` supports `IO`, why is there a need for `name`?
<FromGitter> <bew> no difference in this case. Basically `to_s` is a 'generic' method, that happen to be implemented by calling `name`, but it could be implemented differently
<FromGitter> <Qwerp-Derp> Wouldn't the `name` be redundant in this case then?
<FromGitter> <bew> no, because maybe you want to change how `Class#to_s` is implemented (e.g: show more info when printing), but still be able to have access to its name independantly
<FromGitter> <bew> `Class#to_s` being just a `name` call is an implementation detail
rohitpaulk has joined #crystal-lang
<FromGitter> <bew> `to_s` and `name` methods serve different purpose
<FromGitter> <Qwerp-Derp> So if I want to use this, which one should I use? Is there a preference?
<FromGitter> <bew> well, if you just want to print infos about a class, use `to_s` (implicit when using print and all)
<FromGitter> <bew> and if you need specifically the class's name, use `name`
hightower2 has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 256 seconds]
<FromGitter> <xmonader> @codenoid thanks! will check it out for sure
That_Guy_Anon has quit [Remote host closed the connection]
rohitpaulk has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 264 seconds]
<FromGitter> <hmans> @Qwerp-Derp Use the ancestors macro to get a list of modules (and the parent class) of a class.
<FromGitter> <hmans> I believe I sent you an example yesterday :b
<FromGitter> <bew> @Qwerp-Derp @hmans you can also simply use `.is_a?(SomeModule)`, like: https://carc.in/#/r/4075
That_Guy_Anon has joined #crystal-lang
<FromGitter> <hmans> @bew, that implies having an instance.
<FromGitter> <hmans> (of the class you want to check.)
<FromGitter> <bew> True
Yxhuvud has quit [Remote host closed the connection]
Yxhuvud has joined #crystal-lang
rohitpaulk has joined #crystal-lang
That_Guy_Anon has quit [Remote host closed the connection]
That_Guy_Anon has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 260 seconds]
<FromGitter> <hmans> What are some good strategies to speed up Crystal build (--release) times?
<FromGitter> <hmans> esp. from within a Docker container, where (unless I do a bit of hackery) I don't have any caches available
Yxhuvud has quit [Remote host closed the connection]
Ven`` has joined #crystal-lang
Yxhuvud has joined #crystal-lang
ssvb has joined #crystal-lang
Ven` has joined #crystal-lang
Ven`` has quit [Ping timeout: 240 seconds]
Ven` has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<FromGitter> <oprypin> get a fast cpu
rohitpaulk has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 264 seconds]
<FromGitter> <hmans> :'(
<FromGitter> <hmans> I've done a bit of digging and now understand that this is mostly LLVM going optimizy.
<FromGitter> <oprypin> one thing that may make a tiny difference but everyone should do anyway is: move cache directory from HDD to tmpfs
<FromGitter> <j8r> --thin-lto
<FromGitter> <j8r> and keep the cache (mount in the docker container)
<FromGitter> <hmans> --lto=thin, right?
<FromGitter> <hmans> It crashed my compiler :b
alex`` has joined #crystal-lang
Philpax has joined #crystal-lang
<FromGitter> <faustinoaq> @hmans Yep, `-lto=thin` crash the compiler for me as well, I have a very slow cpu, so I tried it but seems doesn'twork yet 😅
<FromGitter> <faustinoaq> I get something like: ⏎ ⏎ `````` [https://gitter.im/crystal-lang/crystal?at=5aedad826d98e53e04546d7a]
<FromGitter> <faustinoaq> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5aedad8a03cafa797b2bb149]
<FromGitter> <hmans> Yeah, that looks similar to the explosion I was getting.
<FromGitter> <hmans> I'm useless with all things LLVM, so I won't even try to tackle that one.
<FromGitter> <faustinoaq> I guess is a compiler bug, I already opened an issue https://github.com/crystal-lang/crystal/issues/6064
<FromGitter> <faustinoaq> You can leave a comment if you want 😉
<FromGitter> <Sjoerrdd> Crystal is amazing
<FromGitter> <Sjoerrdd> Sometime I forgot that.
<FromGitter> <Sjoerrdd> I'm looking for a programming language, but Crystal is all that I need
<FromGitter> <Sjoerrdd> but it isn't stable (yet) :(
<FromGitter> <sdogruyol> @Sjoerrdd we are working hard to make it stable
moei has quit [Quit: Leaving...]
hightower2 has quit [Ping timeout: 256 seconds]
<FromGitter> <drum445> @Sjoerrdd I haven't really had many stability issues
hightower2 has joined #crystal-lang
<FromGitter> <Blacksmoke16> nice one @faustinoaq
<crystal-gh> [crystal] ysbaddaden closed pull request #6060: Fix: always close signal handler pipe in fork/exec (master...fix-system-blocks-further-signal-handlers) https://git.io/vpVGp
<FromGitter> <Blacksmoke16> --stats should prob be added to `crystal build --help`
<FromGitter> <faustinoaq> ^^ https://packagecontrol.io/packages/Crystal
<FromGitter> <faustinoaq> sublime-crystal v0.0.8 has been published, inclusing latest fixes and features! 🎉
<FromGitter> <faustinoaq> Also, I'm working on fix scry support, there is still some issues with lsp client on sublime 😅
<FromGitter> <faustinoaq> *including
<FromGitter> <jwoertink> Is there anything in crystal that is similar to ruby's Marshal?
<Yxhuvud> no
<FromGitter> <jwoertink> cool. Thanks, I'll check that out
Philpax has quit [Ping timeout: 260 seconds]
<FromGitter> <bew> For those who use the `finished` macro, please comment about it here: https://github.com/crystal-lang/crystal/issues/6028#issuecomment-386820058 or it will be gone!
<FromGitter> <girng> @bararchy good point. ty for reminding
<FromGitter> <faustinoaq> Just got workspace symbols working as well!!! 🎉
<FromGitter> <girng> wow
<FromGitter> <faustinoaq> So, we can get symbol listing on Intellij-Idea as well ✨
<FromGitter> <faustinoaq> and even Sublime Text 😉
<FromGitter> <girng> LOL! look what i searched for (https://i.gyazo.com/d9d4cc868b85a16c5cef5b44e56beb5d.png)
<FromGitter> <petoem> kirby 64 😄
<FromGitter> <jwoertink> searching for crystal stuff is hard. Especially when you're looking for "crystal methods" and get results for "crystal meth OD", or the band "The Crystal Method"
<FromGitter> <girng> @jwoertink lmao
<FromGitter> <petoem> i changed all raise to puts
<FromGitter> <petoem> in my overflow shard
<FromGitter> <petoem> too many, I should limit the check somehow. the stdlib overflows way too much. maybe with a `checked {}` block
<FromGitter> <girng> https://play.crystal-lang.org/#/r/409b/edit ⏎ Okay, so we went over this last week. But I am still a bit confused. Why does update_name not work (because I am not using a `@`). However, I'm not using a `@` when I simply just do `player_name = " CadEy "`. But that still works
<FromGitter> <petoem> does someone know how I can override the operators/methods of a struct/class e.g. `Int32`only inside a block?
jokke has quit [Ping timeout: 240 seconds]
<oprypin> petoem, cant do that. and i have to add "sounds like a bad idea"
<oprypin> girng, it does not, in fact, work
<oprypin> nbm
<oprypin> nvm
<oprypin> girng, here's a copy with all method calls having explicit brackets https://play.crystal-lang.org/#/r/409p
<oprypin> note that `player_name =` is just a local variable, not a method call. so yeah, you set a local variable and forget it
<FromGitter> <bew> @girng or use `self.` in `update_name`: https://play.crystal-lang.org/#/r/409q
<FromGitter> <faustinoaq> @jwoertink just use "crystal lang"
<FromGitter> <faustinoaq> works for me 😉
<FromGitter> <jwoertink> hahah. Yeah, I've got a lot more specific about my crystal google-fu :D
<FromGitter> <girng> sobasically, if updating instance variables insides methods. we need to use self. or `@`
<FromGitter> <bew> yes
<oprypin> as the docs state, of course
<FromGitter> <girng> but if you update a property outside of the method, like `new_player.player_name = "CadEy"`. that still works though
<FromGitter> <girng> and we're not using `@` or `self` there
<oprypin> we're using `new_player` there
<oprypin> that's the same role that `self` plays
<FromGitter> <girng> that synonymous to `self`?
<FromGitter> <girng> of that class
<FromGitter> <girng> `so yeah, you set a local variable and forget it` so this means `player_name` inside the `def update_name` is a local variable?
<FromGitter> <girng> and if it's a local variable, using `@` or `self`, is the way to modify it
<FromGitter> <girng> if i got that right
<oprypin> do you get the concept of the word "local"r?
<FromGitter> <girng> inside a block?
jokke has joined #crystal-lang
<FromGitter> <faustinoaq> Why crystal allows access to instances variables using `instance.@var`? Shouldn't this be avoided?
<FromGitter> <faustinoaq> https://carc.in/#/r/40an Why? 😅
<FromGitter> <faustinoaq> I think a `getter` should be required to do that
<FromGitter> <Blacksmoke16> is there a concept of private/protected variables?
<FromGitter> <Blacksmoke16> as opposed to just methods
<FromGitter> <Blacksmoke16> afaik if you dont have a getter/sett and just do like `@num = 0` that it would be private?
<FromGitter> <Blacksmoke16> er apparently not
<FromGitter> <j8r> this is an instance variable
<FromGitter> <j8r> only scoped for the instance
<FromGitter> <j8r> @faustinoaq agree, I don't know if there is an issue about...
<faustinoaq> I didn't see an issue about that yet, let me open one ;-)
<FromGitter> <girng> https://play.crystal-lang.org/#/r/40b1/edit if you look here, player_name gets modified
<FromGitter> <Blacksmoke16> https://play.crystal-lang.org/#/r/40b6
<FromGitter> <Blacksmoke16> you need the `@` symbol to have it update the instance var, else you are setting the new name to a local var that doesnt do anything
<FromGitter> <bew> @girng https://play.crystal-lang.org/#/r/40ba
<FromGitter> <girng> yes i understand the `@`. but on line 5, it's already reading the instance variable's value, how does it get transformed into a local variable
<oprypin> reading the local variable's value
<oprypin> uh sorry, right, at line 5, there it's calling the method
<oprypin> that's undesirable behavior, python doesnt do that
<oprypin> girng, again, take a step back, and see what's really happening https://play.crystal-lang.org/#/r/40bb
<FromGitter> <bew> @girng checkout my last msg
<FromGitter> <girng> @bew yeah, it seemslike `@` is the way to make the instance variable change. but in my example i posted above, i didn't use `@` and i still changed the variable's value tho. so if you don't use the `@` it becomes just a local variable?
<FromGitter> <girng> like any other local variable?
<oprypin> there is no ambiguity. `var_name = value` creates a local variable
<FromGitter> <girng> but var_name is the instance property
<oprypin> meanwhile, writing just `var_name` might be a method call
<FromGitter> <girng> name
<oprypin> there is no such thing as property, ok? look at my example
<FromGitter> <bew> Yes, like any other local variable, there is no special syntax or anything
<FromGitter> <bew> In your example you didn't use @, so you changed the local var, not the ivar
<oprypin> that's a shallow way to look at it
<FromGitter> <girng> so changing the local var has no effect on the instance variable. no connection,correct?
<FromGitter> <girng> even if it's the same name as property
<oprypin> correct, but as i said, there is no such thing as property
<oprypin> `property` is just a macro that defines a bunch of stuff
<FromGitter> <girng> right, just the macro
<FromGitter> <girng> yeah
<oprypin> i expanded that satuff for you in the example
<oprypin> while `player_name` can be automatically expanded to `self.player_name()`,
<oprypin> `player_name = new_name` will never be expanded to `self.player_name=(new_name)`
<oprypin> it's just a basic syntax rule of the language, writing `=` creates a local variable, if you're not being specific about the object that you're using it on
<oprypin> specific as in `some_object.new_name` or `self.new_name`
moei has joined #crystal-lang
<FromGitter> <girng> wtf then
<FromGitter> <girng> why doesn't your example show CadEy at the last night
<FromGitter> <girng> line, since you used `@player_name = value`?
<FromGitter> <girng> ``` def player_name=(value : String) ⏎ @player_name = value ⏎ end``` [https://gitter.im/crystal-lang/crystal?at=5aedfb3659a0578004a9387e]
<oprypin> girng, that line is never used
<FromGitter> <bew> Because that method is not called anywhere
<oprypin> `player_name=` method is never called
baweaver is now known as baweaver_away
baweaver_away is now known as baweaver
<FromGitter> <girng> my bad, was thinking `player_name =` was alias for that
<oprypin> (see my previous messages)
<FromGitter> <girng> ok well looks like the concepts of "property" is what confused me. because i kept thinking if you are using the `player_name` inside a method, it's already implied you're using `self` when using = on it. but in fact, you are not, you are creating a local variable.
<FromGitter> <girng> i was thinking it's already implied, because when you do puts player_name in that method, it shows the vlaue you originally gave it in the property macro
<FromGitter> <girng> that's where my confusion stemmed from =]
<FromGitter> <girng> but that's just reading the value (accessing it), nothing more
__marty__ has quit [Remote host closed the connection]
<FromGitter> <Blacksmoke16> 👍
<FromGitter> <j8r> property is a macro, the best is to see (like I have previously said) how it expands
<FromGitter> <j8r> getter, setter, class_getter are *just* macros, no underlying dark concepts behing ;-)
<crystal-gh> [crystal] ysbaddaden opened pull request #6068: Fix: nonblocking standard file descriptors using timers (master...fix/nonblocking-standard-file-descriptors-with-timers) https://git.io/vpwpr
<FromGitter> <j8r> just shortcuts if you prefer
DTZUZO has quit [Read error: Connection reset by peer]
<crystal-gh> [crystal] RX14 pushed 1 new commit to master: https://git.io/vpwjP
<crystal-gh> crystal/master 6c3fc2b Chris Hobbs: Revert "Fixed OpenSSL bindings to recognize LibreSSL (#5676)" (#6062)...
That_Guy_Anon has quit [Quit: Leaving]
<travis-ci> crystal-lang/crystal#6c3fc2b (master - Revert "Fixed OpenSSL bindings to recognize LibreSSL (#5676)" (#6062)): The build passed. https://travis-ci.org/crystal-lang/crystal/builds/375373293
<DeBot> https://github.com/crystal-lang/crystal/pull/5676 (Fixed OpenSSL bindings to recognize LibreSSL) | https://github.com/crystal-lang/crystal/pull/6062 (Revert "Fixed OpenSSL bindings to recognize LibreSSL (#5676)")
sz0 has joined #crystal-lang
<FromGitter> <girng> https://github.com/mherrmann/fbs this looks relly cool
<FromGitter> <faustinoaq> I just added stdlib symbols listing to scry 🎉
<FromGitter> <faustinoaq> Thank you @bmulvihill for the initial symbol implementation on Scry 😄 👏
<FromGitter> <faustinoaq> Thank you @bew for suggesting the idea 😉
<FromGitter> <faustinoaq> I just discovered a lot of symbols I did know 😅
<FromGitter> <faustinoaq> 1) didn't