<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 😄
<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> 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 ;-)
<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>
<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>
<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>
<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>
<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>
<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>
<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?
<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> `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
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>
<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>
<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"
<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>
<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
<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>
<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]