jhass changed the topic of #crystal-lang to: The Crystal programming language | http://crystal-lang.org | Crystal 0.7.6 | 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
zamith_ has quit [Quit: Be back later ...]
zamith_ has joined #crystal-lang
zamith_ has quit [Ping timeout: 244 seconds]
<asterite> seems it's a common bug, I'll try to fix it soon :)
<jokke> ah
<jokke> ok
<jokke> good to know
fowlduck has joined #crystal-lang
fowlduck has quit [Ping timeout: 255 seconds]
zamith_ has joined #crystal-lang
zamith_ has quit [Ping timeout: 240 seconds]
<crystal-gh> [crystal] asterite pushed 1 new commit to master: http://git.io/vGcnE
<crystal-gh> crystal/master 59793cf Ary Borenszweig: Fixed #1076: free vars didn't work with recursive alias types
<travis-ci> manastech/crystal#59793cf (master - Fixed #1076: free vars didn't work with recursive alias types): The build has errored. https://travis-ci.org/manastech/crystal/builds/77875669
havenwood has quit [Ping timeout: 240 seconds]
<dzv> can instance_eval (or something else) be used to create DSL's in crystal? http://carc.in/#/r/d69. also self doesn't work with instance_eval
havenwood has joined #crystal-lang
kyrylo has quit [Quit: Konversation terminated!]
kyrylo has joined #crystal-lang
havenwood has quit [Quit: Textual IRC Client: www.textualapp.com]
zamith_ has joined #crystal-lang
zamith_ has quit [Ping timeout: 240 seconds]
havenwood has joined #crystal-lang
kyrylo has quit [Ping timeout: 240 seconds]
kulelu88 has quit [Quit: Leaving]
trapped has quit [Read error: Connection reset by peer]
zamith_ has joined #crystal-lang
zamith_ has quit [Ping timeout: 244 seconds]
fowlduck has joined #crystal-lang
fowlduck has quit [Ping timeout: 244 seconds]
havenwood has quit [Ping timeout: 260 seconds]
havenwood has joined #crystal-lang
zamith_ has joined #crystal-lang
zamith_ has quit [Ping timeout: 265 seconds]
NeverDie has quit [Quit: I'm off to sleep. ZZZzzz…]
zamith_ has joined #crystal-lang
havenwood has quit [Ping timeout: 240 seconds]
zamith_ has quit [Ping timeout: 240 seconds]
fowlduck has joined #crystal-lang
fowlduck has quit [Ping timeout: 264 seconds]
<jhass> I didn't even know we had an instance_eval
<jhass> dzv: for now the pattern is http://carc.in/#/r/d6p, won't change self either though
<crystal-gh> [crystal] jhass opened pull request #1327: Macro def doc (gh-pages...macro_def_doc) http://git.io/vGcMO
zamith_ has joined #crystal-lang
zamith_ has quit [Ping timeout: 252 seconds]
BlaXpirit has joined #crystal-lang
zamith_ has joined #crystal-lang
zamith_ has quit [Ping timeout: 264 seconds]
<dzv> instance_eval doesn't work as expected. not if you're coming from ruby
<jhass> yes
<jhass> it's very hard to do in a compiled language
<jhass> and as said I
<jhass> I'm surprised it exists at all
<jhass> in fact I can't find a reference to it in src/, I think it just hits the missing test before it hits the missing instance_eval
<tatey_> Hmm, is there a negated version of `expect_raises`?
<jhass> no, but I mean if it would it'll fail the test anyhow, no? ;)
<tatey_> True, but I wanted to make the intention of the spec more clear.
<jhass> you can try writing one ;)
<jhass> macro expect_to_not_raise; begin; {{yield}}; rescue e; fail "Expected no exception, but #{e.message} (#{e.class}) was raised"; end; end;
<jhass> or so
<jhass> might not even need to make it a macro
<jhass> actually for that example I find the second more clear
<tatey_> Fair enough. Well, I'll roll with the second one then.
<jhass> the Errno being raise is an error case of that spec, not a failure case
<jhass> *raised
<jhass> more debatable for something like it "allows the broadcast with a correct multicast address"
<tatey_> Actually, I think getting "allowed" in the description helps to convey the purpose of the test.
<tatey_> So good suggestion
zamith_ has joined #crystal-lang
zamith_ has quit [Ping timeout: 255 seconds]
zamith_ has joined #crystal-lang
zamith_ has quit [Ping timeout: 272 seconds]
<crystal-gh> [crystal] davydovanton opened pull request #1328: Fix typos in docs/macros.cr (master...fix-typo-docs-macros) http://git.io/vGCea
zamith_ has joined #crystal-lang
wanderer_ has joined #crystal-lang
<crystal-gh> [crystal] MakeNowJust closed pull request #1317: Add note of arguments evaluation timing (gh-pages...patch-1) http://git.io/vGs15
wanderer_ has quit [Quit: Page closed]
leafybasil has quit [Remote host closed the connection]
<Kilo`byte> who made the dbus bindings again?
<jhass> BlaXpirit ?
<BlaXpirit> hi
<BlaXpirit> maan, i'm letting these github stars get to me too much
<sardaukar> does anyone know what error code 3 is for Crystal binaries?
<sardaukar> *** [run] Quit: 3
<sardaukar> fish: 'and make run' terminated by signal SIGQUIT (Quit request from job control with core dump (^\))
<jhass> I don't think we have that predefined
<jhass> ah, that's signal 3
<sardaukar> it's SO weird - I'm reading a line with readline, and if I type a capital H, it quits with this error
<jhass> aka SIGQUIT
<sardaukar> why would capital H do that?
<jhass> dunno, try another shell?
<sardaukar> I tried a test script, works fine
<jhass> or maybe it segfaults, try running it through valgrind
<sardaukar> valgrind: OS X Mavericks or older is required.
<sardaukar> L(
<sardaukar> I'm on Yosemite
<jhass> that's sad
<jhass> get a sane OS? :P
leafybasil has joined #crystal-lang
<sardaukar> why the hell would a capital H crash my code?
<jhass> idk
<BlaXpirit> D:
<sardaukar> it just makes no sense
<sardaukar> is it because of ^H ?
<sardaukar> I can see no other reason
<sardaukar> guess I'll have to dump readline...
<sardaukar> a lot of choices being dictated to me by Crystal lately
<sardaukar> not cool
<jhass> SIGQUIT is ^\ though
<jhass> and "dictated", well, you're welcome to fix the readline binding
<jhass> (if it's indeed broken, which we didn't prove yet)
<sardaukar> I'm not a C guy :/
<jhass> me neither
<sardaukar> I could post the code, but it would have to be my whole codebase, since a tiny test I tried to replicate it in didn't expose the bug
leafybasil has quit [Ping timeout: 264 seconds]
<jhass> you could try disabling / stubbing out code paths until you have a minimal case still reproducing
<sardaukar> I'll try that
<jhass> had half an hour the other day going from DeBot to HTTP::Client.get("") crashing the compiler (on HEAD)
<sardaukar> gonna try running it with HEAD
kyrylo has joined #crystal-lang
<sardaukar> wow, HEAD won't even compile my code -_-'
<sardaukar> I get undefined method 'to_i' for nil
<sardaukar> on this line frame.return_to ? frame.return_to.to_i : -1,
<jhass> yes, it got dropped
<jhass> do || 0 if you want 0
<sardaukar> how can it be nil in this expression, though?
<jhass> return_to is a method call, it can return different values between invocations
<sardaukar> ah right
<jhass> assign the result to a local if you want the compiler to infer
<jhass> or (frame.return_to || -1).to_i would work too I guess
<sardaukar> HEAD still crashes on capital H
<sardaukar> bah
<sardaukar> I guess asterite is not OK with people sending him code to look at
<jhass> it would be nice if you could try to reduce it as much as you can, but he's perfectly fine with it
<sardaukar> I have a lot of code invested in this project now, and being an emulator it's not easy to extract portions of it :|
<sardaukar> he is? just via email?
<jhass> if you have good code structure it's very possible to stub things out
<jhass> http://paste.mrzyx.de/plunnfvkm is for example my scratchpad for DeBot
<sardaukar> I have to go now, but I'll keep trying this
<sardaukar> wouldn't like to give up readline
trapped has joined #crystal-lang
leafybasil has joined #crystal-lang
leafybasil has quit [Ping timeout: 244 seconds]
leafybasil has joined #crystal-lang
leafybasil has quit [Remote host closed the connection]
tatey_ has quit []
NeverDie has joined #crystal-lang
havenwood has joined #crystal-lang
NeverDie has quit [Quit: I'm off to sleep. ZZZzzz…]
ssvb has quit [Ping timeout: 250 seconds]
kyrylo has quit [Ping timeout: 250 seconds]
NeverDie has joined #crystal-lang
NeverDie has quit [Client Quit]
leafybasil has joined #crystal-lang
kyrylo has joined #crystal-lang
<Kilo`byte> BlaXpirit: you should consider adapting your DBus api to the ruby bindings one: https://github.com/mvidner/ruby-dbus
ssvb has joined #crystal-lang
<BlaXpirit> looks bad
<BlaXpirit> using [] for every operation -_-
<Kilo`byte> its just that people have gotten used to it
<Kilo`byte> one other thing though: make both system and session bus accessible
<BlaXpirit> Kilo`byte, they are accessible
<Kilo`byte> oh okay, i don't see any documentation on that though :P
NeverDie has joined #crystal-lang
kyrylo has quit [Quit: Konversation terminated!]
<BlaXpirit> there isn't any documentation at all
kyrylo has joined #crystal-lang
<Kilo`byte> https://github.com/BlaXpirit/crystal-dbus/blob/master/example.cr i count that as documentation :P
<Kilo`byte> also, can i list services/interfaces/methods
<BlaXpirit> no, Kilo`byte
<BlaXpirit> qdbusviewer is nice though
<Kilo`byte> thats a pity
<Kilo`byte> well, i need to list services matching a certain name ruleset at runtime
<Kilo`byte> wanna work on a mpd protocol wrapper around mpris supporting players
<BlaXpirit> Kilo`byte, well, to begin with, i would need to implement reading of replies
<Kilo`byte> wait, its write only at this point?
<BlaXpirit> yes
<BlaXpirit> and from then it's just a matter of parsing some xml
<Kilo`byte> should be doable with fibers quite easily :P
<Kilo`byte> the blocking calls that is
<BlaXpirit> i would be interested in hearing about that
<Kilo`byte> or to stay higher level, channels
<BlaXpirit> unfortunately, i haven't seen any official information on concurrency in crystal
<BlaXpirit> let alone tutorials
<Kilo`byte> BlaXpirit: basicly you pause the current fiber using Scheduler.reschedule
<Kilo`byte> to get a certain fiber to run use Scheduler.enqueue fiber
<Kilo`byte> Channel does all that for you (its higher level)
<Kilo`byte> reply = channel.receive
<Kilo`byte> then in the handler code: channel.send reply
<Kilo`byte> channel would be of type Channel(DBus::Reply) or sth
<BlaXpirit> eh sounds nice
<BlaXpirit> but i still have no idea how to actually use it
<BlaXpirit> i gather that it's asynchronous
<BlaXpirit> but where's the event loop?
<Kilo`byte> you might be able to use libevent2
<Kilo`byte> which is what crystal uses for IO internally
<Kilo`byte> otherwise you'd have to implement your own
<BlaXpirit> then i dont understand what is the point of using channel
<jhass> BlaXpirit: would you know how to do it with threads and queues?
<BlaXpirit> if it's asynchronous then there needs to be an event loop
<jhass> there is
<BlaXpirit> so that's all im saying
<jhass> but it's abstracted away, the programming paradigm isn't really evented anymore
<Kilo`byte> BlaXpirit: every crystal program uses an event loop for IO internally
<BlaXpirit> that's great, where do i learn about it?
<jhass> so, yes or no?
<Kilo`byte> if you call file.read that will block until the fiber gets an event saying "there is data"
<Kilo`byte> BlaXpirit: so you should probably answer jhass question
<BlaXpirit> huh
<Kilo`byte> 17:29:29 jhass | BlaXpirit: would you know how to do it with threads and queues?
<BlaXpirit> in theory yes but i dont know if libdbus would let me do that
<Kilo`byte> worst case you have to implement your own event loop
<Kilo`byte> which runs in background
<jhass> BlaXpirit: it's about the concept, not about doing that
<BlaXpirit> i don't know what purpose your question has, jhass
<jhass> BlaXpirit: you can work with coroutines and channels just the same way, replace Thread.new with spawn and Queue with Channel
<BlaXpirit> yeah i get it
<jhass> and don't worry about spawning too many threads
<jhass> "threads" ;)
<BlaXpirit> coroutines + async is a huge success with Python+Qt
<BlaXpirit> i understand the concepts, but I want specific Crystal information
<Kilo`byte> the best information source is the source
<Kilo`byte> although i am not too unfamilar with it either
<BlaXpirit> that is generally false
<Kilo`byte> no, there is not much documentation on it is my point
<BlaXpirit> ok
<Kilo`byte> i might write a guide
<Kilo`byte> starting with the basics and going into detail
<BlaXpirit> i would appreciate that
NeverDie has quit [Quit: I'm off to sleep. ZZZzzz…]
<Kilo`byte> does anyone by any chance know how many instructions a thread switch is (including a reliable source)
<Kilo`byte> can't find anything on google
<jhass> I'd expect that to differ quite a bit between versions of a single kernel and platform even
blue_deref has joined #crystal-lang
<Kilo`byte> just want a round figure
<Kilo`byte> i somewhere read something of around 150
<Kilo`byte> probably more
<Kilo`byte> jhass: is Array threadsafe?
<Kilo`byte> or how'd i pass stuff between threads?
<jhass> it's not
<jhass> I got some primitives from the time that DeBot was threaded https://github.com/jhass/DeBot/tree/master/thread/src/thread
<Kilo`byte> meh
<Kilo`byte> it'll do for an example
<Kilo`byte> although i can't really do any blocking operations
<Kilo`byte> gah, passing data between threads is a pain
<Kilo`byte> fibers are so much easier
<BlaXpirit> Kilo`byte, i mean, u can use them in exactly the same way as threads
<BlaXpirit> jhass, when i tried multithreading, i got a bunch of "Collecting from unknown thread" messages
<BlaXpirit> (+crash)
<BlaXpirit> do you know anything about that?
<Kilo`byte> Channels do not work with threads
<Kilo`byte> only fibers
<jhass> nor does any stdio IO anymore
<jhass> and I didn't mean you should use threads
<Kilo`byte> don't use threads unless you know what you are doing.
<BlaXpirit> hm it doesn't seem like threading alone breaks the GC
<BlaXpirit> i have C code starting the thread and calling my code
<BlaXpirit> that's vile
<BlaXpirit> of course, the C code can't register the threads with Crystal's GC. but for some reason GC breaks only sometimes.
<BlaXpirit> only under certain curcumstances i should say. it's not random
BlaXpirit_ has joined #crystal-lang
<Kilo`byte> BlaXpirit_: https://gist.github.com/Kilobyte22/e51a6b16703694f861a3 brief introduction, pipe any criticism straight to me and i'll improve
<Kilo`byte> please note it also is incomplete
<BlaXpirit_> it seems to me that if i didn't know the concept already, i wouldn't understand the introdutction
<Kilo`byte> well, this guide is intended for people who have worked with threads before
<Kilo`byte> might make that more clear
<BlaXpirit_> then maybe the informal explanation isn't needed, just confirming that these fibers are what you think they are
<BlaXpirit_> whatever, for people who know it, it's ok as it
<BlaXpirit_> is
<BlaXpirit_> first example is awesome
<BlaXpirit_> oh it's the only example :p
<Kilo`byte> yeah, i am going to explain how gets works as well
<Kilo`byte> and highlight the fact that you don't have to write event based io code to use event based io
<BlaXpirit_> so does this mean that crystal code is actually always in an event loop?
<BlaXpirit_> and `puts` checks scheduling and returns to the only fiber?
<dzv> io.gets reads from an internal buffer assigned to the io. if the buffer is empty it's filled by calling unbuffered_read(). unbuffered_read calls read(2) (a system call) in nonblocking mode. if it returns -1, errno = EWOULDBLOCK or similar an event is set on the io's fd using libevent and the fiber context is switched using Scheduler.something (Scheduler.yield i think)
oal has quit [Ping timeout: 246 seconds]
<dzv> the scheduler switched to the next available fiber in the run queue - threads that are ready to run for a) computation, b) ready to read from a channel or c) have an event or timer ready from libevent
<dzv> blaxpirit_ is this answering your question or should i stop?
BlaXpirit_ has quit [Ping timeout: 272 seconds]
fowlduck has joined #crystal-lang
<Kilo`byte> BlaXpirit: updated the gist
<BlaXpirit> dzv, i'm talking about the situation where no fibers are used at all
<BlaXpirit> i'm asking if that means that there is just 1 fiber in the run queue and the execution keeps returning to it
<jhass> isn't a Fiber essentially just a stackpointer?
<BlaXpirit> uh Kilo`byte, your code doesn't work
<BlaXpirit> http://carc.in/#/r/d7i and i'm getting the same error on my computer
<BlaXpirit> ah i should p[robably import something
<jhass> BlaXpirit: it's because gets may return nil
<jhass> String?
<BlaXpirit> added .not_nil! and now it instantly quits
<BlaXpirit> added sleep-loop afterwards. seems to work
<BlaXpirit> but this should be better explained
<BlaXpirit> and the example should be complete and runnable
<BlaXpirit> that will be my main criticism
thelonelyghost has joined #crystal-lang
<BlaXpirit> also the fact that sleep doesn't seem to hinder fibers
<BlaXpirit> is interesting and might be worth mentioning
<jhass> it's because it's not LibC.sleep, it's hooking into libevent
<Kilo`byte> yeah, socket needs to be imported
<BlaXpirit> Kilo`byte, could you just make the examples runnable
<Kilo`byte> ohhh gets returns a String?
<Kilo`byte> gotta do a nil check
<BlaXpirit> did you write an almost correct example without even trying it? :D
<BlaXpirit> that's nice
<Kilo`byte> i tried none of those examples
<Kilo`byte> xD
<Kilo`byte> BlaXpirit: the code examples that are supposed to work actually work now
<Kilo`byte> please note the second one needs a Server.new.listen to actually run :P
trapped has quit [Ping timeout: 260 seconds]
<Kilo`byte> BlaXpirit: another note, don't use .not_nil! in socket reading
<Kilo`byte> .gets returns nil to denote end-of-file
<Kilo`byte> in other words: the other end has closed the socket for writing
kulelu88 has joined #crystal-lang
kyrylo has quit [Ping timeout: 246 seconds]
Excureo has quit [Ping timeout: 240 seconds]
havenwood has quit [Quit: Textual IRC Client: www.textualapp.com]
kyrylo has joined #crystal-lang
<BlaXpirit> it says it gives you file descriptors to watch
<BlaXpirit> can i integrate this with crystal's event loop?
<Netfeed> man, that documentation...
<BlaXpirit> ikr
<Netfeed> if using this, then you get that, but if you are using this then you might get this other thing or yet another thing over here
<Netfeed> sigh
<Kilo`byte> BlaXpirit: idk the exact details on how crystal uses libevent2
<Kilo`byte> i assume you can register the fd to it somehow
<BlaXpirit> Kilo`byte, do you think you could help me out?
<Kilo`byte> not sure tbh, but i can try
<Kilo`byte> i'd really love to learn more about fibers, so why not
<BlaXpirit> i mean really, there is no other way that this can work
<BlaXpirit> how else would libdbus notify you of changes
<BlaXpirit> there is one other option - it's running dbus event loop in a separate thread
<Kilo`byte> you could do that
<BlaXpirit> and letting it communicate through channels with a fiber which would call functions
<Kilo`byte> channels won't work
<BlaXpirit> bleh, then what would?
<Kilo`byte> see my notes in the section about multithreading
<Kilo`byte> in the gist
<BlaXpirit> it's just warnings against i
<BlaXpirit> t
<Kilo`byte> it will break everything
<BlaXpirit> "In the future, crystal might actually run multiple fibers at the same time in different OS threads"
<BlaXpirit> so channels are supposed to work through threads
<Kilo`byte> if you run channel.send in like thread x (!= main thread), channel.receive will actually return in a different thread
<Kilo`byte> unix pipes
<Kilo`byte> that can get hairy though
<Kilo`byte> like, idk how to pass arbitrary data through them
<Kilo`byte> maybe json-ify it and shove it through
<BlaXpirit> ughh there could be a hashtable of ID->pendingreply
<BlaXpirit> so just number IDs would be sent
<Kilo`byte> i am not actually sure tbh
<Kilo`byte> BlaXpirit: what do you actually do once you get an event on a file descriptor
<BlaXpirit> i have no idea
<Kilo`byte> once you have that i can help you
<Kilo`byte> you might be able to still use fibers :P
<Kilo`byte> hmm unbuffered_read seems to be private
<thelonelyghost> quick question: is there active development on a REPL I can join in on?
<Kilo`byte> doubt it
<Kilo`byte> but who knows
* thelonelyghost shrugs
<Kilo`byte> question to those more familar with crystal IO: i have an fd io thingy. i want a read operation that reads all the buffered data
<Kilo`byte> if there is none, it shall block until there is data again
<jhass> doesn't take FileDescriptIO an fd?
<BlaXpirit> http://stackoverflow.com/a/9379775 something something. the guy even says it uses libevent
<Kilo`byte> jhass: yes, but how'd i query ti
<Kilo`byte> a call like io.read_until_end
<Kilo`byte> actually
<Kilo`byte> io.read_until_end_of_buffer
<jhass> .read does that, no?
<jhass> or was there read_fully?
<Kilo`byte> jhass: .read reads into a slice
<Kilo`byte> read_fully does not exist
<jhass> not all of them
<Kilo`byte> the ones from the BufferedIO mixin do
<jhass> IO#read doesn't
fowlduck has quit [Remote host closed the connection]
<Kilo`byte> but that seems to read all data
<Kilo`byte> which in this example is not feasable at all
<Kilo`byte> BlaXpirit: that would probably be all you need for your thing :P
<Kilo`byte> (read_partial, see issue)
<BlaXpirit> uhhhh
<Kilo`byte> actually hmmmm
<Kilo`byte> you can't shove data into it
<Kilo`byte> you can only tell it its ready i think
<Kilo`byte> yeah
<Kilo`byte> so we'd need a way to make a buffered io block until it has data without actually reading the data
<Kilo`byte> you'd then call dbus_handle_watch after pulling the event
<BlaXpirit> might be possible to just call libevent directly..?
<Kilo`byte> you might be able to
<Kilo`byte> check this file
<Kilo`byte> should be doable from what i see
<BlaXpirit> this is way over my head
<Kilo`byte> you really only have to register your own handler
<Kilo`byte> BlaXpirit: i am gonna finish some videos on electronics design, will look into that after that :)
<BlaXpirit> :o ok, thanks
<Kilo`byte> but if i am not mistaken it should be cleanly doable :P
<Kilo`byte> without any real hackery besides interfacing directly with libevent2
<Kilo`byte> idk if that counts as hackery
<BlaXpirit> that stackoverflow example shows everything
<BlaXpirit> but i'll be damned if i understand it
<BlaXpirit> probably should clean it from unrelated code. it has sockets and dbus functionality that we dont need
<Kilo`byte> well, i'll have to wrap my head around it first as well
<Kilo`byte> could have used some comments :P
<Kilo`byte> nice thing: the standard lib of crystal already has nice libevent bindings :D
<Kilo`byte> so we don't have to worry so much about that
fowlduck has joined #crystal-lang
<Kilo`byte> BlaXpirit: basicly the dbus library wants me to notifiy it whenever it gets data on a socket it can read from
<Kilo`byte> the addwatch is so i know it wants to be notified on a certain socket
<Kilo`byte> dbus_handle_watch does the actual notification
<Kilo`byte> so all i gotta do is register a low-level libevent2 handler for each of those sockets that actually pushes the event to dbus
<BlaXpirit> you explained it so clearly, but there is a lot of other stuff happening
<Kilo`byte> well, you also need code for unregistering the handler
<Kilo`byte> and stuff like that
<Kilo`byte> you also gotta handle when dbus tells you that stuff arrives
<Kilo`byte> (namely: push it to whatever fiber is waiting on it)
<Kilo`byte> BlaXpirit: i start to like this project :P
<BlaXpirit> is this sarcasm?
<Kilo`byte> no, not at all :P
<BlaXpirit> well i'm glad you like it. i guess i'll just be implementing the actual reading of replies
<Kilo`byte> sounds like good fun :D
<Kilo`byte> well, you will pretty much have to work with fibers there :P
<Kilo`byte> although you can probably use channels, haven't looked too much into that yet
<jhass> >> def foo(_); end; foo(1))
<DeBot> jhass: Syntax error in eval:4: unexpected token: UNDERSCORE - http://carc.in/#/r/d96
<jhass> I thought we allowed that already :/
<Kilo`byte> sounds like a good one tho :P
<Kilo`byte> you also got a ) too much at the end :P
<jhass> meh, doesn't matter :P
fowlduck has quit [Remote host closed the connection]
<Kilo`byte> BlaXpirit: do you have all dbus related functions in your lib.cr?
<BlaXpirit> Kilo`byte, i should, but mistakes are possible
<Kilo`byte> also you should comment your code better
<Kilo`byte> looking at the signature.cr and i have no clue what it does
<BlaXpirit> look at function names
<BlaXpirit> also there are tiny comments before functions
<BlaXpirit> eh you shouldn't concern yourself with signatures anyway
<Kilo`byte> yeah
<jhass> Okay I don't think the new Channel.select still works
<Kilo`byte> just wanted to get an overview
<Kilo`byte> BlaXpirit: uh i gotta dive into the dbus and libevent apis some more first
<Kilo`byte> you'd basicly map request -> fiber
<Kilo`byte> then for a reply get the request and resume the correct fiber (possibly use a channel instead)
<Kilo`byte> that fiber checks the request, parses it and returns the details from the method (possibly throwing an exception)
<BlaXpirit> yes...
<Kilo`byte> i can try anything that works with async stuff
<Kilo`byte> you would do the blocking stuff (would involve stuff like the parsing of the actual reply)
<BlaXpirit> yes, i'm on that
<BlaXpirit> just gonna implement it with blocking and push
<Kilo`byte> push?
<BlaXpirit> git push
<BlaXpirit> ETA: 1 hour
blue_deref has quit [Quit: Taking myself out of hear.]
<Kilo`byte> oh okay
<Kilo`byte> i'll probably push a struct/class instance through a channel for you :P
<Kilo`byte> you just grab and process that
<BlaXpirit> should we move to a private conversation?
<BlaXpirit> Kilo`byte
<Kilo`byte> sure
wanderer_ has joined #crystal-lang
NeverDie has joined #crystal-lang
n0xff has joined #crystal-lang
n0xff has left #crystal-lang [#crystal-lang]
thelonelyghost has quit [Quit: Leaving]
qard has joined #crystal-lang
dyulax has joined #crystal-lang
<Kilo`byte> can't wait for crystal to reliably run on arm
<sardaukar> can't wait for crystal to reliably run
<jhass> heh
<Kilo`byte> it does reliably run
<Kilo`byte> maybe not production reliable
<Kilo`byte> but reliable enough that i'd use it for basicly any personal project
<Kilo`byte> anyways, once crystal runs on arm i can implement my pi status page on it
<Kilo`byte> that gives a quick network status
<Kilo`byte> gotta look into fastcgi
<jhass> dunno, plain cgi I can see, but instead of fastcgi just listen on a socket
<sardaukar> Kilo`byte: I've been working on a Crystal project for 2 weeks now, yielded 5 issues so far
<jhass> only?
<sardaukar> not reliable enough for me
<sardaukar> jhass: 5 big ones only :D
<Kilo`byte> realiable enough means that i know if something runs for an hour it'll also run for 100 hours
<Kilo`byte> for me that is
<Kilo`byte> errors should appear at build time
<Kilo`byte> either compile time or in unit tests
<sardaukar> Kilo`byte: don't get me wrong, I love it too - but there's a way to go
<Kilo`byte> of course
<Kilo`byte> but this is alpha
<Kilo`byte> :P
<sardaukar> THIS. IS. ALPHAAAAAAA
<sardaukar> yeah, I get it :D
<jhass> okay, I need to restart it
<Kilo`byte> although... weechat was in alpha/beta for 10 years
<Kilo`byte> and it was working fine
DeBot has quit [Quit: Crystal IRC]
DeBot has joined #crystal-lang
<sardaukar> Freedos for over a decade too, right?
<jhass> !excuse
<DeBot> I haven't had the chance to run that code yet
<Kilo`byte> idk, haven't looked at that
<Kilo`byte> jhass: i gotta look into seemless restart again xD
<Kilo`byte> really nice concept
<sardaukar> what's that?
<Kilo`byte> restarting a network server/program without any outage
<sardaukar> interesting
<Kilo`byte> read: not even connections dropping
<Kilo`byte> you use the fact that after a fork() the child inherits the parents file descriptors and even after loading a new binary they stay open
<jhass> iirc the gist is serialize state and then fork to the new binary and recover state
<Kilo`byte> so you just pass the entire state of the program to the new instance
<sardaukar> pretty cool
<Kilo`byte> the tricky part is to make sure that while the new server is starting/the state is serializing the server still is fully operational
<sardaukar> it does sound tricky, or else more code would be doing this
<Kilo`byte> once the new server is ready to take over it tells the old instance
<Kilo`byte> firstly that and secondly: unix only :P
<Kilo`byte> weechat does that btw
<Kilo`byte> /upgrade will do a full restart and not drop any connections
<Kilo`byte> (doesn't work for TLS connections though :<)
<jhass> let's all curse OpenSSL together
* jhass curses OpenSSL
<Kilo`byte> actually weechat uses gnutls iirc
<Kilo`byte> yeah, at least on my computer it does
<jhass> ldd says no
<jhass> libssl.so.1.0.0 => /usr/lib/libssl.so.1.0.0 (0x00007fda1ba42000)
<jhass> libcrypto.so.1.0.0 => /usr/lib/libcrypto.so.1.0.0 (0x00007fda1b5cb000)
<jhass> wth does it link against ssh?
<Kilo`byte> ~/code/crystal  ldd $(which weechat) | grep gnu
<Kilo`byte> libgnutls.so.30 => /usr/lib/libgnutls.so.30 (0x00007f571d621000)
<Kilo`byte> thats on arch
<jhass> oh, it links against both oO
<jhass> look further down
<Kilo`byte> ic
<Kilo`byte> well, i've been told gnutls has better performance
<jhass> I'll need to do DANE verification for openssl.cr
<jhass> but that requires getting authenticated DNS replies first I guess
<Kilo`byte> jhass: also i am considering to suggest adding a socket factory api
<jhass> that'd do what?
<Kilo`byte> could be pretty useful for stuff like proxy or ssl libraries
<Kilo`byte> you'd be able to pass a class to libraries using sockets which has a factory method for creating sockets
<Kilo`byte> how that socket is created depends on the factory
<Kilo`byte> it might be tunneled through a proxy or it might be a plain old TCPSocket
<Kilo`byte> or even stuff we can't think of right now
<Kilo`byte> if we ensure that all internal libs support it and encourage external library authors to use it, we'd have much more compatibility
<jhass> uh, dunno, I'd let one or two libraries that would benefit from it emerge first and then look for a common interface
* Kilo`byte is looking at the builtin http/ftp stuff
<Kilo`byte> also we have multiple irc libraries already :P
<jhass> wouldn't a single well defined callback suffice actually?
<Kilo`byte> hmmm
<Kilo`byte> actually, it should be enough
<jhass> alias SocketConstructor = host : String?, port : Int32?, path : String? -> Socket
<Kilo`byte> thinking if it should be a url thats passed (so you could support things like unix sockets as well) or string/int combo
<jhass> or so, idk
<jhass> or maybe just a URI
<Kilo`byte> that'd allow pretty much anything
<Kilo`byte> if the factory doesn't support that it'd just throw an exception
<Kilo`byte> that being the protocol
<Kilo`byte> you could also chain factories. so the ssl factory would use its own factory to create the socket
<Kilo`byte> so you could pipe TLS through a proxy for example
<Kilo`byte> gonna make that an issue on github
<BlaXpirit> finally it's not a potato anymore https://github.com/BlaXpirit/crystal-dbus
<BlaXpirit> sending messages and receiving replies is something
<jhass> nice1
<BlaXpirit> but receiving only by blocking so far
<Kilo`byte> we'll get event based in :P
<Kilo`byte> jhass: https://github.com/manastech/crystal/issues/1330 issue created
tatey_ has joined #crystal-lang
<dzv> kilo`byte: do you have an example of fork + exec where fd's stay open in the child?
<Kilo`byte> uh not off hand
<Kilo`byte> file = File.open("~/.bashrc"); Process.fork do puts Process.pid; sleep 100; end
<Kilo`byte> then check /proc/<pid>/fd
<dzv> but you didn't exec
<Kilo`byte> oh right
<Kilo`byte> file = File.open("~/.bashrc"); Process.fork do puts Process.pid; Process.exec("sleep 100"); end
<Kilo`byte> there :P
<dzv> all fd's should be marked close on exec
<dzv> that's odd
<dzv> is that on HEAD?
<Kilo`byte> i've not tried it myself
<Kilo`byte> why'd you do that though :P
<jhass> dzv: system? :P
<jhass> system("cat")
<Kilo`byte> gah
<Kilo`byte> i vote for an option to not automatically close fds :P
<jhass> try that on HEAD
<jhass> oh, nvm
<dzv> doesn't show anything except pipes for me
<Kilo`byte> is there an option to not close sockets?
<dzv> io.close_on_exec = true|false
<Kilo`byte> good to know :D
<dzv> it's done turned off automatically for io passed to Process.run
<Kilo`byte> just something to be aware off
waterlink has joined #crystal-lang
<waterlink> Hi all! Is there a way to pin-point segfaults?
<waterlink> gdb only tells that SIGSEGV was received in GC_finalize (), since I can't generate debug symbols (since feature currently is broken)..
<jhass> I usually valgrind, but if it's in GC_finalize that won't help much either I guess :/
<Kilo`byte> i doubt debug symbols could help you with that
<Kilo`byte> but who knows
<jhass> I guess it's a double free bug? maybe you recognize the pointer?
<waterlink> jhass: there is a high chance it is a double free bug, since I am calling LibMySql.free_result, which probably deallocates memory..
<waterlink> jhass: Yes, if I comment out LibMySql.free_result(result), it fails now somewhere in crystal code: in *Spec::Result::new<Symbol, String, String, Int32, Spec::AssertionFailed>:Spec::Result ()
<waterlink> It actually fails at random places. Depending on if I run under valgrind or not, if I specify `-v` parameter to specs or not..
<waterlink> This one being the most often one: https://gist.github.com/waterlink/ab0a845fa29342a54d84
<jhass> ugh
<jhass> did you map out structs or is all passing around void pointers?
<Kilo`byte> anyways, i am going to get a nap
<waterlink> I have structs there, but they are empty. Actually just with one stub element.
<jhass> ah, that might be the wrong size then
<waterlink> I see
<jhass> wrongly mapped out structs tend to produce these kind of random memory corruptions
<Kilo`byte> keep in mind: struct size is platform dependant
<Kilo`byte> (well, in some cases)
<waterlink> jhass, Kilo`byte: thanks! will give it a shot
<jhass> waterlink: it seems like you never actually need to allocate it yourself?
<jhass> ah, nvm, init wants an allocated one
blue_deref has joined #crystal-lang
<BlaXpirit> is there a shortcut to arr = []; asdf.each do |x|; arr << x; end; arr
<BlaXpirit> (when an iterator is not defined)
<jhass> .concat ?
<jhass> .dup?
<BlaXpirit> arr = []; asdf do |x|; arr << x; end; arr
<jhass> oh, no
<BlaXpirit> collecting from a yielding thing into an array
BlaXpirit has quit [Quit: Konversation]
blue_deref has quit [Quit: Taking myself out of hear.]