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