<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
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
<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