00:04
DerisiveLogic has joined #crystal-lang
00:17
vikaton has quit []
00:47
datanoise has joined #crystal-lang
01:35
Liothen has quit [Ping timeout: 276 seconds]
03:13
shama has quit [Quit: (╯°□°)╯︵ɐɯɐɥs]
03:15
ismaelga has joined #crystal-lang
03:49
JBat has joined #crystal-lang
04:00
Cidan is now known as zz_Cidan
04:23
datanoise has quit [Quit: leaving]
04:23
datanoise has joined #crystal-lang
04:59
havenwood has joined #crystal-lang
05:00
bcardiff has joined #crystal-lang
05:26
ismaelga has quit [Remote host closed the connection]
05:49
DerisiveLogic has quit [Ping timeout: 265 seconds]
06:32
DerisiveLogic has joined #crystal-lang
06:35
Liothen has joined #crystal-lang
06:44
havenwood has quit [Ping timeout: 250 seconds]
07:21
BlaXpirit has joined #crystal-lang
07:26
ponga has joined #crystal-lang
07:26
datanoise has quit [Ping timeout: 245 seconds]
08:10
jua_ has joined #crystal-lang
08:23
datanoise has joined #crystal-lang
08:50
<
unshadow >
Thats funny, the IPSocket default is IPV6 ?
08:53
<
jhass >
what do you mean?
08:54
<
jhass >
it's AF_UNSPEC, so whatever your system configuration prefers comes first
09:02
<
unshadow >
My system (the same as yours) defaults to IPv4, now, when looking at the class(?) that server.accept.peeraddr get I see this : "Socket::Addr(@family="AF_INET6", @ip_port=51233, @ip_address="::ffff:127.0.0.1")"
09:02
<
unshadow >
@family="AF_INET6"
09:03
<
jhass >
oh, TCPSocket
09:03
<
unshadow >
yeha .. sorry I wrote IPSocket
09:03
<
unshadow >
isn't that wierd ?
09:04
<
jhass >
so, on modern linux that listens to both, v4 and v6 and you get those mapped addresses for v4 traffic
09:04
<
unshadow >
yeha, I can see that I have both ::ffff and 127.0.0.1
09:04
<
jhass >
so listening to v6 by default gets you the broader compatibility in fact
09:09
<
unshadow >
thats ok as long as this is on Arch, what about Ubuntu ? will that behave ok ? also, what if my system don't support IPv6 ?
09:10
<
jhass >
as said, it's the default for modern linux
09:11
bcardiff has quit [Quit: Leaving.]
09:11
<
unshadow >
btw, I got t.alive? to work, though I get segfault here and now XD Maybe i'll use your suggestion
09:15
<
unshadow >
If I get Process.pid != Thread id right ? there could be multiple threads under the same process right ?
09:15
<
unshadow >
ignore "If I get"
09:17
<
jhass >
I think so, yeah
09:17
<
jhass >
check pthread_self
09:18
datanoise has quit [Ping timeout: 240 seconds]
09:19
ponga has quit [Quit: Leaving...]
09:46
BlaXpirit has quit [Quit: Quit Konversation]
09:47
BlaXpirit has joined #crystal-lang
10:15
datanoise has joined #crystal-lang
10:19
datanoise has quit [Ping timeout: 252 seconds]
10:29
DerisiveLogic has quit [Ping timeout: 264 seconds]
11:24
Codcore has joined #crystal-lang
11:25
<
Codcore >
Hello, how to properly to redefine assign method? I tried def = () but it doesn't work
11:26
<
jhass >
it's not a method
11:26
<
jhass >
a = b doesn't involve a method call, only a.b = c does
11:27
<
jhass >
the latter is syntax sugar for a.b=(c)
11:27
<
jhass >
so calling the method b= on a
11:27
<
Codcore >
Got it, thanks!
11:34
<
Codcore >
is it some perfomance benefits for using "getter :headers" instead "getter headers"?
11:34
<
BlaXpirit >
Codcore, it's exactly the same
11:34
<
jhass >
no, that's evaluated at compile time
11:34
<
jhass >
well, SymbolLiteral vs idk, Call?
11:34
<
jhass >
but the code that's generated is the same, yeah
11:35
<
BlaXpirit >
i assume .id is called on the argument which makes it exactly the same
11:36
<
BlaXpirit >
but not the same in general
11:39
<
Codcore >
jhass, BlaXpirit thank you for answers
12:17
<
unshadow >
Again, I won the compiler ;)
12:46
<
unshadow >
jhass: got thread.alive? work with the method you suggested (pthread.kill(t, 0)) looks good and no segfaults
12:47
<
unshadow >
It's only like 4 lines of changes, I dont wanna open a PR for that, should I just open an issue with the changes to the files ?
12:49
<
jhass >
why not open a PR? add some specs to make it more changes :P
12:49
<
unshadow >
Oh well.. I'll fork and change
12:57
vikaton has joined #crystal-lang
13:03
zamith has joined #crystal-lang
13:03
<
zamith >
How can I translate this "typedef void* (*GumboAllocatorFunction)(void* userdata, size_t size);" into crytal's C binding dsl?
13:05
datanoise has joined #crystal-lang
13:14
datanoise has quit [Ping timeout: 276 seconds]
13:15
ismaelga has joined #crystal-lang
13:19
<
unshadow >
jhass: about the removing ==, what do you mean its already returs boolean ?
13:20
<
jhass >
>> "a" == "b"
13:20
<
jhass >
>> "a" == "a"
13:20
<
jhass >
>> ("a" == "a").class
13:21
<
unshadow >
anything else ?
13:22
<
jhass >
nothing important, I like be_true and be_false
13:23
<
unshadow >
yeha, its cool but I tried to keep the same style of the former spec tests
13:24
<
jhass >
zamith: mmh, I still suck at reading C function type declarations
13:24
<
zamith >
I went with Void*, because I don't know how to do it properly
13:25
<
zamith >
would love to understand it though :/
13:25
<
jhass >
alias GumboAllocatorFunction = (Void*, LibC::SizeT) -> Void* ?
13:26
<
zamith >
alias or type?
13:27
<
zamith >
I saw type being used a couple of times throughout the core
13:27
<
jhass >
ah, another one where I still don't know the exact difference, I think both should work
13:27
<
jhass >
I somehow always used alias so far
13:29
<
zamith >
ok, thanks
13:40
BlaXpirit_ has joined #crystal-lang
13:40
BlaXpirit has quit [Killed (hitchcock.freenode.net (Nickname regained by services))]
13:46
<
unshadow >
>> gets("\r\n\r\n")
13:46
<
unshadow >
>> gets('\r')
13:47
<
unshadow >
thats kinda stupid, if I want to specify a delimiter which is 4 null, "\0\0\0\0" why to force a char ?
13:51
alexmikitenko has joined #crystal-lang
13:54
alexmikitenko has quit [Client Quit]
14:14
<
BlaXpirit >
if the whole function body is written in a header file, I think it is not included in the library file
14:14
<
BlaXpirit >
so I can't use it in crystal
14:14
<
BlaXpirit >
is that correct?
14:15
Codcore has quit [Ping timeout: 246 seconds]
14:16
<
jhass >
no experiences, I'd say 50/50 chance
14:16
<
jhass >
mh, actually the header is just included into the .c on build, it's treated like one file by the C compiler
14:17
<
BlaXpirit >
i would just try this, but it's not that quick
14:17
<
jhass >
thinking about it, I'd say 80% chance it's in the .so
14:17
<
BlaXpirit >
what if it also says inline?
14:18
<
jhass >
oh, then 5% chance (because I might miss something, my C is weak)
14:18
<
jhass >
inline means don't generate the function, replace the calls by the body
14:22
<
BlaXpirit >
yup, no such function
14:22
<
BlaXpirit >
so then, if i make bindings then i must write this function in crystal code
14:22
<
BlaXpirit >
and I can't include it inside the namespace of the lib
14:23
<
BlaXpirit >
just completely no way
14:23
<
BlaXpirit >
this is really not nice
14:26
datanoise has joined #crystal-lang
14:31
datanoise has quit [Ping timeout: 264 seconds]
14:45
bcardiff has joined #crystal-lang
14:52
havenwood has joined #crystal-lang
14:55
<
unshadow >
>> a = "test::more"; b = a.split("::"); puts b
14:55
<
unshadow >
>> a = "testmore"; b = a.split("::"); puts b
14:56
Codcore has joined #crystal-lang
14:59
ismaelga has quit [Remote host closed the connection]
15:00
<
unshadow >
Codcore: nice !
15:06
<
unshadow >
So, for my next trick, Process.setsid :)
15:07
<
jhass >
I have setuid laying around
15:08
<
unshadow >
so why dont you add setuid and setsid and create a PR ?
15:09
<
jhass >
because I'm lazy
15:10
<
unshadow >
btw, I think fork do my be broken, or at least makes the compiler crazy
15:14
<
unshadow >
>> defined?(a)
15:14
<
unshadow >
>> is_defined?(a)
15:15
<
jhass >
>> "happy #{"100".to_i64(36)} pastes!"
15:18
ismaelga has joined #crystal-lang
15:29
<
unshadow >
jhass: what are we going to do with Thread.alive? then?, should I retry using pthread_tryjoin_np ?
15:30
<
jhass >
dunno, look up on the portability of that one first. might just have to maintain our own flag :/
15:31
<
unshadow >
This function is missing on all non-glibc platforms: glibc 2.3.2, Mac OS X 10.5, FreeBSD 6.4, NetBSD 5.0, OpenBSD 3.8, Minix 3.1.8, AIX 7.1, HP-UX 11.31, IRIX 6.5, OSF/1 5.1, Solaris 11 2011-11, Cygwin, mingw, MSVC 9, Interix 3.5, BeOS.
15:35
<
unshadow >
jhass: when you say that MRI maintains there own flag, does that mean they compile a lipthread with the MRI program and then use the modified version ?
15:36
<
jhass >
no, it means they hook stuff into the end of the thready body that sets the flag (and all other places that notice when a thread's state changes)
15:37
<
unshadow >
Oh, that sounds like alot of work
15:38
<
unshadow >
so when ever I'll do a Thread.new, the returned class (object) will have another value in it that means the threads state right ?
15:39
<
unshadow >
and from there on the GC, Thread.join,kill,finalize etc.. will need to see and understand that flag right ?
15:43
<
unshadow >
>> t = Thread.new; p t
15:43
<
unshadow >
>> t = Thread.new { a = 5}; p t
15:43
<
DeBot >
unshadow: #<Thread(Nil, Int32):0x8bf8fc8 @func=#<(Nil -> Int32):0x804abf0:closure>, @arg=nil, @detached=false, @th=Pointer(Void)@0xb6becb40, @ret=nil, @exception=nil> - more at
http://carc.in/#/r/104
15:44
<
unshadow >
>> t = Thread.new { a = 5}; puts pointerof(t)
15:45
<
unshadow >
Can't we just check if the pointer is a Thread pointer or just cleaned by GC ?
15:47
<
unshadow >
>> t = Thread.new { a = 5}; check = pointerof(t); puts alive if check.is_a?(Pointer(Thread(Nil, Int32)))
15:47
<
unshadow >
>> t = Thread.new { a = 5}; check = pointerof(t); puts "alive" if check.is_a?(Pointer(Thread(Nil, Int32)))
15:48
<
unshadow >
>> t = Thread.new { a = 5}; check = pointerof(t); puts "alive" if check.is_a?(Pointer(Thread(Nil, Int32))) ; puts "dead" if !check.is_a?(Pointer(Thread(Nil, Int32)))
15:48
<
unshadow >
or something ....
15:51
<
Codcore >
how to transform float from exponential representation to dotted one?
15:51
<
unshadow >
>> t = Thread.new { a = 5}; check = pointerof(t); puts "alive" if check.is_a?(Pointer(Thread(T, T))) ; puts "dead" if !check.is_a?(Pointer(Thread(Nil, Int32)))
16:13
vikaton has quit []
16:16
datanoise has joined #crystal-lang
16:22
ismaelga has quit [Remote host closed the connection]
16:23
datanoise has quit [Ping timeout: 256 seconds]
16:24
ismaelga has joined #crystal-lang
16:25
jua_ has quit [Ping timeout: 264 seconds]
16:29
datanoise has joined #crystal-lang
16:49
jua_ has joined #crystal-lang
16:58
<
BlaXpirit >
i think Int is always 32
17:00
vikaton has joined #crystal-lang
17:07
<
jhass >
wouldn't we get a ton of segfaults if so?
17:09
<
BlaXpirit >
jhass, well i dunno, first of all i've never seen these used
17:09
<
BlaXpirit >
and maybe those who did use it had 64 bit systems
17:09
<
jhass >
only a few specs are failing on 32 bit
17:09
<
jhass >
still didn't find a way to run a 32bit CI build :/
17:14
bcardiff has quit [Quit: Leaving.]
17:17
Codcore has quit [Ping timeout: 246 seconds]
18:00
bcardiff has joined #crystal-lang
18:04
<
vikaton >
how is windows going for Crystal?
18:06
<
vikaton >
BlaXpirit: Is it ready for windows or not yet?
18:06
<
BlaXpirit >
i really don't know
18:07
<
BlaXpirit >
the main thing we see at the link is it's not stagnant
18:19
zamith has quit [Quit: Be back later ...]
18:21
zamith has joined #crystal-lang
18:40
ismaelga has quit [Remote host closed the connection]
18:52
ismaelga has joined #crystal-lang
18:53
bcardiff1 has joined #crystal-lang
18:53
bcardiff has quit [Ping timeout: 250 seconds]
18:57
zz_Cidan is now known as Cidan
19:05
havenwood has joined #crystal-lang
19:14
<
unshadow >
I'm playing around with stressing Threads, I'm getting this crash: "[err] evmap.c:367: Assertion nread >= 0 failed in evmap_io_del"
19:14
<
unshadow >
Aborted (core dumped)
19:15
<
unshadow >
the code itself is pretty simple, but I cant understand the err
19:24
dhruv has joined #crystal-lang
19:24
<
dhruv >
How can I kill a process by pid?
19:24
<
dhruv >
In ruby, you can do Process.kill 9, pid
19:25
<
jhass >
I think you still have to bind the syscall
19:26
<
jhass >
lib LibC; fun kill(pid : Int32, signal : LibC::IntT); end;
19:27
<
jhass >
an enum for the signals is there
19:27
<
jhass >
well, constants
19:27
<
jhass >
Signal::TERM
19:27
<
jhass >
wrap that up in a method on Process and it's a nice PR :)
19:29
<
dhruv >
will do, thanks
19:29
<
dhruv >
how can I typecast int32 to Int64?
19:29
ismael_ has joined #crystal-lang
19:30
ismaelga has quit [Ping timeout: 276 seconds]
19:30
<
jhass >
>> 42 as Int64
19:30
<
jhass >
>> Int64.cast(42)
19:30
<
jhass >
>> Int64.cast(42).class
19:31
<
jhass >
well, I guess it does convert under the hood there :P
19:31
<
jhass >
>> 42.to_i64
19:31
<
jhass >
prolly the same
19:31
<
unshadow >
42.to_i64.class
19:31
<
unshadow >
>> 42.to_i64.class
19:32
<
jhass >
should rename .cast to .convert I guess
19:34
<
unshadow >
>> a,b, = 1,2 if true
19:34
<
unshadow >
>> a,b = 1,2 if true
19:35
<
unshadow >
I hate working on Saturday :(
19:35
<
strcmp1 >
im doing the same
19:35
<
strcmp1 >
do you work from home?
19:36
<
unshadow >
Well, its 22:30 here, if I was'nt working from home someone would need to give me a f**king big raise hahah
19:36
JBat has quit [Quit: Computer has gone to sleep.]
19:36
<
unshadow >
strcmp1: are you in the office right now ?
19:37
<
unshadow >
I mean at work *
19:37
<
strcmp1 >
no, i work from home too
19:38
bcardiff has joined #crystal-lang
19:41
bcardiff1 has quit [Ping timeout: 272 seconds]
19:42
<
unshadow >
>> puts "a" rescue nil
19:42
<
unshadow >
>> raise "a" rescue nil
19:43
<
unshadow >
>> raise "a" rescue nil if true
19:43
<
jhass >
inline rescue could have been gone IMO
19:43
<
unshadow >
I know I know
19:44
<
unshadow >
it's just for a ensure on socket.close
19:45
<
strcmp1 >
it's one of those things that's useful when you're doing a quick hack
19:45
<
jhass >
mmh, do we allow restrictions?
19:46
<
jhass >
>> raise ArgumentError.new rescue ArgumentError nil
19:46
<
jhass >
>> raise ArgumentError.new rescue e : ArgumentError nil
19:46
<
BlaXpirit >
>> raise ArgumentError.new; rescue e : ArgumentError; nil end;
19:46
<
BlaXpirit >
>> begin; raise ArgumentError.new; rescue e : ArgumentError; nil end;
19:47
<
jhass >
yeah, ; in real code is as ugly :P
19:47
<
unshadow >
its not real oneliner
19:47
bcardiff has quit [Ping timeout: 272 seconds]
19:48
bcardiff has joined #crystal-lang
19:49
<
unshadow >
a.is_a?(Array) feels bad, should be a.is_an?(Array) ;)
19:51
<
jhass >
well, that's why Ruby core is adopting a strict infinitive policy
19:51
<
jhass >
.include?, .exist? etc
19:51
<
jhass >
because it's not english after all, it just looks a whole lot like it
19:51
dhruv has quit [Ping timeout: 272 seconds]
19:52
<
strcmp1 >
i prefer Array === a.
19:52
<
jhass >
=== is for case, nothing else
19:53
<
unshadow >
>> a = [1,2,3]; a === Array
19:53
<
unshadow >
>> a = [1,2,3]; Array === a
19:53
<
unshadow >
>> a = [1,2,3]; a == Array
19:53
<
unshadow >
>> a = [1,2,3]; a.is_a?(Array)
19:53
<
jhass >
>> a = [1, 2, 3]; case a; when Array; puts "hey"; end;
19:54
<
unshadow >
for a sec I thought your bot got crazy
19:54
<
strcmp1 >
in crystal, === is not an option then :)
19:54
<
unshadow >
strcmp1: you said it, you open an issue XD
19:56
<
unshadow >
I opened too many lately, I think asterite will just start ignoring my issues hhaha
19:56
ismael_ has quit [Remote host closed the connection]
19:58
<
jhass >
nah, he didn't have to debug a program you wrote for 3 hours yet :P
19:59
<
jhass >
(to be fair it uncovered 3-4 bugs in the compiler)
20:02
<
BlaXpirit >
my issues seem to have gone pretty well
20:07
Cidan is now known as zz_Cidan
20:20
DerisiveLogic has joined #crystal-lang
20:56
bcardiff has quit [Ping timeout: 264 seconds]
21:02
bcardiff has joined #crystal-lang
21:05
bcardiff1 has joined #crystal-lang
21:07
bcardiff has quit [Ping timeout: 272 seconds]
21:24
bcardiff1 has quit [Read error: Connection timed out]
21:24
bcardiff has joined #crystal-lang
21:25
zamith has quit [Quit: Be back later ...]
21:31
blAckEn3d has joined #crystal-lang
21:31
blAckEn3d has quit [Client Quit]
21:32
blAckEn3d has joined #crystal-lang
21:32
<
blAckEn3d >
hi. just wanted to say that I tried crystal today and it's a great language :). thanks for the hard work.
21:40
<
jhass >
what's your background?
21:40
<
blAckEn3d >
kind of mixed: lisp, ocaml, c++, python
21:42
BlaXpirit has quit [Quit: Quit Konversation]
21:43
<
jhass >
ah, so no ruby background. Like the syntax anyway? :P
21:44
<
blAckEn3d >
well, I was always intrigued by Ruby, but never had time to give it a serious go. so far I mostly like the syntax
21:57
blAckEn3d has quit [Remote host closed the connection]
22:09
bcardiff1 has joined #crystal-lang
22:09
bcardiff2 has joined #crystal-lang
22:11
bcardiff has quit [Ping timeout: 244 seconds]
22:13
bcardiff1 has quit [Ping timeout: 264 seconds]
22:15
bcardiff2 has quit [Ping timeout: 244 seconds]
22:15
zamith has joined #crystal-lang
22:20
zamith has quit [Ping timeout: 256 seconds]
22:21
zamith has joined #crystal-lang
22:21
jua_ has quit [Quit: Vision[0.9.7-H-20140108]: i've been blurred!]
22:29
zamith has quit [Ping timeout: 256 seconds]
22:46
zamith has joined #crystal-lang
22:51
zamith has quit [Ping timeout: 255 seconds]
22:53
dhruv_ has joined #crystal-lang
22:54
<
dhruv_ >
what is the correct way to close HTTP::Server?
22:54
<
dhruv_ >
server.listen()
22:54
<
dhruv_ >
ctrl-c displays "process exited with error code 2"
23:05
<
jhass >
good question
23:07
<
jhass >
might try what happens when calling that in Signal.trap(Signal::INT)
23:07
<
strcmp1 >
it generates a better signal called SIGSEGV, probably
23:08
<
jhass >
well, it'll block until the next connection attempt if I read it right
23:08
<
jhass >
which then will still be handled and then it should exit cleanly
23:17
zamith has joined #crystal-lang
23:22
zamith has quit [Ping timeout: 252 seconds]
23:23
unshadow_ has joined #crystal-lang
23:24
unshadow_ has quit [Client Quit]
23:37
zamith has joined #crystal-lang
23:42
zamith has quit [Ping timeout: 256 seconds]