jhass changed the topic of #crystal-lang to: The Crystal programming language | http://crystal-lang.org | Crystal 0.7.2 | 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
DerisiveLogic has joined #crystal-lang
vikaton has quit []
datanoise has joined #crystal-lang
havenwood has quit [Quit: Textual IRC Client: www.textualapp.com]
Liothen has quit [Ping timeout: 276 seconds]
shama has quit [Quit: (╯°□°)╯︵ɐɯɐɥs]
ismaelga has joined #crystal-lang
JBat has joined #crystal-lang
Cidan is now known as zz_Cidan
datanoise has quit [Quit: leaving]
datanoise has joined #crystal-lang
havenwood has joined #crystal-lang
bcardiff has joined #crystal-lang
ismaelga has quit [Remote host closed the connection]
DerisiveLogic has quit [Ping timeout: 265 seconds]
DerisiveLogic has joined #crystal-lang
Liothen has joined #crystal-lang
havenwood has quit [Ping timeout: 250 seconds]
BlaXpirit has joined #crystal-lang
ponga has joined #crystal-lang
datanoise has quit [Ping timeout: 245 seconds]
jua_ has joined #crystal-lang
datanoise has joined #crystal-lang
<unshadow> Thats funny, the IPSocket default is IPV6 ?
<jhass> what do you mean?
<jhass> it's AF_UNSPEC, so whatever your system configuration prefers comes first
<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")"
<unshadow> @family="AF_INET6"
<jhass> oh, TCPSocket
<unshadow> yeha .. sorry I wrote IPSocket
<unshadow> isn't that wierd ?
<jhass> so, on modern linux that listens to both, v4 and v6 and you get those mapped addresses for v4 traffic
<unshadow> yeha, I can see that I have both ::ffff and 127.0.0.1
<jhass> so listening to v6 by default gets you the broader compatibility in fact
<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 ?
<jhass> as said, it's the default for modern linux
bcardiff has quit [Quit: Leaving.]
<unshadow> btw, I got t.alive? to work, though I get segfault here and now XD Maybe i'll use your suggestion
<unshadow> If I get Process.pid != Thread id right ? there could be multiple threads under the same process right ?
<unshadow> ignore "If I get"
<jhass> I think so, yeah
<jhass> check pthread_self
datanoise has quit [Ping timeout: 240 seconds]
ponga has quit [Quit: Leaving...]
BlaXpirit has quit [Quit: Quit Konversation]
BlaXpirit has joined #crystal-lang
datanoise has joined #crystal-lang
datanoise has quit [Ping timeout: 252 seconds]
DerisiveLogic has quit [Ping timeout: 264 seconds]
Codcore has joined #crystal-lang
<Codcore> Hello, how to properly to redefine assign method? I tried def = () but it doesn't work
<jhass> it's not a method
<Codcore> Oh...
<jhass> a = b doesn't involve a method call, only a.b = c does
<jhass> the latter is syntax sugar for a.b=(c)
<jhass> so calling the method b= on a
<Codcore> Got it, thanks!
<Codcore> is it some perfomance benefits for using "getter :headers" instead "getter headers"?
<BlaXpirit> Codcore, it's exactly the same
<jhass> no, that's evaluated at compile time
<jhass> well, SymbolLiteral vs idk, Call?
<jhass> but the code that's generated is the same, yeah
<BlaXpirit> i assume .id is called on the argument which makes it exactly the same
<BlaXpirit> but not the same in general
<Codcore> jhass, BlaXpirit thank you for answers
<unshadow> Again, I won the compiler ;)
<unshadow> jhass: got thread.alive? work with the method you suggested (pthread.kill(t, 0)) looks good and no segfaults
<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 ?
<jhass> why not open a PR? add some specs to make it more changes :P
<unshadow> hahah
<unshadow> Oh well.. I'll fork and change
vikaton has joined #crystal-lang
zamith has joined #crystal-lang
<zamith> How can I translate this "typedef void* (*GumboAllocatorFunction)(void* userdata, size_t size);" into crytal's C binding dsl?
datanoise has joined #crystal-lang
<crystal-gh> [crystal] bararchy opened pull request #712: Thread.alive? (master...master) http://git.io/vk2Yd
datanoise has quit [Ping timeout: 276 seconds]
ismaelga has joined #crystal-lang
<unshadow> jhass: about the removing ==, what do you mean its already returs boolean ?
<jhass> >> "a" == "b"
<DeBot> jhass: # => false - http://carc.in/#/r/zo
<jhass> >> "a" == "a"
<DeBot> jhass: # => true - http://carc.in/#/r/zp
<jhass> >> ("a" == "a").class
<DeBot> jhass: # => Bool - http://carc.in/#/r/zq
<unshadow> hhhhh
<unshadow> ok
<unshadow> Done.
<unshadow> anything else ?
<jhass> nothing important, I like be_true and be_false
<unshadow> yeha, its cool but I tried to keep the same style of the former spec tests
<jhass> zamith: mmh, I still suck at reading C function type declarations
<zamith> I went with Void*, because I don't know how to do it properly
<zamith> would love to understand it though :/
<jhass> alias GumboAllocatorFunction = (Void*, LibC::SizeT) -> Void* ?
<jhass> idk
<zamith> alias or type?
<zamith> I saw type being used a couple of times throughout the core
<jhass> ah, another one where I still don't know the exact difference, I think both should work
<jhass> I somehow always used alias so far
<zamith> ok, thanks
BlaXpirit_ has joined #crystal-lang
BlaXpirit has quit [Killed (hitchcock.freenode.net (Nickname regained by services))]
<unshadow> >> gets("\r\n\r\n")
<DeBot> unshadow: Error in line 4: no overload matches 'gets' with types String - http://carc.in/#/r/zr
<unshadow> >> gets('\r')
<DeBot> unshadow: Sorry, that took too long. - http://carc.in/#/r/zs
<unshadow> thats kinda stupid, if I want to specify a delimiter which is 4 null, "\0\0\0\0" why to force a char ?
alexmikitenko has joined #crystal-lang
alexmikitenko has quit [Client Quit]
<BlaXpirit> if the whole function body is written in a header file, I think it is not included in the library file
<BlaXpirit> so I can't use it in crystal
<BlaXpirit> is that correct?
Codcore has quit [Ping timeout: 246 seconds]
<jhass> no experiences, I'd say 50/50 chance
<jhass> mh, actually the header is just included into the .c on build, it's treated like one file by the C compiler
<BlaXpirit> i would just try this, but it's not that quick
<jhass> thinking about it, I'd say 80% chance it's in the .so
<BlaXpirit> what if it also says inline?
<jhass> oh, then 5% chance (because I might miss something, my C is weak)
<jhass> inline means don't generate the function, replace the calls by the body
<jhass> afaik
<BlaXpirit> yup, no such function
<BlaXpirit> so then, if i make bindings then i must write this function in crystal code
<BlaXpirit> and I can't include it inside the namespace of the lib
<BlaXpirit> just completely no way
<BlaXpirit> this is really not nice
datanoise has joined #crystal-lang
datanoise has quit [Ping timeout: 264 seconds]
bcardiff has joined #crystal-lang
havenwood has joined #crystal-lang
<unshadow> >> a = "test::more"; b = a.split("::"); puts b
<DeBot> unshadow: ["test", "more"] - more at http://carc.in/#/r/zw
<unshadow> >> a = "testmore"; b = a.split("::"); puts b
<DeBot> unshadow: ["testmore"] - more at http://carc.in/#/r/zx
Codcore has joined #crystal-lang
<Codcore> first pre-release of my web framework written in Crystal =) https://github.com/Codcore/Amethyst/releases/tag/v0.0.2
<jhass> cool!
ismaelga has quit [Remote host closed the connection]
<unshadow> Codcore: nice !
<unshadow> So, for my next trick, Process.setsid :)
<jhass> I have setuid laying around
<unshadow> so why dont you add setuid and setsid and create a PR ?
<jhass> because I'm lazy
<unshadow> XD
<unshadow> btw, I think fork do my be broken, or at least makes the compiler crazy
<unshadow> >> defined?(a)
<DeBot> unshadow: Error in line 4: undefined local variable or method 'a' - http://carc.in/#/r/zy
<unshadow> >> is_defined?(a)
<DeBot> unshadow: Error in line 4: undefined local variable or method 'a' - http://carc.in/#/r/zz
<jhass> >> "happy #{"100".to_i64(36)} pastes!"
<DeBot> jhass: # => "happy 1296 pastes!" - http://carc.in/#/r/100
ismaelga has joined #crystal-lang
<unshadow> jhass: what are we going to do with Thread.alive? then?, should I retry using pthread_tryjoin_np ?
<jhass> dunno, look up on the portability of that one first. might just have to maintain our own flag :/
<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.
<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 ?
<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)
<jhass> *thread
<unshadow> Oh, that sounds like alot of work
<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 ?
<unshadow> and from there on the GC, Thread.join,kill,finalize etc.. will need to see and understand that flag right ?
<unshadow> >> t = Thread.new; p t
<DeBot> unshadow: Error in line 4: wrong number of arguments for 'Thread(T, R)#initialize' (0 for 1) - http://carc.in/#/r/103
<unshadow> >> t = Thread.new { a = 5}; p t
<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
<unshadow> >> t = Thread.new { a = 5}; puts pointerof(t)
<DeBot> unshadow: Pointer(Thread(Nil, Int32))@0xbff23784 - more at http://carc.in/#/r/105
<unshadow> Can't we just check if the pointer is a Thread pointer or just cleaned by GC ?
<unshadow> >> t = Thread.new { a = 5}; check = pointerof(t); puts alive if check.is_a?(Pointer(Thread(Nil, Int32)))
<DeBot> unshadow: Error in line 4: undefined local variable or method 'alive' - http://carc.in/#/r/106
<unshadow> >> t = Thread.new { a = 5}; check = pointerof(t); puts "alive" if check.is_a?(Pointer(Thread(Nil, Int32)))
<DeBot> unshadow: alive - more at http://carc.in/#/r/107
<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)))
<DeBot> unshadow: alive - more at http://carc.in/#/r/108
<unshadow> or something ....
<Codcore> how to transform float from exponential representation to dotted one?
<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)))
<DeBot> unshadow: Error in line 4: undefined constant T - http://carc.in/#/r/109
vikaton has quit []
datanoise has joined #crystal-lang
ismaelga has quit [Remote host closed the connection]
datanoise has quit [Ping timeout: 256 seconds]
ismaelga has joined #crystal-lang
jua_ has quit [Ping timeout: 264 seconds]
datanoise has joined #crystal-lang
jua_ has joined #crystal-lang
<BlaXpirit> i think Int is always 32
vikaton has joined #crystal-lang
<jhass> wouldn't we get a ton of segfaults if so?
<BlaXpirit> jhass, well i dunno, first of all i've never seen these used
<BlaXpirit> and maybe those who did use it had 64 bit systems
<jhass> only a few specs are failing on 32 bit
<jhass> still didn't find a way to run a 32bit CI build :/
bcardiff has quit [Quit: Leaving.]
Codcore has quit [Ping timeout: 246 seconds]
bcardiff has joined #crystal-lang
<vikaton> how is windows going for Crystal?
<vikaton> BlaXpirit: Is it ready for windows or not yet?
<BlaXpirit> i really don't know
<BlaXpirit> the main thing we see at the link is it's not stagnant
havenwood has quit [Quit: Textual IRC Client: www.textualapp.com]
zamith has quit [Quit: Be back later ...]
zamith has joined #crystal-lang
ismaelga has quit [Remote host closed the connection]
ismaelga has joined #crystal-lang
bcardiff1 has joined #crystal-lang
bcardiff has quit [Ping timeout: 250 seconds]
zz_Cidan is now known as Cidan
havenwood has joined #crystal-lang
<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"
<unshadow> Aborted (core dumped)
<unshadow> the code itself is pretty simple, but I cant understand the err
dhruv has joined #crystal-lang
<dhruv> How can I kill a process by pid?
<dhruv> In ruby, you can do Process.kill 9, pid
<jhass> I think you still have to bind the syscall
<jhass> lib LibC; fun kill(pid : Int32, signal : LibC::IntT); end;
<jhass> an enum for the signals is there
<jhass> well, constants
<jhass> Signal::TERM
<jhass> wrap that up in a method on Process and it's a nice PR :)
<dhruv> will do, thanks
<dhruv> how can I typecast int32 to Int64?
ismael_ has joined #crystal-lang
ismaelga has quit [Ping timeout: 276 seconds]
<jhass> >> 42 as Int64
<DeBot> jhass: Error in line 4: can't cast Int32 to Int64 - http://carc.in/#/r/10l
<jhass> mh
<jhass> >> Int64.cast(42)
<DeBot> jhass: # => 42 - http://carc.in/#/r/10m
<jhass> >> Int64.cast(42).class
<DeBot> jhass: # => Int64 - http://carc.in/#/r/10n
<jhass> well, I guess it does convert under the hood there :P
<jhass> >> 42.to_i64
<DeBot> jhass: # => 42 - http://carc.in/#/r/10o
<jhass> prolly the same
<unshadow> 42.to_i64.class
<unshadow> >> 42.to_i64.class
<DeBot> unshadow: # => Int64 - http://carc.in/#/r/10p
<jhass> should rename .cast to .convert I guess
<unshadow> >> a,b, = 1,2 if true
<DeBot> unshadow: Syntax error in eval:4: unexpected token: = - http://carc.in/#/r/10q
<unshadow> >> a,b = 1,2 if true
<DeBot> unshadow: # => 2 - http://carc.in/#/r/10r
<unshadow> I hate working on Saturday :(
<strcmp1> ha
<strcmp1> im doing the same
<strcmp1> do you work from home?
<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
JBat has quit [Quit: Computer has gone to sleep.]
<unshadow> strcmp1: are you in the office right now ?
<unshadow> I mean at work *
<strcmp1> no, i work from home too
<unshadow> nice
bcardiff has joined #crystal-lang
bcardiff1 has quit [Ping timeout: 272 seconds]
<unshadow> >> puts "a" rescue nil
<DeBot> unshadow: a - more at http://carc.in/#/r/10s
<unshadow> >> raise "a" rescue nil
<DeBot> unshadow: # => nil - http://carc.in/#/r/10t
<unshadow> >> raise "a" rescue nil if true
<DeBot> unshadow: # => nil - http://carc.in/#/r/10u
<unshadow> nice
<jhass> :/
<jhass> inline rescue could have been gone IMO
<unshadow> I know I know
<unshadow> it's just for a ensure on socket.close
<strcmp1> it's one of those things that's useful when you're doing a quick hack
<jhass> mmh, do we allow restrictions?
<jhass> >> raise ArgumentError.new rescue ArgumentError nil
<DeBot> jhass: Syntax error in eval:4: unexpected token: nil - http://carc.in/#/r/10v
<jhass> >> raise ArgumentError.new rescue e : ArgumentError nil
<DeBot> jhass: Syntax error in eval:4: unexpected token: : - http://carc.in/#/r/10w
<jhass> :(
<BlaXpirit> >> raise ArgumentError.new; rescue e : ArgumentError; nil end;
<DeBot> BlaXpirit: Syntax error in eval:8: expecting token 'EOF', not 'rescue' - http://carc.in/#/r/10x
<BlaXpirit> >> begin; raise ArgumentError.new; rescue e : ArgumentError; nil end;
<DeBot> BlaXpirit: # => nil - http://carc.in/#/r/10y
<jhass> yeah, ; in real code is as ugly :P
<unshadow> its not real oneliner
<unshadow> :)
bcardiff has quit [Ping timeout: 272 seconds]
bcardiff has joined #crystal-lang
<unshadow> a.is_a?(Array) feels bad, should be a.is_an?(Array) ;)
<jhass> well, that's why Ruby core is adopting a strict infinitive policy
<jhass> .include?, .exist? etc
<jhass> because it's not english after all, it just looks a whole lot like it
dhruv has quit [Ping timeout: 272 seconds]
<strcmp1> i prefer Array === a.
<jhass> :(
<jhass> === is for case, nothing else
<strcmp1> :))
<unshadow> :\
<unshadow> >> a = [1,2,3]; a === Array
<DeBot> unshadow: # => false - http://carc.in/#/r/10z
<unshadow> >> a = [1,2,3]; Array === a
<DeBot> unshadow: # => false - http://carc.in/#/r/110
<jhass> huh
<unshadow> >> a = [1,2,3]; a == Array
<DeBot> unshadow: # => false - http://carc.in/#/r/111
<unshadow> >> a = [1,2,3]; a.is_a?(Array)
<DeBot> unshadow: # => true - http://carc.in/#/r/112
<jhass> >> a = [1, 2, 3]; case a; when Array; puts "hey"; end;
<DeBot> jhass: hey - more at http://carc.in/#/r/113
<unshadow> for a sec I thought your bot got crazy
<strcmp1> in crystal, === is not an option then :)
<jhass> weird
<jhass> bug IMO
<unshadow> strcmp1: you said it, you open an issue XD
<strcmp1> okay
<unshadow> I opened too many lately, I think asterite will just start ignoring my issues hhaha
ismael_ has quit [Remote host closed the connection]
<jhass> nah, he didn't have to debug a program you wrote for 3 hours yet :P
<unshadow> XD
<jhass> (to be fair it uncovered 3-4 bugs in the compiler)
<BlaXpirit> my issues seem to have gone pretty well
Cidan is now known as zz_Cidan
DerisiveLogic has joined #crystal-lang
bcardiff has quit [Ping timeout: 264 seconds]
bcardiff has joined #crystal-lang
bcardiff1 has joined #crystal-lang
bcardiff has quit [Ping timeout: 272 seconds]
bcardiff1 has quit [Read error: Connection timed out]
bcardiff has joined #crystal-lang
zamith has quit [Quit: Be back later ...]
blAckEn3d has joined #crystal-lang
blAckEn3d has quit [Client Quit]
blAckEn3d has joined #crystal-lang
<blAckEn3d> hi. just wanted to say that I tried crystal today and it's a great language :). thanks for the hard work.
<jhass> :)
<jhass> what's your background?
<blAckEn3d> kind of mixed: lisp, ocaml, c++, python
BlaXpirit has quit [Quit: Quit Konversation]
<jhass> ah, so no ruby background. Like the syntax anyway? :P
<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
<jhass> cool
blAckEn3d has quit [Remote host closed the connection]
bcardiff1 has joined #crystal-lang
bcardiff2 has joined #crystal-lang
bcardiff has quit [Ping timeout: 244 seconds]
bcardiff1 has quit [Ping timeout: 264 seconds]
bcardiff2 has quit [Ping timeout: 244 seconds]
zamith has joined #crystal-lang
zamith has quit [Ping timeout: 256 seconds]
zamith has joined #crystal-lang
jua_ has quit [Quit: Vision[0.9.7-H-20140108]: i've been blurred!]
zamith has quit [Ping timeout: 256 seconds]
zamith has joined #crystal-lang
zamith has quit [Ping timeout: 255 seconds]
dhruv_ has joined #crystal-lang
<dhruv_> what is the correct way to close HTTP::Server?
<dhruv_> server.listen()
<dhruv_> ctrl-c displays "process exited with error code 2"
<jhass> good question
<jhass> might try what happens when calling that in Signal.trap(Signal::INT)
<strcmp1> it generates a better signal called SIGSEGV, probably
<jhass> :P
<jhass> well, it'll block until the next connection attempt if I read it right
<jhass> which then will still be handled and then it should exit cleanly
<jhass> in theory
zamith has joined #crystal-lang
zamith has quit [Ping timeout: 252 seconds]
unshadow_ has joined #crystal-lang
unshadow_ has quit [Client Quit]
zamith has joined #crystal-lang
zamith has quit [Ping timeout: 256 seconds]