asterite changed the topic of #crystal-lang to: #crystal-lang The Crystal programming language | http://crystal-lang.org | Crystal 0.6.1 | 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
havenwood has joined #crystal-lang
Kache4 has quit [Quit: http://www.kiwiirc.com/ - A hand crafted IRC client]
DerisiveLogic_ has quit [Ping timeout: 276 seconds]
davissp14 has left #crystal-lang [#crystal-lang]
davissp14 has joined #crystal-lang
shama has quit [Quit: (╯°□°)╯︵ɐɯɐɥs]
strcmp1 has joined #crystal-lang
davissp14 has quit [Remote host closed the connection]
davissp14 has joined #crystal-lang
davissp14 has quit [Remote host closed the connection]
davissp14 has joined #crystal-lang
zipR4ND has joined #crystal-lang
strcmp1 has quit [Quit: Leaving]
zipR4ND has quit [Ping timeout: 276 seconds]
a5i has quit [Quit: Connection closed for inactivity]
davissp14 has quit [Remote host closed the connection]
davissp14 has joined #crystal-lang
havenwood has quit []
harisamin has joined #crystal-lang
davissp1_ has joined #crystal-lang
davissp14 has quit [Ping timeout: 250 seconds]
davissp1_ has quit [Remote host closed the connection]
endou_________ has joined #crystal-lang
endou________ has quit [Ping timeout: 252 seconds]
colorisco has quit [Ping timeout: 252 seconds]
hplar has quit [Ping timeout: 252 seconds]
harisamin has quit [Ping timeout: 252 seconds]
colorisco has joined #crystal-lang
davissp14 has joined #crystal-lang
hplar has joined #crystal-lang
davissp14 has quit [Ping timeout: 256 seconds]
BlaXpirit has joined #crystal-lang
leex_ has joined #crystal-lang
c355E3B_ has joined #crystal-lang
ryanf_ has joined #crystal-lang
hplar has quit [*.net *.split]
c355E3B has quit [*.net *.split]
ryanf has quit [*.net *.split]
leex has quit [*.net *.split]
c355E3B_ is now known as c355E3B
hplar has joined #crystal-lang
DerisiveLogic has joined #crystal-lang
hplar has quit [Ping timeout: 276 seconds]
hplar has joined #crystal-lang
DerisiveLogic has quit [Remote host closed the connection]
DerisiveLogic has joined #crystal-lang
BlaXpirit has quit [Read error: Connection reset by peer]
BlaXpirit has joined #crystal-lang
colorisco has quit [Ping timeout: 250 seconds]
Ven has joined #crystal-lang
JBat has joined #crystal-lang
ponga has joined #crystal-lang
havenwood has joined #crystal-lang
DerisiveLogic has quit [Ping timeout: 250 seconds]
Ven has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
Ven has joined #crystal-lang
colorisco has joined #crystal-lang
wanderer_ has joined #crystal-lang
strcmp1 has joined #crystal-lang
strcmp1 has quit [Client Quit]
strcmp1 has joined #crystal-lang
strcmp1 has quit [Remote host closed the connection]
strcmp1 has joined #crystal-lang
JBat has quit [Quit: Computer has gone to sleep.]
havenwood has quit [Remote host closed the connection]
Ven has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<wanderer_> jhass: hi, have you experienced an error like `can't execute `event = @event` at io\file_descriptor_io.cr:107:8`?
<jhass> no
<jhass> (and wb!)
<wanderer_> :)
<jhass> is there any more output?
<wanderer_> I've downloaded crystal's HEAD which uses libevent by default and I'm trying to get it running on windows
<wanderer_> there are no exceptions yet, so that's the only output
<jhass> it's a runtime error?
<wanderer_> on windows, libevent uses IOCP that work with the sockets API so a WSAStartup-call is needed
<wanderer_> when I don't call it, I get #[warn] evsig_init: socketpair: Successful WSAStartup not yet performed [WSANOTINITIALISED ]" after started the compiled & linked compiler, it also works
<wanderer_> so without WSAStartup the compiled compiler can compile itself again, with it, however, I get the error from above when trying to use the new compiled compiler
<wanderer_> for any source file
<wanderer_> but without WSAStartup libevent shouldn't work, I don't really know, though, I've never used it before
<jhass> it comes right out of the guts of the compiler, should be https://github.com/manastech/crystal/blob/master/src/compiler/crystal/semantic/after_type_inference_transformer.cr#L93 since it's the only one with no second arg in the call
<jhass> but that's all I can say about it
<jhass> so better prepare a reproducer for asterite :P
<wanderer_> after 0.6.1 the stdlib uses the scheduler by default, doesn't it? and the scheduler needs both libevent and libpcl?
<jhass> afaik, yeah
<wanderer_> ah, I know what I messed up: so far I haven't fully understood what's going on in the stdlib, so I'm sometimes using trial&error, like windows doesn't have fcntl, that's why I commented out the whole if-block in FileDescriptorIO#initialize, so it doesn't initialize @event which is why it's untyped later
<jhass> might still be a bug
<wanderer_> again, I don't have experience with non-blocking IO that's why I don't even know what's going on there /swt
<jhass> me neither really
<jhass> but yeah, an unassigned instance var should be (and typed as) nil
<jhass> so might still be a bug
<wanderer_> k, I'll write it down
<jhass> >> class Foo; def a; @a; end; end; Foo.a
<DeBot> jhass: Error in line 3: undefined method 'a' for Foo:Class
<jhass> >> class Foo; def a; @a; end; end; Foo.new.a
<DeBot> jhass: nil
<wanderer_> apparently, it's a runtime error, I've changed the src and it's still raised
<wanderer_> still reporting like 107, which is now a different one
<wanderer_> *line..
<jhass> well, if you modified code there's a good chance that it's reproducable on non-windows
<wanderer_> well, now I've commented out only the fnctl-calls and it seems to work, it shouldn't be non-blocking now, though
<jhass> mmh, nope, can still compile the compiler with a compiler compiled with it commented out
<wanderer_> yes, but does it work again?
<wanderer_> it's apparently a runtime error, so the freshly compiled compiler shouldn't work anymore
<wanderer_> at least for me it did not
<jhass> I commented it out, compiled a compiler and then compiled a compiler with the resulting compiler
<wanderer_> ah, k
wanderer_ has quit [Ping timeout: 246 seconds]
<strcmp1> jhass, so meta
<jhass> self-hosted compiler correctness test: compile the new code with the old compiler, compile the new code with the new compiler, compile the new code with the compiler from the last iteration, check that the result and the compiler before that have the same checksum
<jhass> meta enough? :P
Ven has joined #crystal-lang
a5i has joined #crystal-lang
Ven has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
Ven has joined #crystal-lang
dhruv has joined #crystal-lang
<dhruv> hello everyone! I need to instantiate a class from a string of its qualified name, eg "Mod.Classname". Is there a way to do this?
<jhass> no
<jhass> except doing a manual lookup table I guess
<jhass> but then you'll be quite limited on what you can call on the resulting object
<dhruv> that's a shame :( Any plans for adding this feature in the future?
<jhass> I doubt it, keep in mind that if a method call is valid is a compile time check
<jhass> so if the compiler doesn't know which type (=class) it is, it can't validate if your call is possible
<jhass> what do you need that for?
<dhruv> I'm working on a web framework and needed django style routing
<dhruv> Another quick question. can I pass functions/methods as method arguments?
<jhass> yes
<jhass> though you need to explicitly type them, at least on the method definition
<dhruv> that's not a problem. What's the syntax for that?
<jhass> and you might want to use a block instead
<jhass> it depends a bit on what you want exactly, there are 3-4 variants
<jhass> >> def foo; yield 1; end; foo {|i| "this is a normal block, it got the parameter #{i}" }
<DeBot> jhass: "this is a normal block, it got the parameter 1"
<dhruv> I need to pass a function to a class method which should be able to call it
<jhass> >> def foo(&block Int32 -> String; block.call(1); end; foo {|i| "this captures a block into a Proc object, so you can pass it around, it got the parameter #{i}" }
<DeBot> jhass: Syntax error in eval:3: expecting token ')', not 'Int32'
<jhass> >> def foo(&block : Int32 -> String; block.call(1); end; foo {|i| "this captures a block into a Proc object, so you can pass it around, it got the parameter #{i}" }
<DeBot> jhass: Syntax error in eval:3: expecting token ')', not ';'
<jhass> eh
Ven has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<strcmp1> missing a paren
<jhass> >> def foo(&block : Int32 -> String); block.call(1); end; foo {|i| "this captures a block into a Proc object, so you can pass it around, it got the parameter #{i}" }
<DeBot> jhass: "this captures a block into a Proc object, so you can pass it around, it got the parameter 1"
BlaXpirit_ has joined #crystal-lang
<jhass> >> def foo(proc : Int32 -> String); proc.call(1); end; foo(-> (i : Int32) { "this is a Proc literal, you can pass it around, it got the parameter #{i}" }
<DeBot> jhass: Syntax error in eval:4: expecting token ')', not 'end'
<jhass> not my day
<jhass> >> def foo(proc : Int32 -> String); proc.call(1); end; foo(-> (i : Int32) { "this is a Proc literal, you can pass it around, it got the parameter #{i}" })
<DeBot> jhass: "this is a Proc literal, you can pass it around, it got the parameter 1"
<jhass> >> def foo(fun : String ->); fun.call("this takes a pointer to a named function too"); end; foo(->puts(String))
<DeBot> jhass: Syntax error in eval:3: can't define fun inside def
BlaXpirit has quit [Ping timeout: 246 seconds]
<jhass> >> def foo(func : String ->); func.call("this takes a pointer to a named function too"); end; foo(->puts(String))
<DeBot> jhass: in /usr/lib/crystal/io.cr:339: undefined method 'inspect' for Void
<jhass> heh
<jhass> something like that at least
<dhruv> i get the idea. thanks
<jhass> a nice trick is to create an alias for your function signature
<jhass> alias MyCallback = String -> Bool; def fun(cb : MyCallback); cb.call("hey"); end
zipR4ND has joined #crystal-lang
Ven has joined #crystal-lang
Ven has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
Ven has joined #crystal-lang
panga has joined #crystal-lang
ponga has quit [Ping timeout: 256 seconds]
bcardiff has joined #crystal-lang
bcardiff has quit [Client Quit]
bcardiff has joined #crystal-lang
bcardiff has quit [Quit: Leaving.]
bcardiff has joined #crystal-lang
bcardiff has quit [Client Quit]
Ven has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
a5i has quit [Quit: Connection closed for inactivity]
Ven has joined #crystal-lang
JBat has joined #crystal-lang
<zipR4ND> hi, given i have a buffer (pointer) of UInt8 how can i convert this to a string converting bytes back to chars ... link String.bytes backwards ?
Ven has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<jhass> I think there's a String.new for it
<jhass> zipR4ND: http://crystal-lang.org/api/String.html even documented ;)
<zipR4ND> ok, think i tried that ... (been searching through string.cr alot ..)
<zipR4ND> if i use this i can print the string:
<zipR4ND> (0..n.value).each do |n|
<zipR4ND> LibC.printf("%02x:", buf[n])
<zipR4ND> end
<zipR4ND> where n is the length of the buffer
<zipR4ND> but i don't want to print it, i want to capture it into an array or string ...
<zipR4ND> i need the hexadecimal conversion (%2x in printf ..)
<jhass> >> "abc".codepoints
<DeBot> jhass: Error in line 3: undefined method 'codepoints' for String
<jhass> >> "abc".chars.map(&.ord.to_s(16)).join
<DeBot> jhass: "616263"
<jhass> like that?
<jhass> >> LibC.printf "%02x", "abc"
<DeBot> jhass: 8050844'\u{7}'
<jhass> mh
<zipR4ND> no
<zipR4ND> i need numbers to chars
<jhass> >> (0..16).map(&.to_s(16)).join
<DeBot> jhass: "0123456789ABCDEF10"
<zipR4ND> yes
<zipR4ND> hmm
<dhruv> how do I create a named block (for passing to a function)?
Ven has joined #crystal-lang
<zipR4ND> this is what i have: [154, 156, 67, 89, 47, 246, 233, 210, 162, 199, 65, 195, 218, 8, 54, 181, 61, 206, 176, 34, 0]
<zipR4ND> this is what i want:
<zipR4ND> 9a,9c,43,59,2f,f6,e9,d2,a2,c7,41,c3,da,08,36,b5,3d,ce,b0,22,00
<ytti> i don't think that is possible
<ytti> it would be "9a" etc
<ytti> numbers are not in any particular base, they are just numbers
<ytti> presentation you are calling becomes base10
<zipR4ND> ok, i got it the to_s(16) method does it indeed, thanks people :)
havenwood has joined #crystal-lang
ponga has joined #crystal-lang
Ven has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
panga has quit [Ping timeout: 245 seconds]
dhruv has quit [Quit: Leaving]
endou_ has joined #crystal-lang
irclogger_______ has quit [Ping timeout: 246 seconds]
vifino has quit [Ping timeout: 246 seconds]
vifino has joined #crystal-lang
irclogger_______ has joined #crystal-lang
Excureo has quit [Read error: Connection reset by peer]
Excureo has joined #crystal-lang
orliesaurus has quit [*.net *.split]
endou has quit [*.net *.split]
DerisiveLogic has joined #crystal-lang
Ven has joined #crystal-lang
<zipR4ND> hi, another question: im writing C-lib bindings. I have the type: STACK_OF (openssl library), how can i use it in my function bindings?
<zipR4ND> i have this signature: int SSL_get0_chain_certs(SSL *ssl, STACK_OF(X509) **sk);
<jhass> zipR4ND: that looks like a macro or a typedef
<jhass> you need to figure out the real type
orliesaurus has joined #crystal-lang
<zipR4ND> jhass: thanks. right now i define an empty struct, to just pass the thing around openssl functions until i get something i can use ..#
yawniek has quit [Ping timeout: 264 seconds]
a5i has joined #crystal-lang
<jhass> if you don't need to allocate it or modify it with regular struct operations, you can just use Void* or an alias to that
JBat has quit [Quit: Computer has gone to sleep.]
yawniek has joined #crystal-lang
<colorisco> hi, What is the potential advantage of crystal over other programming languages(rust)?
<colorisco> or meaning feature for you
<jhass> few to no type annotations while still having a statically typed language
<colorisco> where can find info about mutithreading in crystal
<colorisco> or samples
<jhass> no docs so far that I'm aware of
<jhass> we do have a Thread class pretty much as you know it from Ruby, that wraps pthreads
<jhass> HEAD is currently porting the default IO class to an evented IO model backed by libevent and libpcl
<jhass> so you'll also have a similar concurrency model like Go available
<a5i> jhass, remember GithubRepos.from_json(response.body).items.map {|repo| [repo.name, repo.description] }.to_a ?
<a5i> Now I'm looking to add another value next to description
<a5i> so its 1 key 2 values
<strcmp1> wrap the two values in an array
<a5i> so
<jhass> or keep proper objects
<strcmp1> a nested array
<strcmp1> yeah
<a5i> [repo.name, [repo.description, repo.foo]] ?
<strcmp1> that sounds better jhass
<jhass> [repo.name, repo]
<jhass> and actually better return tuples
<jhass> {repo.name, repo}
<a5i> I get this as the value
<a5i> #<GithubRepo:0x1007EA0 @name="crystal", @watchers_count=1466, @html_url="https://github.com/manastech/crystal", @description="The Crystal Programming Langua
<a5i> ge">
<a5i> Which has a changing memory address, so I can't work with that
<jhass> wat
<strcmp1> my thought as well ha
<a5i> are you confused by why I can;t use that?
<jhass> that's just the object representation, it's not a string
<strcmp1> i am confused why you couldn't use it, yeah
<strcmp1> it has all the properties you want
<jhass> do you even need access by name?
<jhass> access/lookup
<a5i> hmm
<a5i> I only wanted html_url
<a5i> jhass, I end up writing that hash to another file, would the #<GithubRepo> stuff show in that hash ?
<crystal-gh> [crystal] asterite pushed 1 new commit to master: http://git.io/vfiB4
<crystal-gh> crystal/master b1d8385 Ary Borenszweig: Simpler and earlier error message when a method specifies a return type
<jhass> a5i: no, json_mapping defines a proper to_json
<a5i> oh
<a5i> jhass, do when iterating through the hash, I can do value.html_urls ?
<a5i> so*
<jhass> try?
<a5i> jhass, value is nil, how can I specify it's type ?
<jhass> you can't just change the type of nil
<jhass> figure out where the nil comes from and make sure it isn't returned
Ven has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<travis-ci> manastech/crystal#2259 (master - b1d8385 : Ary Borenszweig): The build passed.
<a5i> jhass, is this correct btw, since I'm putting an object into the hash instead of a String now ?
<a5i> Hash(String, Object).from_json File.read("list.json")
<jhass> no, you want to use the specific type
<jhass> so, all you want to remember is which repos you already tweeted, right?
_whitelogger has joined #crystal-lang
<a5i> and the compiler says unexpected being_object which means it should be an Object
<jhass> json object != Object
<a5i> well then what is it :/
_whitelogger has joined #crystal-lang
DerisiveLogic has quit [Ping timeout: 245 seconds]
<jhass> yeah, maybe use Ruby
<a5i> the other issue for the 2nd impl with the nested array is that value is nil, which I haven't yet found why it is
<a5i> I am using ruby for some of the code
<a5i> anyhow sorry for the indentation, github messes it up for me
<strcmp1> your editor just lies to you :P
<jhass> you just need to set your editor to use spaces and 2 spaces
<jhass> so why not do everything in Ruby
<a5i> Because I want to use Crystal, and get more familiar with it and it's types
<a5i> the Ruby part is the tweeting part
<jhass> tab size != use spaces
<a5i> Can't seem to find spaces
<a5i> but it surely doesnt space it out like what that gist is showing you
<jhass> yes, editors are usually configurable about the width they use to show a tab
<jhass> that's what you configured there
<a5i> nvm just found it
<a5i> okay, any idea on how and why value is nil here ?
<jhass> no, I'm not going to reverse engineer what that's doing
<jhass> or if you even interpreted the error message you get correctly
havenwood has quit []
HakanD has quit [Quit: Be back later ...]
strcmp1 has quit [Ping timeout: 272 seconds]
<a5i> finally got it to work
<a5i> ended up trashing the hash iteration, turned res into an array
<a5i> apprently its a 3d array
<a5i> but a small one so im not worried
<a5i> God I'm horrible :(
dhruv has joined #crystal-lang
havenwood has joined #crystal-lang
<dhruv> I'm working on a web framework for Crystal, check it out https://github.com/dhruvrajvanshi/Moonshine
<jhass> dhruv: you can use ```crystal code fences already ;)
<a5i> my contab aint working :(
<a5i> crontab
<jhass> I wonder if we should define something like rack early on
<jhass> oh the time..
havenwood has quit [Remote host closed the connection]
strcmp1 has joined #crystal-lang
gmathe has joined #crystal-lang
<gmathe> hey i got a question, is crystal good to learn as a beginner programmer?
<strcmp1> maybe not, just because there's not a whole lot of documentation and the language is still new.
<a5i> gmathe, if you learn Ruby then you'll pick up Crystal in 1.7 seconds
<shadeslayer> heh
<a5i> next release of crystal will have specified return types for methods ?
havenwood has joined #crystal-lang
<jhass> gmathe: but indeed, start with Ruby, less concepts to grasp, lots of resources oriented to programming beginners and easy to learn Crystal afterwards
vifino has joined #crystal-lang
<gmathe> isn't ruby mostly used for web purposes
<strcmp1> professionally, yeah
<jhass> it's still a general purpose programming language, that just means that the ecosystem is stronger in that area
<strcmp1> i don't do anything with web+ruby, and i still write a lot of ruby. it's not professional though, just open source hacks.
zipR4ND has quit [Ping timeout: 264 seconds]
shama has joined #crystal-lang
gmathe has quit [Remote host closed the connection]
<shadeslayer> what
<shadeslayer> strcmp1: I think you're juding ruby on the wrong criteria
<shadeslayer> I use it heavily to write backend code
<shadeslayer> nothing to do with websites, but building distributions
<strcmp1> just speaking from personal experience, i had a few jobs doing ruby and all of 'em were web focused.
havenwood has quit [Remote host closed the connection]
<shadeslayer> strcmp1: the ecosystem is doing lots of web stuff sure
<strcmp1> id say the ecosystem is probably doing less web stuff overall, just that if you want to get a job doing ruby you're probably looking at using rails/some web framework.
<strcmp1> more often than that it's rails.
<strcmp1> i dont disagree ruby is useful beyond that tho :)
DerisiveLogic has joined #crystal-lang
dhruv has quit [Ping timeout: 256 seconds]
<ponga> looking forward to crystal 1.0.0
<a5i> that seems like a long way lol
BlaXpirit_ has quit [Quit: Quit Konversation]
wanderer_ has joined #crystal-lang
<strcmp1> haha
a5i is now known as vikaton
wanderer_ has quit [Quit: Page closed]
ponga has quit [Remote host closed the connection]
shama has quit [Remote host closed the connection]