ChanServ changed the topic of #crystal-lang to: The Crystal programming language | http://crystal-lang.org | Crystal 0.31.1 | Fund Crystal's development: http://is.gd/X7PRtI | GH: https://github.com/crystal-lang/crystal | Docs: http://crystal-lang.org/docs/ | API: http://crystal-lang.org/api/ | Gitter: https://gitter.im/crystal-lang/crystal
<FromGitter> <watzon> I really wish HTTP::Client had the ability to follow redirects
<FromGitter> <watzon> We need #2721
<DeBot> https://github.com/crystal-lang/crystal/issues/2721 (HTTP::Client: follow redirects)
<FromGitter> <Daniel-Worrall> Prepared statements
<FromGitter> <Daniel-Worrall> I believe https://crystal-lang.org/docs/ needs a link to the mysql-db shard
sz0 has joined #crystal-lang
f1reflyylmao has joined #crystal-lang
f1refly has quit [Ping timeout: 276 seconds]
chachasmooth_ has quit [Ping timeout: 240 seconds]
chachasmooth has joined #crystal-lang
_whitelogger has joined #crystal-lang
Raimondi has joined #crystal-lang
_whitelogger has joined #crystal-lang
_whitelogger has joined #crystal-lang
_whitelogger has joined #crystal-lang
alexherbo2 has joined #crystal-lang
top_roupi has joined #crystal-lang
ua_ has quit [Ping timeout: 268 seconds]
ua_ has joined #crystal-lang
HumanG33k has joined #crystal-lang
<hightower3> Do I need to somehow check that the unix socket I connected to is ready for write? I just connect with UNIXSocket.new(path), and if I write immediately, sometimes I get broken pipe, and sometimes it works...
<hightower3> actually seems unrelated to write.. it just sometimes gets that error..
yashko has joined #crystal-lang
<yashko> Hello guys! I'm new to crystal. In my program i need to have variable which i can access/modify anywhere. What is the best approach to do so in Crystal?
<yashko> Hello guys! I'm new to crystal. In my program i want to have variable which i can access/modify anywhere. What is the best approach to do so in Crystal?
<FromGitter> <Daniel-Worrall> Constant
<FromGitter> <Daniel-Worrall> or shift your paradigm because global variables are almost always a terrible idea
<yashko> Trying latter option. How can I? Lets say i need to store users list (in-memory), and access users list in few classes. Only way i see atm - pass to the other classes `initialize()` reference to this variable, and keep it inside some `Main` class where all stuff starts . Idk if it will works
<FromGitter> <j8r> yashko you can use a class/struct/module
<FromGitter> <j8r> with a `class_property`
<FromGitter> <j8r> that's common for `Logger`
<FromGitter> <j8r> but use this only if the object is supposed to be accessible to the whole program, not just some places
<FromGitter> <j8r> because it will be harder to test
rohitpaulk has joined #crystal-lang
<yashko> thank you guys will try
yashko has quit [Ping timeout: 260 seconds]
rohitpaulk has quit [Ping timeout: 245 seconds]
rohitpaulk has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 250 seconds]
rohitpaulk has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 276 seconds]
rohitpaulk has joined #crystal-lang
<FromGitter> <christopherzimmerman> ```code paste, see link``` ⏎ ⏎ Is there a way that I can direct inherited classes to return instances of themselves, rather than the base class from an inherited method? [https://gitter.im/crystal-lang/crystal?at=5dc83bd84adf071a8405c2ae]
<FromGitter> <tenebrousedge> use `self.new` ?
<FromGitter> <Blacksmoke16> `self.class.new`
rohitpaulk has quit [Remote host closed the connection]
<FromGitter> <christopherzimmerman> Thanks, `self.class` is what I needed. Is there a way to specify a generic type? It seems like `self.class(U)` doesn't work
<FromGitter> <Daniel-Worrall> If it's in a quick and dirty app, I just have the Logger on the top level instead of class instance. Probably bad practice, but quicky&dirty apps
<FromGitter> <Blacksmoke16> not via that syntax
<FromGitter> <Blacksmoke16> other convo: a better way might be some sort of DI to inject instances of your user list/logger into the classes that need them
<FromGitter> <Blacksmoke16> but yea, depends on how serious the app is ha
Nekka has quit [Quit: zzz]
Nekka has joined #crystal-lang
dannyAAM has quit [Quit: znc.saru.moe : ZNC 1.6.2 - http://znc.in]
dannyAAM has joined #crystal-lang
Human_G33k has joined #crystal-lang
HumanG33k has quit [Ping timeout: 240 seconds]
<hightower3> Hey Blacksmoke16 , could you please check this paste and advise if my solution is OK -- https://play.crystal-lang.org/#/r/7zqd ? (The code in the example doesn't compile, but I think the code and comments give enough context)
<FromGitter> <Blacksmoke16> probably?
<hightower3> yeah, I am pretty sure it will work, but I am unclear as to why it didn't recognize that Proc(Event+,Bool) was accepted, but only Proc(Event,Bool)
<hightower3> I.e. I'll go with this, but if there's any way to avoid unsafe_as, that'd be wonderful
<hightower3> Ah yes sorry, the main point of the pasted code was missing -- I had to use #unsafe_as, instead of #as that is shown in the paste
<hightower3> And that's what I would like to avoid if possible
<FromGitter> <Blacksmoke16> ahh
<FromGitter> <Blacksmoke16> could do that trick that @asterite had, like wrap the proc in another proc that fulfills the type requirement
<hightower3> Aaah yes, I know what you mean
<hightower3> I was looking at that but couldn't figure out whether this would still be applicable trick now that the whole thing is wrapped inside that Handler( ) on the outside
<hightower3> Will try
gangstacat has quit [Ping timeout: 264 seconds]
gangstacat has joined #crystal-lang
<hightower3> mm, so previously type trick was: ->(ev : Event) { handler.call(ev.as({{e.id}})) } . This gave out types like Proc(MyEvent,Bool) which was working. How I'm not sure how to modify that to change type to be Handler(Proc(MyEvent,Bool))
<hightower3> My attempts all generate a syntax error of one form or another
<FromGitter> <Blacksmoke16> wouldnt you just do like `Handler(Proc(MyEvent, Bool)).new the_wrapped_proc, ...`
<hightower3> mm potentially but the proc is already wrapped in Handler class. So now I would be trying to wrapp Handler inside Handler
<hightower3> so the issue is I want to pass the wrapped proc instead of the proc itself
<FromGitter> <Blacksmoke16> can you make an example link?
<hightower3> Hehe yeah I tried before asking the question, but I couldn't reproduce it.. let me try again
<hightower3> I tried to reproduce it in https://play.crystal-lang.org/#/r/7zgl
<hightower3> but that one works strangely... I don't understand what's different in actual code vs. that example
<hightower3> ah making mistakes today.. the good link is:
<hightower3> ah I know why it doesn't work! Will update this example
<FromGitter> <Blacksmoke16> πŸ‘
<hightower3> I think this is the root of the issue: https://play.crystal-lang.org/#/r/7zqn
<hightower3> That the "Handler" class is not a subclass of the other one
<hightower3> oh no, well, close to it
<hightower3> the issue seems to be that we have a class and a subclass. and when we wrap them in a generic class Handler(T), the compiler no longer treats them as class and subclass, right?
<hightower3> Handler(Subclass) is not subclass of Handler(Class)
<FromGitter> <Blacksmoke16> i think so?
<hightower3> so that's the issue I couldn't solve without doing Handler(Subclass).unsafe_as(Handler(Class))
<FromGitter> <Blacksmoke16> is it expected that `1/0` returns infinity?
<FromGitter> <watzon> I would've thought it would raise an exception
<FromGitter> <Blacksmoke16> `1//0` does, so might be something with the change to floor div
<FromGitter> <Blacksmoke16> er float division by default
<hightower3> However, Blacksmoke16, when I check what the effect of the proc trick is, compared to this unsafe_as, they're identical (the type gets reported as Proc(Event,Bool). So, I believe unsafe_as produces the identical result that we had before, just wrapped inside Handler(T), and the only not-niceness is the use of #unsafe_as. Unless there are ideas to that, I'll go with unsafe_as.
<hightower3> And as always, thanks for the discussion/help, much appreciated
<FromGitter> <Blacksmoke16> np, gl
alexherbo2 has quit [Quit: The Lounge - https://thelounge.chat]
<FromGitter> <Daniel-Worrall> @veelenga ⏎ Is this code snippet supposed to flag the shadowing outer variable test on ameba? It's still accessible through `@foo` ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5dc881caca778c1fbfdd0854]
_whitelogger has joined #crystal-lang
<FromGitter> <Daniel-Worrall> Is there a community favourite ORM?
<FromGitter> <christopherzimmerman> @Blacksmoke16 I think that behavior is expected. There isn’t really an integer concept of infinity or NaN. Most languages handle that similarly.
<FromGitter> <christopherzimmerman> I would assume crystal follows the floating point standard.
<FromGitter> <christopherzimmerman> I swear Fortran ordering of arrays was the worst idea in the history of compute science.
yukai has joined #crystal-lang
ht_ has quit [Remote host closed the connection]
mistergibson has quit [Quit: Leaving]
<FromGitter> <Blacksmoke16> @Daniel-Worrall i like Granite, but depends on what features you want/need
<FromGitter> <Daniel-Worrall> I've been setting up jennifer.cr but it's a bit of an ache lol