<RX14>
since you can just assign different types in both branches of an if
<RX14>
and unions just happen
<jxv>
thank you, RX14
<RX14>
jxv, i hope that answers your questions
<RX14>
although trying them out is probably a lot more informative
<jxv>
yes :)
rohitpaulk has joined #crystal-lang
martinium has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
rohitpaulk has quit [Ping timeout: 265 seconds]
davic has quit [Ping timeout: 252 seconds]
davic has joined #crystal-lang
<crystal-gh>
[crystal] RX14 closed pull request #5525: Define `new(JSON::PullParser)` on BigDecimal so it can be deserialized (master...json-parse-bigdecimal) https://git.io/vNe7X
<FromGitter>
<elorest> What would be the best way to detect when an TCPSocket is broken. i.e the server is closed or the network connection is broken?
<FromGitter>
<elorest> I'm currently just catching the error on `#write` reconnecting and resending the message. Doesn't seem like the best way to do it though.
<FromGitter>
<bajro17> I hope I will not be boring with this project
<FromGitter>
<bajro17> I get error on start and I dont know what I need to fix it
<Groogy>
and just like you do with other similar cases, if you test the variable you dequalify its type from being Nil, or False
<Groogy>
and the type is removed within that scope
<FromGitter>
<LuckyChicken91_twitter> at me its always UInt64 | Nil
<FromGitter>
<LuckyChicken91_twitter> so i dont think i need the if query
<Groogy>
eh... you still need to if you want to use the variable as an UInt64
<Groogy>
any operation the Nil type doesn't support it will result in a compilation error
<FromGitter>
<LuckyChicken91_twitter> but i dont understand whats calculate_number means
<Groogy>
that was just his example of how he "got" the variable
<FromGitter>
<LuckyChicken91_twitter> i just have one method that returns this uint64?
<Groogy>
ignore it
<FromGitter>
<bararchy> This will create an initialized got repo with your basic files (specs src readme etc..)
<FromGitter>
<bararchy> This structure is what is expected by shards , so people can use your work
<FromGitter>
<marksiemers> @LuckyChicken91_twitter - can you put a code sample in https://carc.in/
<FromGitter>
<bararchy> Its also became the standard in the communit
<FromGitter>
<marksiemers> then paste the link here?
<FromGitter>
<LuckyChicken91_twitter> here: ⏎ im getting the uint64? with this code: ⏎ `guild_id = cache.resolve_channel(payload.channel_id).guild_id` ⏎ and in the docs it says: ⏎ `#guild_id : UInt64?` [https://gitter.im/crystal-lang/crystal?at=5a547668ba39a53f1af2e2a3]
<FromGitter>
<marksiemers> What will you do with the `guild_id`?
<Groogy>
yes so that variable now is both an UInt64 and a Nil
<FromGitter>
<LuckyChicken91_twitter> it works thanks
<FromGitter>
<marksiemers> np ⏎ get used to that pattern (or any conditional check) to take care of nilable types (e.g. `(String | Nil)`, `(Int | Nil)`, etc.)
flaviodesousa has joined #crystal-lang
andrewzah has joined #crystal-lang
<FromGitter>
<bajro17> Its its Ruby repo copied and changed extensions I just work on it for now I want fix syntax than I will focus to make actual shard
claudiuinberlin has joined #crystal-lang
mark_66 has joined #crystal-lang
hello has quit [Quit: Page closed]
emgonam2 has joined #crystal-lang
<emgonam2>
i got kemel compile errno
<emgonam2>
my crystal version 0.25.2
<emgonam2>
failed to convert json to bson stringify {} of Float => Float
alex`` has quit [Ping timeout: 265 seconds]
dhk has joined #crystal-lang
<FromGitter>
<bajro17> what you try compile?
joe_-_ has joined #crystal-lang
joe_-_ has quit [Remote host closed the connection]
dhk has quit [Quit: Leaving]
dhk has joined #crystal-lang
rohitpaulk has joined #crystal-lang
cbass has joined #crystal-lang
dhk has quit [Quit: Leaving]
<FromGitter>
<bew> @bajro17 I don't think it's a good idea to take an existing Ruby gem and manually convert the code to Crystal: they are different languages, and things doesn't always translate or things are not done the same way in Cr than on Rb. I would suggest you to forget this conversion repo, and create a brand new crystal project, and starting to document yourself about the official paypal's HTTP API, and make a Crystal
<FromGitter>
... shard based on this documentation. Of course you can take inspiration from the Ruby gem on the files, object hierarchy, and the final dev API exposed by the gem. But don't take good Ruby code, change the syntax and expect it to be good Crystal code.
rohitpaulk has quit [Ping timeout: 248 seconds]
<FromGitter>
<bararchy> ^ @bew totally agree
rohitpaulk has joined #crystal-lang
<FromGitter>
<bararchy> When I started playing with Crystal 2013? I automatically looked at Ruby and tried to "make it crystal" , now I know better and would usually just think about the task and do it purely Crystal from the start, doing a conversion would make you think Ruby instead of Crystal and would make you ignore misuse the wonderful things Crystal has to offer
<FromGitter>
<bararchy> More then that, Crystal has made me a better Ruby dev :)
<FromGitter>
<bajro17> :'( my dreams are ruined
<FromGitter>
<bew> Hmm not your dreams I hope, but the way to accomplish one of them will need to change I think ;)
<FromGitter>
<bajro17> I just joke I dont give up I will now check more how to do it in proper way
<FromGitter>
<bew> We're here to help if needed (not 24/7 though ˆˆ)
<FromGitter>
<bajro17> is there anything like on golang site tour for crystal
<FromGitter>
<bajro17> it is so hard to find any guide or tutorial
<FromGitter>
<bajro17> specialy video almost impossible
<FromGitter>
<bew> Currently not, this is a current issue we're discussing. Yeah I agree it's quite difficult to start. I suggest to look at existing source code, learn by reading and understanding then doing. I suggest you to look at the code of another shard wrapping an http api, see how it handle it
<FromGitter>
<bew> @bararchy do you know a good one?
<FromGitter>
<bew> ua did you tried crystal play or icr? Your description seems to fit pretty well for these 2 tool (well it will recompile but you almost don't see it)
<ua>
just crystal play
<ua>
i havent seen icr, cool thanks
<ua>
hmm i think ive used icr
<ua>
long time ago but then went back to pry
<FromGitter>
<bew> I like how they've added syntax highlighting in ocr lately
<FromGitter>
<bew> icr*
<ua>
thing is in icr i cant just load data into memory once and then monkeypatch and run code around it
<ua>
basically no eval no real REPL
<FromGitter>
<bararchy> ua working on Ruby and then saying "ill just change it to Crystal when it works" sounds like a lost of wasted work for me, but, if it works for you enjoy :)
<FromGitter>
<bararchy> @bew would love your input on above issue
<ua>
nah, not really, it just breaks very rarely in some places
<ua>
stuff like having to use BigInt manually, did that yesterday
<ua>
got orders of magnitude speed improvement, very happy about it
<ua>
lol
<ua>
ah my use case i guess is unusual, processing lots of data, so time difference in execution between ruby and crystal is really worth it to do slight code modifications
<ua>
but then im really lazy
<FromGitter>
<bew> @bararchy I'm not sure I could add anything, I'm still student, never did a GSoC myself and never mentored anyone ˆˆ
hightower has joined #crystal-lang
hightower3 has quit [Ping timeout: 248 seconds]
<FromGitter>
<bew> @bararchy I don't know `cryatal-db` ˆˆ (typo in your gsoc issue)
<FromGitter>
<bararchy> XD
<FromGitter>
<bararchy> will fix
<FromGitter>
<bararchy> Fixed also added links so it will be clearer for those not knowing about the projects
<RX14>
why is that issue on crystak-lang/crystal?
<FromGitter>
<bajro17> is there any method in array to compare 2 values
<FromGitter>
<bew> Good idea, could you add links to gsoc event, what's needed etc?
<RX14>
it doesn't even mention asking anyone to work on the compiler
<FromGitter>
<bew> That would be good idea though
<RX14>
@bajro17 what do you mean?
<RX14>
to compare two values you use == but I don't see how that relates to array
<FromGitter>
<bajro17> I little practive
<FromGitter>
<bajro17> practice
<RX14>
@bew @bararchy it's my understanding that if you submit "crystal" as a project to gsoc you should be working on... crystal
<FromGitter>
<bajro17> and I have for example in array 1,2,3,3,4,5,6,6,6
<RX14>
not shards
<FromGitter>
<bew> Good point RX14
<FromGitter>
<bararchy> > **<RX14>** why is that issue on crystak-lang/crystal? ⏎ Wait, what ?
<FromGitter>
<bajro17> I want to replace same numbers is there any method to remove same
<RX14>
@bararchy gsoc
<FromGitter>
<bajro17> or need use [n] == [n+1]
<RX14>
in my opinion there isn't any shards in crystal which could keep someone busy all summer working full-time
<RX14>
which is what gsoc is
<RX14>
it's like 3 months meant to be 40 hours a week
<RX14>
iirc
<RX14>
is there *that much* that needs to be done on kemal? i hope not
<RX14>
on amber or another large framework? maybe
<RX14>
on crystal? definitely
<FromGitter>
<bararchy> RX14, It was suggested that maybe the compiler it a little to hard for a student to come and work on, if you think this isn't true (And i value your opinion as a compiler developer) please let me know
<RX14>
crystal is not the compiler
<FromGitter>
<bew> @bajro17 what are you trying to do? Remove duplicates? Why not use a Set (no duplicate by design)?
<RX14>
i've been busy for 2 years and havent even touched the compiler properly @bajro17
<RX14>
oops
<RX14>
@bararchy
<FromGitter>
<bajro17> thanks @bew :)
<FromGitter>
<bararchy> I see, do you think it makes sense for a Crystal first timer to just hop on the Compiler and produce actual relevant code?
<FromGitter>
<bararchy> RX14, would you be fine in mentoring?
<RX14>
well my opinion is mentoring is a risk
<FromGitter>
<bararchy> how come?
<RX14>
at the end of the day gsoc isn't about the amount of work done
<RX14>
it's about helping students
<RX14>
if you get an adept student then you can get more work out of the time taken to mentor the students
<RX14>
but it's probably not uncommon that you'd get more work just doing the work yourself
<RX14>
i'd rater not think of gsoc as "free work done by a volunteer"
DTZUZU has quit [Ping timeout: 248 seconds]
<FromGitter>
<bararchy> ofc not, it's a great opurtunity to ⏎ 1) Put Crystal out there ⏎ 2) teach the next gen of Crystal devs
<RX14>
well if you do treat it as such then you have to think that someone somewhere is giving up a significant amount of time they would be spending on crystal to mentor a student
<RX14>
I have no idea if i'm going to be able to have time to even work on crystal myself over the summber as I have no job lined up
<Papierkorb>
bararchy, you usually don't teach someone totally new. Google itself even tells GSOC students to hang out in the community first to get to know it
<RX14>
the people at manas I wouldn't be surprised if they said "no we want to work on crystal ourselves"
<RX14>
and I'm not sure the mentor would want to be anyone outsde the core team
<FromGitter>
<sdogruyol> @RX14 that's the main reason why we initially not mentioned compiler / std in the issue itself
<RX14>
then my original point stands:
<RX14>
why is this issue open on the compiler/std repo
<FromGitter>
<sdogruyol> that's where everyone looks at?
<FromGitter>
<bararchy> you knwo why, because this is the main repo for anything Crystal, and it's something that is still considered (the work on std)
<RX14>
ok, then we need to set up some forums
<RX14>
because using github issues as a messageboard isn't ideal
<FromGitter>
<bararchy> I know it "technically" should have been in the google groups, but we know it dosen't have the same broadcast the git have
<FromGitter>
<bararchy> True^
<FromGitter>
<sdogruyol> Yeah, that's another discussion to make
<crystal-gh>
[crystal] RX14 closed pull request #5561: Fix spec name for parsing BigDecimal from floats (master...patch-2) https://git.io/vNtQ5
DTZUZO has joined #crystal-lang
<FromGitter>
<bararchy> having some inputs from @asterite and @mgarciaisaia
<FromGitter>
<bararchy> would be great
<FromGitter>
<Svenskunganka> RX14 about not being able to work on Crystal, to me that's quite bad news, as I believe you are a key person at this stage to bring Crystal to 1.0 and further, but I've voiced my opinion of you over on Reddit so you know how I feel. Which leads to me question, how does manas spend the bountysource money? I haven't found much transparenty in that area.
DTZUZU has joined #crystal-lang
<FromGitter>
<Svenskunganka> transparency*
<RX14>
they spend it to fund the time of the manas people working on crystal
<FromGitter>
<yxhuvud> OpenSSL? It is a marvel of good error messages.
<FromGitter>
<bararchy> yeha OpenSSL
rohitpaulk has quit [Ping timeout: 248 seconds]
emgonam2 has joined #crystal-lang
<FromGitter>
<imonmyown> SNAFU
rohitpaulk has joined #crystal-lang
DTZUZO has quit [Ping timeout: 264 seconds]
DTZUZO has joined #crystal-lang
<FromGitter>
<bararchy> Well, cool, we have 3 mentors and 1 student
<FromGitter>
<bew> 1 student?
<FromGitter>
<bararchy> @MakeNowJust
<FromGitter>
<bararchy> he want's to join as Student under the GSOC and to be mentored by Ary
<FromGitter>
<bew> Ah yes ok :p
<FromGitter>
<bararchy> @straight-shoota what about you? Mentor?
<FromGitter>
<bararchy> Maybe @marksiemers
emgonam2 has quit [Ping timeout: 260 seconds]
DTZUZO has quit [Ping timeout: 256 seconds]
DTZUZO has joined #crystal-lang
return0e has quit [Ping timeout: 256 seconds]
LastWhisper____ has joined #crystal-lang
alex`` has joined #crystal-lang
return0e has joined #crystal-lang
<RX14>
hmm
<RX14>
that makes me think
<RX14>
i'm a student, can I be a gsoc student for crystal?
<RX14>
is that breaking the system?
<FromGitter>
<asterite> no, approved
<FromGitter>
<asterite> :-P
<FromGitter>
<bararchy> RX14 no issue :) you can TBH
<FromGitter>
<bararchy> but you need a mentor
<FromGitter>
<bararchy> and that is a good idea BTW, you will be paid to work on Crystal
<FromGitter>
<bararchy> at least for the time of the project
<FromGitter>
<bararchy> you just need ⏎ Mentor + Student card (certificate that shows you are corrently in a university or other similar instetuation)
rohitpaulk has quit [Ping timeout: 240 seconds]
<RX14>
well unless someone else approaches me with a job i'll probably do that then...
<FromGitter>
<sdogruyol> you mean a full time job?
<RX14>
yeah
<RX14>
if someone wants to pay me mroe to work on what *they* want to add to crystal then sure lol
mark_66 has quit [Remote host closed the connection]
<FromGitter>
<bararchy> RX14 be careful what you wish for ;)
<FromGitter>
<sdogruyol> haha
<FromGitter>
<bararchy> anyway, this is another drive to get in GSOC, also I know Papairkorb is a student too
<FromGitter>
<bararchy> he can also enjoy this
<RX14>
looks like I can work on gsoc if i've been working on crystal before
<FromGitter>
<bararchy> can or can't?
<RX14>
can
<RX14>
its in the FAQ
<FromGitter>
<bararchy> awsome!
<FromGitter>
<bararchy> so totally cool
<RX14>
doesn't mean i'll get accepted though
<RX14>
lol
<FromGitter>
<bararchy> If Crystal will get accepted, you most likely will get accepted has you have former knowledge that can help your choise of project succed
<FromGitter>
<bararchy> ie. you know Crystal and are part of core dev team XD
<RX14>
ehh i'm not so sure about that
emgonam2 has joined #crystal-lang
alex`` has quit [Ping timeout: 246 seconds]
<FromGitter>
<bararchy> well, the Org admin decides who is getting in, so, lets say I send the application and become the project org admin, I'll let you in ;)
<FromGitter>
<bararchy> hahahha
<RX14>
well
<RX14>
google supplies the money
<RX14>
so they definitely have some say in it
<FromGitter>
<bararchy> Yeha, but once they accept an organization, the organization decides who is ok
<RX14>
...huh
<RX14>
that sounds gameable
<FromGitter>
<bararchy> it's in the organization admin
<FromGitter>
<bararchy> guide
<RX14>
well
<FromGitter>
<bararchy> yes and no, if we fuck it up we wont be joining next year
<FromGitter>
<bararchy> etc..
<FromGitter>
<straight-shoota> too bad I'm not a student anymore...
<FromGitter>
<bararchy> But you can Mentor
<RX14>
i presume someone at manas should be the org admin
<RX14>
the org admin != mentor right?
<FromGitter>
<bararchy> No no
<FromGitter>
<bararchy> Org admin just send application etc..
<RX14>
yeah
<FromGitter>
<straight-shoota> hehe, I can mentor RX14 :P
<FromGitter>
<bararchy> @straight-shoota That could be cool
<FromGitter>
<bararchy> as we need pairs
<FromGitter>
<straight-shoota> But I don't know if he could learn anything from me...
<FromGitter>
<bararchy> well, in hes case, you can try and mentor, and he can do his best to just "do what's needed"
<FromGitter>
<bararchy> also, Ary can help , etc...
<FromGitter>
<bararchy> I'm writing you down as Mentor
<FromGitter>
<bararchy> so it is up to organizations to choose and accept students
<FromGitter>
<marksiemers> @bararchy - I would want to read more details about it, but I may be willing to Mentor, though I'm not sure I can provide that much help if RX14 and Papierkorb are the students. If it hasn't become obvious already, I lean more toward product management than I do writing std-lib and compilers.
<FromGitter>
<bararchy> @marksiemers they hopefully wont be the only students, and the projects range from Compiler to rewrite docs.. etc..
<FromGitter>
<bararchy> read about it and tell me what you think
<RX14>
if I had the choice i'd rather get paid to work on cryatal independently and then mentor new people to the community
<FromGitter>
<marksiemers> What about `crystal-db` and `crystal-pg` - could those be worked on as well?
<FromGitter>
<straight-shoota> sure why not?
<FromGitter>
<marksiemers> Well, opportunity cost of working on std-lib or the compiler
<FromGitter>
<bararchy> @marksiemers `crystal-db` is already in the issue
<FromGitter>
<marksiemers> Oh, great. yeah, I'm reading through the issue now.
cremes has quit [Quit: cremes]
cremes has joined #crystal-lang
vikaton has quit [Quit: Connection closed for inactivity]
emgonam2 has quit [Ping timeout: 240 seconds]
DTZUZO has quit [Ping timeout: 248 seconds]
DTZUZO has joined #crystal-lang
<FromGitter>
<bew> Maybe I could apply to gsoc too ;) I almost applied last year, but I wasn't really available durong summer, this year will be different, and it could be some Crystal, this is heaven!
emgonam2 has joined #crystal-lang
LastWhisper____ has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
<FromGitter>
<bararchy> look at Org Admin at the left side
<FromGitter>
<bararchy> it's all the relevant FAQ for Orgs
<oprypin>
yeah thx
<FromGitter>
<bararchy> 👍
<oprypin>
it's not all though, there is a particular field in the organization creation page that i was wondering about
<FromGitter>
<bararchy> which is it?
<oprypin>
there's a field to specify other organizations or google employees that can vouch for the organization
<oprypin>
(i'm not 100% sure on this though)
<FromGitter>
<bararchy> well, I guess it's not really big deal for something as robust and known as Crystal, maybe if it was a 3 man project with 30 stars or something
<oprypin>
anything helps
<FromGitter>
<bararchy> Do we know people from Google? :)
<oprypin>
i actually got excited about this, disregard what i said previously
<FromGitter>
<bararchy> XD
<FromGitter>
<bararchy> cool !
<FromGitter>
<sdogruyol> I remember @bcardiff presenting Crystal at Google last year, maybe he has some contacts there?
<FromGitter>
<sdogruyol> when did you join? I'm pretty sure haven't seen that before oprypin
<FromGitter>
<bararchy> oprypin, you should give us credit !
<FromGitter>
<bararchy> :)
<RX14>
oprypin can help destroy go from the inside lol
<FromGitter>
<bararchy> "Crystal is awsome, those guys can do anything"
<FromGitter>
<bararchy> hahahaha
<FromGitter>
<sdogruyol> roflmao
<FromGitter>
<bararchy> maybe he is a Go spy ??
<FromGitter>
<sdogruyol> double agent :O
<oprypin>
no i think it's literally just a field to specify a name during the creation of the organization, just don't forget about it
LastWhisper____ has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
<FromGitter>
<bew> Lool x) love reading you guys
alex`` has joined #crystal-lang
<oprypin>
that's all i wanted say in a public/logged chat
<FromGitter>
<bararchy> XD noooo
<FromGitter>
<bararchy> anyway, awsome!
<FromGitter>
<bararchy> would you care to mentor though ?
<FromGitter>
<bararchy> oprypin I also know people from DeepMind in Israel, so we can use them too
DTZUZO has quit [Ping timeout: 240 seconds]
<FromGitter>
<bcardiff> :-) this is fun. @oprypin next thing is that you've wen't to Herräng during July and there will be too much coincidence. ⏎ ⏎ When I presented at google, my contact was a former co-worker of Manas that started to worked in google nyc.
<oprypin>
i didnt go to Herräng, what about it?
<FromGitter>
<bararchy> @bcardiff would you care to Mentor for GSOC ?
<FromGitter>
<sdogruyol> too many googlers alert :P
DTZUZO has joined #crystal-lang
emgonam2 has joined #crystal-lang
<FromGitter>
<bcardiff> @bararchy I would happy to answere and offer guidance in the context of GSOC. I have some weeks where I will be mostly offline somewhere between May-Jul (not all of them!) But if there can be a channel where all teh GSOC communication can be tunneled so I give more priority that could work. I've never participate before so I am unsure about the expected work load.
<FromGitter>
<bararchy> @bcardiff Cool, I'll add you up
<FromGitter>
<bcardiff> @oprypin Herräng, a swing dance festival :-) lots of people (~1K) all around the globe go there during July. In the swing community people know about stockholm & herräng and nothing else about sweden :-P. They play a huge role in the modern history of the dance.
<oprypin>
yeah with the first search result being about dancing, i figured. nah I don't dance. but cool!
<FromGitter>
<codenoid> yeah. electro swing is cool
<FromGitter>
<codenoid> my music from 3 years ago
rohitpaulk has joined #crystal-lang
<FromGitter>
<codenoid> good luck ✨
rohitpaulk has quit [Ping timeout: 276 seconds]
<oprypin>
bararchy, i'm not sure if we should pre-enlist students xD
<oprypin>
also i dont think people who happen to be studying cant be mentors
<FromGitter>
<bararchy> applicant as students can't be mentors, not talking about studnets IRL who want to mentor
LastWhisper____ has joined #crystal-lang
LastWhisper____ has quit [Read error: Connection reset by peer]
<FromGitter>
<bararchy> it's a good idea to see if there are strong people from the comuunity who would like to join as students, because it encourge all of us to work extra on this for them
<FromGitter>
<bararchy> If I can help RX14 get paid for working on Crystal, that's a great drive for me
<FromGitter>
<imonmyown> seeing all this discussion shows a healthy community spirit, which (in my opinion) is much more important than eventual contributions (if any should follow) during GSoC
<emgonam2>
<3
<FromGitter>
<bararchy> ^ 100% with you
<FromGitter>
<codenoid> My wish for crystal this year is `fast compilation time`, just like interpreter 🐶
<FromGitter>
<bararchy> well, debug is pretty fast, and release is faster if you use --thin-lto
<crystal-gh>
[crystal] petoem opened pull request #5563: Fix Time::Span multiply and divide (master...fix-time_span-multiply-divide) https://git.io/vNq5n
<FromGitter>
<bararchy> I want to have alias = Int32 | Int64 ⏎ But i want them both to be #.class, when calling my_alias.class it produces ⏎ (Int32 | Int64):class instead of (int32:class | Int64:class)
<FromGitter>
<bararchy> is it a bug or am i missing something ?
DTZUZO has quit [Ping timeout: 256 seconds]
<FromGitter>
<bararchy> I can ofc do my_alias_class = (Int32.class | Int64.class) , but I thought there is something easier
DTZUZO has joined #crystal-lang
<FromGitter>
<asterite> `Int32 | Int64` is the union type
<FromGitter>
<asterite> the other case is a union of types
<FromGitter>
<asterite> mmm... pretty confusing
<FromGitter>
<asterite> To be honest, I don't know (or remember) if I understand it :-P
DTZUZU has quit [Ping timeout: 248 seconds]
<FromGitter>
<bararchy> If you don't know then I give up hahha, I'll use the `.class` trick
wontruefree has joined #crystal-lang
<FromGitter>
<asterite> Oh, now I see
<FromGitter>
<asterite> The .class trick gives you a different thing
<FromGitter>
<asterite> it means it's either the Int32 type, or the Int64 type
<FromGitter>
<asterite> the alias is about the type of instances
DTZUZO has quit [Read error: Connection reset by peer]
<oprypin>
RX14, it is actually kinda distributed, that's where netsplits come from
<RX14>
yeah
<RX14>
but like
<RX14>
not enough
<RX14>
it's federated not distributed
<RX14>
i think
<oprypin>
that's a nice way to put it
DTZUZO has joined #crystal-lang
<FromGitter>
<bajro17> Hi people I really need help
<jhass>
well freenode at least is quite well distributed into different DCs around the world, more as a side effect of the servers being donations though
<FromGitter>
<bajro17> if someone use stripe atlas I need invitation
wontruefree has quit [Quit: The Internet needs a break and I need a cookie]
DTZUZO has joined #crystal-lang
sz0_ has joined #crystal-lang
wontruefree has joined #crystal-lang
wontruefree has quit [Remote host closed the connection]
wontruefree has joined #crystal-lang
wontruefree has quit [Client Quit]
jnyw has joined #crystal-lang
<FromGitter>
<bararchy> So, who is working on crystal play android edition ? :)
wontruefree has joined #crystal-lang
RX14 has quit [Quit: Fuck this shit, I'm out!]
Vexatos has quit [Quit: ZNC Quit]
<oprypin>
i dont know how people can suggest splitting up the compiler with a straight face. thank goodness that @straight-shoota has put it diplomatically
<oprypin>
bararchy, that might actually be a project because if it's not already working, it's quite close
Ven`` has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
jxv has joined #crystal-lang
jxv has quit [Client Quit]
wontruefree has quit [Quit: The Internet needs a break and I need a cookie]
<FromGitter>
<straight-shoota> @oprypin You never know from what background people are looking at things... maybe they're used to the strategy of devide and conquer which can help solving many problems. Unfortunately a compiler rewrite doesn't seem to be one of them ;)
<FromGitter>
<Dillybob1992> Hey guys just got done reading the removal of global variable thread. im following the TCPServer API and want to use a global `users` = [] of TCPServer to store players connections but can't seem to use the users array inside `handle_client`. as I get `undefined local variable or method 'users'`
jxv has joined #crystal-lang
<FromGitter>
<Dillybob1992> btw, im very new to crystal (in fact, installed lubuntu just so i can dev with it). the syntax is awesome!
<FromGitter>
<straight-shoota> Hey @Dillybob1992
<FromGitter>
<straight-shoota> Could you show some more code?
jxv has quit [Client Quit]
<FromGitter>
<Dillybob1992> hey :) should I paste it here, or use pastebin?
<FromGitter>
<Dillybob1992> > inline the methods body directly at the call ⏎ like, pass by argument?
<FromGitter>
<straight-shoota> yes, for example
<FromGitter>
<straight-shoota> or you make `users`accessible e.g. by making it a class variable
<FromGitter>
<Dillybob1992> So I can create something like class GameServer, then do @@users = [] of TCPSocket, and it'll be available everywhere in all my methods inside that GameServer?
<FromGitter>
<straight-shoota> yes
<FromGitter>
<Dillybob1992> Ohh, sweet 😄 i'll try that now
<FromGitter>
<straight-shoota> but you can even access it from outside that class using an accessor like `class_getter users`
<FromGitter>
<straight-shoota> (the error is just because the example can't run on carc.in but it should when you can open TCP ports)
<FromGitter>
<Dillybob1992> oh wow, i see
<FromGitter>
<straight-shoota> that's more like a hack though
<FromGitter>
<elorest> While we're on the topic of TCPSocket.... What is the best way to detect if the TCPServer is down. I need to pass hundreds of values a second through, but need to detect if the server is no longer reachable, and reconnect.
<FromGitter>
<straight-shoota> you mean connecting from crystal to a tcp server or checking if a crystal tcp server is running?
<FromGitter>
<elorest> I was hoping that the method `#closed?` would be useful but it only seems to switch if I call `close_write` and `close_read` on the client first.
<FromGitter>
<elorest> Both/Either. The client needs to do the detection so it shouldn't really matter what the server is written in...
<oprypin>
elorest, if there's one thing you should know about sockets, asking one if it's closed is never helpful
<oprypin>
the only thing you can do is ping it and give it some time before deciding that it's non-responsive
<FromGitter>
<Dillybob1992> i'm going to try to write my own gameserver class @straight-shoota just bcz i spent a lot of time reading docs/challenge myself, if i can't get it, gonna use your module hack :D
<FromGitter>
<elorest> By ping do you just mean send a message through and see if it responds?
FromGitter has quit [Remote host closed the connection]
oprypin has quit [Quit: Bye]
<RX14>
yes
FromGitter has joined #crystal-lang
<RX14>
@elorest but if reconenction is your goal, why not just set a read_timeout and write_timeout
<FromGitter>
<elorest> Would setting read and write timeouts to a really low number fix this?
justicefries has joined #crystal-lang
<RX14>
like what
DTZUZO has joined #crystal-lang
justicefries has left #crystal-lang [#crystal-lang]
<RX14>
10s is as low as i'd go
<RX14>
@elorest you don't even set timeouts in your sample
<FromGitter>
<elorest> Why would going lower than 10 seconds be bad.
<RX14>
you'll probably get spurious disconencts
<RX14>
TCP queues are long
<FromGitter>
<elorest> There are defaults though.
<FromGitter>
<elorest> Currently it reconnects after one or two missed messages.
<FromGitter>
<elorest> Apparently there isn't a way to catch it faster than that then?
<RX14>
that's after setting a 10s timeout?
<FromGitter>
<elorest> No before.
<FromGitter>
<elorest> 10 seconds if far longer than it currently takes to reconnect.
<RX14>
oh ok
<RX14>
well then
<FromGitter>
<elorest> So i'm not sure if setting it to 10 seconds would be useful or not.
<RX14>
you're not going to get better than that
<FromGitter>
<elorest> Ok. Thanks.
<RX14>
10s for a TCP reconnect?
<RX14>
that's instant
wontruefree has joined #crystal-lang
oprypin has joined #crystal-lang
wontruefree has quit [Client Quit]
<FromGitter>
<Dillybob1992> Ok! I finally got it I think: https://pastebin.com/raw/7fe4Me1F however, for some reason, still getting `undefined local variable or method 'users'` :(
<RX14>
@Dillybob1992 you need to refer to users as @@users
<RX14>
since that's how you defined it
<RX14>
well, more accurately the syntax for class vars is @@
<FromGitter>
<marksiemers> It isn't defined, there is just a class variable. Use that or create a method that returns the class variable
DTZUZU has joined #crystal-lang
<FromGitter>
<Dillybob1992> I see, there is going to be alot of @@'s all over once i get done with this hahaha
<RX14>
plus do you really want a global variable? Why aren't you using an instance variable here?
<RX14>
shouldn't the list of users be per-gameserver
<RX14>
not between all gameservers?
<FromGitter>
<straight-shoota> he started with a script without any types and couldn't use a top level variable in a method
<FromGitter>
<straight-shoota> getting oop-ifyied step by step
<FromGitter>
<straight-shoota> RX14 do you still have draft for 0.24.1 release notes?
<RX14>
draft?
<RX14>
why, they're released
<RX14>
oh you mean the blog post?
<FromGitter>
<straight-shoota> you mentioned in the website issue that you collected some ideas for a blog post
<RX14>
I got less than 1 sentence into it
<FromGitter>
<straight-shoota> okay then
<RX14>
actually 1.5
<RX14>
Crystal 0.14.1 has been released!
<RX14>
Crystal 0.24.1 has bought a lot of new and cool features,
<RX14>
then I stopped
<RX14>
lol
<FromGitter>
<straight-shoota> that's a great opener =)
<FromGitter>
<Dillybob1992> well, im just trying to keep track of all the connected players in one master server for now. i am cming from nodejs and crystal has been the one that i can understand the most, been trying them all (elixir, c++, golang)