jhass changed the topic of #crystal-lang to: The Crystal programming language | http://crystal-lang.org | Crystal 0.9.1 | Fund Crystals development: http://is.gd/X7PRtI | Paste > 3 lines of text to https://gist.github.com | GH: https://github.com/manastech/crystal | Docs: http://crystal-lang.org/docs/ | API: http://crystal-lang.org/api/ | Logs: http://irclog.whitequark.org/crystal-lang
renews has joined #crystal-lang
trapped has quit [Quit: Textual IRC Client: www.textualapp.com]
renews has quit [Remote host closed the connection]
pawnbox has joined #crystal-lang
pawnbox has quit [Ping timeout: 240 seconds]
bcardiff has joined #crystal-lang
ytti has joined #crystal-lang
ssvb has quit [Ping timeout: 240 seconds]
pawnbox has joined #crystal-lang
pawnbox has quit [Ping timeout: 246 seconds]
pawnbox has joined #crystal-lang
ssvb has joined #crystal-lang
pawnbox has quit [Ping timeout: 260 seconds]
<Reiser> Alright so, I managed to cut out the rest of my program and narrow down the problem somewhat
<Reiser> Does anyone know why this happens: http://pastebin.com/raw.php?i=r3cBmyBX
<Reiser> The output for running the program is at the bottom
<Reiser> I'm hoping this is just me misunderstanding something before I go and open a github issue about it
<Reiser> I thought maybe it was because what .select returns is an [] of IO, and maybe the base type being Array(IO) instead of Array(TCPSocket) was making the comparison fail
<Reiser> But the third test just with an .each on the array has the same problem even though It's working with the same data as the first test
ssvb has quit [Ping timeout: 246 seconds]
<jhass> Reiser: I guess FileDescriptorIO#== simply isn't (re)defined to match to compare the fd
<Reiser> Hmm, why does the first example work then
<jhass> same object
bcardiff has quit [Quit: bcardiff]
<Reiser> So the returned objects from IO.select are different objects?
<jhass> mmh, maybe iirc when I implemented it I actually search through the input, mhh
<Reiser> read_ios.try &.each do |io|
<Reiser> ios << io if read_fdset.is_set(io)
<Reiser> end
<jhass> yeah, it still does
<jhass> weird
<Reiser> I'll open an issue I guess
<jhass> they even have the same object ids :/
<jhass> I guess it has to do with the wrong == getting called
<Reiser> Yeah, honestly my ACTUAL program is doing this and has even weirder behaviour
<Reiser> Where if I do any stdout I/O before doing things with the sockets
<Reiser> The program stops working, but if I comment out any puts lines
<Reiser> it works
<Reiser> which makes me think It's a codegen bug but I feel like I'm not special enough to have instantly walked into something like that
<jhass> I ran into these all the time still ;)
<jhass> but atm I'm not sure it'll get fixed, given asterite & waj are basically rewriting that
<Reiser> Ah
<Reiser> I didn't realise, I already opened the issue as well
<jhass> Reiser: works if you swap it to socket == domain.conn
<Reiser> Hmm, hang on
<Reiser> As in, .find { |domain| socket == domain.conn }
<Reiser> ?
<jhass> yeah
<jhass> well, for the third case anyhow, apparently not for the second :/
<jhass> oh d'oh changed the first one actually
<Reiser> Ok so
<Reiser> a == b is not the same as b == a
<jhass> yes, since == is a method call
<Reiser> I didn't know that was the case
<jhass> so I guess the type inference goes mad here, picks the wrong type and thus the wrong ==
<Reiser> Yeah, because what I originally had, before switching to &
<Reiser> was
<Reiser> { |domain| domain.conn == socket }
<Reiser> which gives me the weird behaviour
<jhass> like it generalizes it to IO and calls IO#== instead of adding a runtime dispatch to the right thing
<Reiser> I've been going nuts over this for like 2 days, and never thought it would be something like that
<jhass> or something like that
<jhass> Reiser: that said aside, did you consider blocking calls inside new coroutines and Channel'ing out the result instead? Or are you really only ever interested in the first result?
<Reiser> I didn't, I'm pretty new to the language
<Reiser> Though why would it only ever be the first result, doesn't IO.select return all descriptors ready for reading?
<jhass> it does though idk what you're doing real world with this
<jhass> given find picks the first one too
<jhass> I guess my question is, what's your real world usecase?
<Reiser> There should only be one wrapper with each socket
<Reiser> Basically what I'm doing is I want to wrap several protocols (XMPP, IRC, Stack, etc) in Connection objects
<Reiser> Throw the TCPConnections into select and respond to whatever request comes through regardless of protocol
<Reiser> The .find will only find the first object but that should be fine, no two connections will share the same TCPSocket
<Reiser> I mean this was just me headbutting a first attempt to learn Crystal
<jhass> so, that sounds like superb usecase for coroutines
<Reiser> If I ever have a ton of connections doing .find is a bad idea
<jhass> spawn a new one for each connection and do a "blocking" read
<Reiser> Yeah, actually the old implementation for what I'm doing was in Haskell and did exactly that
<Reiser> I just forkIO'd every connection
<jhass> then run a handler right there or Channel out to a general handler coroutine
<Reiser> But I was writing this as-I-learn crystal so I just went for naive simple to get the hang of the language
<jhass> the coroutine version is actually a lot simpler :P
<Reiser> When you know the language, definitely, but I wrote this while doing the tutorial, and looking at the api at each step
<Reiser> I could've looked up coroutines but I was writing code before I even knew what TCPSocket looked like
<Reiser> I.E I just saw IO.select and thought 'grab that', 'grab this', it's just a bit of scratch work
<jhass> well granted, they're poorly documented atm since the API is still in flux
<jhass> https://gist.github.com/Kilobyte22/e51a6b16703694f861a3 goes somewhat into the current one
<Reiser> At first glance looks pretty standard
<jhass> yup
<Reiser> I'll switch things up eventually, but yeah, still learning the language
<Reiser> For example, I do not yet understand exactly WHY I can do &.<whatever> as a sort of short-form lambda
<jhass> it's simply syntax
<Reiser> Yeah, I just don't know the rules, for example I can't do method (& == 2), or method socket == &
<jhass> rewritten to {|_some_temp_name| _some_temp_name.<whatever you wrote after &.> } by the compiler for you
<Reiser> I assumed it was some sort of extension to the method &block hidden argument passing syntax
<Reiser> But It's just guessing
<jhass> well, it comes from Ruby's &:foo trick and in Ruby you're right
<Reiser> Never used ruby, for what It's worth
<jhass> in Ruby it's &(:foo), so passing the Symbol :foo to the & operator
<jhass> the & operator is used to pass a Proc (Lambda/anonymous function essentially) as a block to a method
<jhass> it has the side effect of calling to_proc on its argument
<Reiser> Huh, are the docs out of date? I thought that was what -> did
<jhass> I'm still talking about Ruby here
<Reiser> Oh I see
<Reiser> Ok
<jhass> so Symbol#to_proc, in Ruby, has a nice implementation that calls the method of the symbols name on the first argument
<jhass> that even started out in Rails (webframework you might've heard of)
<jhass> people found it useful enough that they included it into the standard library
<Reiser> Not familiar with its details, but a hard name to miss
<Reiser> Ah
<jhass> Crystal being heavily Ruby inspired tried to port that over, but given we can't make dynamic calls like that, it was introduced as syntax
<jhass> and made somewhat more powerful at the same time by accepting chains and arguments
<Reiser> I see, so It's more of a hardcoded special form
<jhass> yes
conorreedy1 has joined #crystal-lang
<Reiser> I feel like that should be better documented
<Reiser> I mean I get that Crystal is very Ruby-like
<Reiser> But I'm sure there's a lot of people who aren't Ruby programmers who'll pick up the language
<jhass> patches welcome ;)
<Reiser> I'll give it a shot, sitting in an cafe leeching wifi right now though because my block has a power cut
<Reiser> So I'll give it a shot later when I'm more relaxed
<jhass> cool
pawnbox has joined #crystal-lang
pawnbox has quit [Ping timeout: 246 seconds]
pawnbox has joined #crystal-lang
pawnbox has quit [Ping timeout: 246 seconds]
harisamin has joined #crystal-lang
<harisamin> hello everyone
pawnbox has joined #crystal-lang
pawnbox has quit [Ping timeout: 246 seconds]
pawnbox has joined #crystal-lang
pawnbox has quit [Ping timeout: 246 seconds]
harisamin has quit [Remote host closed the connection]
harisamin has joined #crystal-lang
conorreedy1 has quit [Quit: conorreedy1]
pawnbox has joined #crystal-lang
pawnbox has quit [Ping timeout: 246 seconds]
harisamin has quit []
vifino has quit [Ping timeout: 246 seconds]
vifino has joined #crystal-lang
rvchangue_ has joined #crystal-lang
rvchangue has quit [*.net *.split]
rvchangue_ is now known as rvchangue
manveru_ has joined #crystal-lang
BlaXpirit_ has joined #crystal-lang
jamie_ has joined #crystal-lang
havenn has joined #crystal-lang
havenn has joined #crystal-lang
salvor- has joined #crystal-lang
rvchangue_ has joined #crystal-lang
pragmatism_ has joined #crystal-lang
rvchangue has quit [*.net *.split]
BlaXpirit has quit [*.net *.split]
manveru has quit [*.net *.split]
pragmatism has quit [*.net *.split]
Keziolio has quit [*.net *.split]
Cidan has quit [*.net *.split]
havenwood has quit [*.net *.split]
salvor has quit [*.net *.split]
jamie_ca has quit [*.net *.split]
Bofu2U has quit [*.net *.split]
wmoxam has quit [*.net *.split]
mlitwiniuk has quit [*.net *.split]
jamie_ is now known as jamie_ca
rvchangue_ is now known as rvchangue
havenn is now known as havenwood
BlaXpirit_ is now known as BlaXpirit
wmoxam has joined #crystal-lang
Cidan has joined #crystal-lang
manveru_ is now known as manveru
pawnbox has joined #crystal-lang
Keziolio has joined #crystal-lang
pawnbox has quit [Ping timeout: 240 seconds]
pawnbox has joined #crystal-lang
ssvb has joined #crystal-lang
ssvb has quit [Ping timeout: 240 seconds]
A124 has joined #crystal-lang
ssvb has joined #crystal-lang
mlitwiniuk has joined #crystal-lang
sdogruyol has quit [Remote host closed the connection]
<travis-ci> MakeNowJust/crystal#e51690b (master - Merge pull request #1913 from benoist/escape-cookie-key): The build passed. https://travis-ci.org/MakeNowJust/crystal/builds/93630742
sdogruyol has joined #crystal-lang
sdogruyol has quit []
conorreedy1 has joined #crystal-lang
conorreedy1 has quit [Client Quit]
BlaXpirit has quit [Quit: Bye]
BlaXpirit has joined #crystal-lang
trapped has joined #crystal-lang
trapped has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
trapped has joined #crystal-lang
gamemanj has joined #crystal-lang
trapped has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
trapped has joined #crystal-lang
<trapped> does anyone know how to tell the compiler to add include paths (-L/path/to/something)?
<jhass> trapped: in code @[Link(ldflags: "...")], commandline: crystal build --link-flags="..."
<trapped> can i set `crystal build` flags for travis? it fails to link crystal-sqlite3 to libsqlite3 (i think it's because it can't find the library itself, which appears to be in /usr/lib/$(gcc -dumpmachine)/) https://travis-ci.org/trapped/sqlite_adapter.cr/builds/93650722
<jhass> trapped: that one is actually because the sqlite version on Travis is so old
<trapped> ah
<trapped> what if i download a sqlite source tarball and compile it locally then add something like "./sqlite" to LIBRARY_PATH?
<jhass> what you could try for me is whether the trusty image a newer one
<jhass> trapped: ^
<trapped> will do
<trapped> it seems it works
<jhass> cool
Kendos-Kenlen has joined #crystal-lang
<crystal-gh> [crystal] MakeNowJust opened pull request #1917: Ignore an empty path in CRYSTAL_PATH (master...fix/ignore-empty-path) http://git.io/vBibn
<crystal-gh> [crystal] MakeNowJust opened pull request #1918: Added the special variable $! (master...feature/dollar_bang) http://git.io/vBiNc
<crystal-gh> [crystal] jhass closed pull request #1917: Ignore an empty path in CRYSTAL_PATH (master...fix/ignore-empty-path) http://git.io/vBibn
trapped has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
ssvb has quit [Quit: Leaving]
trapped has joined #crystal-lang
renews has joined #crystal-lang
pawnbox has quit [Remote host closed the connection]
pawnbox has joined #crystal-lang
bcardiff has joined #crystal-lang
Kendos-Kenlen has quit [Quit: Konversation terminated!]
renews has quit [Remote host closed the connection]
renews has joined #crystal-lang
ponga has joined #crystal-lang
tomchapin has joined #crystal-lang
<crystal-gh> [crystal] benoist opened pull request #1919: allow set from json (master...json-mapping-set) http://git.io/vBPDy
bcardiff has quit [Quit: bcardiff]
bcardiff has joined #crystal-lang
tomchapin has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
trapped has quit [Read error: Connection reset by peer]
trapped has joined #crystal-lang
gamemanj has quit [Ping timeout: 260 seconds]
trapped has quit [Read error: Connection reset by peer]
renews has quit [Remote host closed the connection]
renews has joined #crystal-lang
renews has quit [Ping timeout: 240 seconds]
vifino has quit [*.net *.split]
toydestroyer has quit [K-Lined]
toydestroyer has joined #crystal-lang
benoist has joined #crystal-lang
renews has joined #crystal-lang
<benoist> jhass: I just changed the PR but I'm actually reconsidering if it's wise to use the Array PullParser
<jhass> because ... ?
<benoist> by reusing the array pull parser, you loop over the JSON array twice
<benoist> because creating a set from an array loops over the elements again
<jhass> benoist: wait, it doesn't yield?
A124 has quit [Quit: '']
<jhass> looks like there's a yielding one
<jhass> reuse that, the one you copied
renews has quit [Ping timeout: 246 seconds]
<benoist> I copied the 2 array methods
<jhass> yes, and I'm saying reuse the one we complained about since it didn't make sense
benoist_ has joined #crystal-lang
benoist has quit [Read error: Connection reset by peer]
<benoist_> must be because it's late, but don't get how it should be :)
<jhass> set = new; Array(T).new(pull) do |item| set << item; end; set; end
<benoist_> how about http://carc.in/#/r/n3p?
<jhass> maybe, did you figure out why the yielding overload exists for the array case?
<benoist_> there is a spec that uses it
<benoist_> looks like its the only one
<benoist_> running the full spec suite without that method now
<benoist_> so far it compiles without that method
<benoist_> should we remove it then?
<jhass> maybe?
<jhass> better ask asterite why he added it?
<benoist_> well it might be more memory efficient if you just want to iterate over the array and for instance just sum an array of numbers
benoist_ has quit [Remote host closed the connection]
benoist has joined #crystal-lang
vifino has joined #crystal-lang
pawnbox has quit [Remote host closed the connection]
pawnbox has joined #crystal-lang
pawnbox has quit [Ping timeout: 240 seconds]
renews has joined #crystal-lang
renews has quit [Ping timeout: 260 seconds]