jhass changed the topic of #crystal-lang to: The Crystal programming language | http://crystal-lang.org | Crystal 0.7.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
bcardiff has quit [Quit: Leaving.]
leafybas_ has joined #crystal-lang
leafybasil has quit [Ping timeout: 258 seconds]
<vikaton> jhass, why doyu have user-agent as crystalshards ?
leafybas_ has quit [Ping timeout: 264 seconds]
Cidan is now known as zz_Cidan
shama has quit [Remote host closed the connection]
shama has joined #crystal-lang
JBat has joined #crystal-lang
JBat has quit [Quit: Computer has gone to sleep.]
shama has quit [Remote host closed the connection]
shama has joined #crystal-lang
bcardiff has joined #crystal-lang
zz_Cidan is now known as Cidan
shama has quit [Remote host closed the connection]
shama has joined #crystal-lang
DerisiveLogic has quit [Remote host closed the connection]
shama has quit [Quit: (╯°□°)╯︵ɐɯɐɥs]
DerisiveLogic has joined #crystal-lang
sandelius has joined #crystal-lang
DerisiveLogic has quit [Ping timeout: 240 seconds]
Nimble_Erni has joined #crystal-lang
Cidan is now known as zz_Cidan
BlaXpirit has joined #crystal-lang
bcardiff has quit [Quit: Leaving.]
<jhass> vikaton: hm?
unshadow has quit [Ping timeout: 272 seconds]
unshadow has joined #crystal-lang
<unshadow> jhass: do you think I shouldn't add the .so file to the repo in crystal-libinjection ?
<jhass> mh, no
<jhass> binary distribution via SCM sucks :P
<unshadow> so should I make some sory of a Makefile to clone, compile and set the file ? or something like that ?
<jhass> why not declare "this depends on libinjection, have it installed" ?
<unshadow> jhass: I guess that's a valid options also
sandelius has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
sandelius has joined #crystal-lang
leafybasil has joined #crystal-lang
Ven has joined #crystal-lang
Ven_ has joined #crystal-lang
Ven has quit [Read error: Connection reset by peer]
orliesaurus has quit [Excess Flood]
Guest65236 has joined #crystal-lang
Ven_ has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<unshadow> how does one writes a driver ? how can you for example make a laptop camera take a pic ? or a screen to dim (without using some api i mean)
Guest65236 has quit [Ping timeout: 264 seconds]
<jhass> you talk to the raw PCI/USB devices
a| has joined #crystal-lang
<jhass> it's just a connection & a protocol after all too
a| is now known as Guest22835
<unshadow> How do you talk to them, how do you do this final bridge between the software and the hardware ? can any languge do it ?
<unshadow> for example, I can see there is a USB driver (or lib) in ruby (https://github.com/larskanis/libusb/tree/master/lib/libusb) for it just wraps a c code using FFI https://github.com/larskanis/libusb/blob/master/ext/libusb-1.0.19/libusb/libusb.h which in it self wraps around OS based API's and calls
<jhass> in the monolithic kernel design like linux has it, you'll need a kernel driver that at least exposes stuff for a userspace driver
<jhass> doubt it's realistic to write a kernel driver in crystal
<unshadow> Can a kernel driver be only written in C ?
Guest22835 has quit [Ping timeout: 250 seconds]
<jhass> idk, I never did investigate much into that
<jhass> you're better off in ##linux or something
<unshadow> Thats interesting, I'll check there :)
<unshadow> I started reading "What every programmer should know about memory" , it gave me some thing to wonder about
a^ has joined #crystal-lang
ponga has joined #crystal-lang
<unshadow> Is I see that crystal init app and crystal init lib does exactly the same thing ha ?
<unshadow> jhass: topic saying Crystal 0.7.1
<jhass> unshadow: /msg ChanServ access #crystal-lang list
<unshadow> Oh... becuase -!- Topic set by jhass [~jhass@aeshna.de] [Sat May 9 03:24:04 2015]
<jhass> yeah, since reasons...
<unshadow> ok. waj, bcardiff or asterite , Topic needs to be changed
Ven has joined #crystal-lang
Ven has quit [Ping timeout: 244 seconds]
BlaXpirit has quit [Read error: Connection reset by peer]
BlaXpirit has joined #crystal-lang
ismaelga has joined #crystal-lang
Ven has joined #crystal-lang
strcmp1 has quit [Remote host closed the connection]
havenwood has joined #crystal-lang
<unshadow> What would you say is the best config file parser ? I used TOML until now but I heard that there are better ones out there, I personally kinda hate XML's.
<jhass> I yet have to try toml, but I think I like it better if the target audience is end users
<jhass> if the target audience is devs I wouldn't bother the dep and use json
<unshadow> I want to create something in the background to work with a Web front, DB is an overkill as I only have like 5-10 configurable values, you would recommend json for that ?
<jhass> or even just hardcode constants into your code
strcmp1 has joined #crystal-lang
<jhass> module Config; BASE_URL = "http://example.org"; ... end
<unshadow> But those will need to be changed sometimes via the web front
<jhass> or for carc.in's backend I do things like BASE_URL = ENV["BASE_URL"]? || "http://carc.in"
<jhass> well, then json, yeah
<jhass> that's what I do for debot
<jhass> json_mapping makes it easy
ismaelga has quit [Remote host closed the connection]
<unshadow> cool thanks, I'll give json a try
<unshadow> Does it also parses to a hash value ?
<unshadow> looking at the source I dont see a return value other then the Parser class
havenwood has quit [Quit: Textual IRC Client: www.textualapp.com]
bcardiff has joined #crystal-lang
<jhass> json_mapping maps (and defines) the classes attributes to json
<jhass> >> require "json"; class Foo; json_mapping({hello: String}); end; Foo.from_json(%({hello: "World"})).hello
<DeBot> jhass: JSON::ParseException: unexpected char 'h' at 1:2 - more at http://carc.in/#/r/s5
<jhass> heh
<jhass> >> require "json"; class Foo; json_mapping({hello: String}); end; Foo.from_json(%({"hello": "World"})).hello
<DeBot> jhass: # => "World" - http://carc.in/#/r/s6
<unshadow> lets say I have a file {'bar': 123}, I want to read the file and use it in the program, does JSON.parse(file) is the way to do that ?
<unshadow> require "json"; config = "{'bar': 123}"; test_json = JSON.parse(config); p test_json
<unshadow> >> require "json"; config = "{'bar': 123}"; test_json = JSON.parse(config); p test_json
<DeBot> unshadow: JSON::ParseException: unexpected char ''' at 1:2 - more at http://carc.in/#/r/sb
<jhass> you can do it, but it's cumbersome, hence json_mapping exists
<jhass> and json demands " for keys
<unshadow> >> require "json"; config = "{\"bar\": 123}"; test_json = JSON.parse(config); p test_json
<DeBot> unshadow: {"bar" => 123} - more at http://carc.in/#/r/sd
<unshadow> >> require "json"; config = "{\"bar\": 123}"; test_json = JSON.parse(config); puts test_json["bar"]
<DeBot> unshadow: Error in line 4: undefined method '[]' for Nil - http://carc.in/#/r/se
<unshadow> >> require "json"; config = "{\"bar\": 123}"; test_json = JSON.parse(config); puts test_json["bar"] if test_json
<DeBot> unshadow: Error in line 4: undefined method '[]' for Int64 - http://carc.in/#/r/sf
<unshadow> ffs
<jhass> that's why it's cumbersome ;)
<jhass> >> require "json"; config = "{\"bar\": 123}"; test_json = JSON.parse(config) as Hash(String, JSON::Type); puts test_json["bar"]
<DeBot> jhass: 123 - more at http://carc.in/#/r/sh
zamith has joined #crystal-lang
<zamith> Is there a way to write lambdas in crystal?
<zamith> or some sort of closure
<jhass> >> require "json"; config = "{\"bar\": 123}"; test_json = Hash(String, Int64).from_json(config); puts test_json["bar"]
<DeBot> jhass: 123 - more at http://carc.in/#/r/sk
<jhass> zamith: yup, -> { "I'm a proc!" }
<zamith> I how do I pass parameters in?
<jhass> >> greeter = -> name : String { "Hello #{name}" }; greeter.call("zamith")
<DeBot> jhass: Syntax error in eval:4: unexpected token: : - http://carc.in/#/r/sl
<jhass> heh
<jhass> >> greeter = -> (name : String) { "Hello #{name}" }; greeter.call("zamith")
<DeBot> jhass: # => "Hello zamith" - http://carc.in/#/r/sm
<zamith> thanks
<strcmp1> >> ->(n: String) { }.call(1)
<DeBot> strcmp1: Error in line 4: no overload matches '(String -> Nil)#call' with types Int32 - http://carc.in/#/r/sn
zamith has quit [Ping timeout: 265 seconds]
zamith_ has joined #crystal-lang
ismaelga has joined #crystal-lang
ismaelga has quit [Remote host closed the connection]
ismaelga has joined #crystal-lang
Ven has quit [Ping timeout: 256 seconds]
bcardiff1 has joined #crystal-lang
bcardiff has quit [Ping timeout: 246 seconds]
<unshadow> jhass: json is annoying ha ? https://github.com/manastech/crystal-toml/issues/1
jua_ has joined #crystal-lang
<unshadow> this should be warnings not errors ...
<jhass> well I guess somebody should contribute toml_mapping there ;)
<jhass> no
<jhass> that would just move those potential errors to runtime
<jhass> having them compile time makes your program a lot more robust
<BlaXpirit> i'm gonna need some help trying to use lib/bindings generator
<jhass> I doubt anybody besides their authors really used them :/
<BlaXpirit> cc: error: /Toolchains/XcodeDefault.xctoolchain/usr/lib: No such file or directory
<BlaXpirit> whatever, removed that line, it compiled
<BlaXpirit> oh, it actually attempts something but /usr/include/stdlib.h:32:10: fatal error: 'stddef.h' file not found
<unshadow> sometime the potential errors should be handeled by the developers, I know this is making me program a more stable software by making sure no type issues, but, sometime I am 100% sure of the type, or at lest dont care for errors, and those if ... if .. if... checks are very ugly in the code
<jhass> then use a cast as shown in the readme
<jhass> for type unions that's just a runtime check
<BlaXpirit> looks like both of these are intentionally limited to os x -_- https://github.com/manastech/crystal_lib https://github.com/fazibear/crystal_lib_gen
<jhass> I'd say s/limited/developed on/, which boils down to my earlier point, only tested/used by their authors
<BlaXpirit> so what can i do then
<BlaXpirit> probably best to make my own, huh
<jhass> stddef.h seems to be shipped by like every compiler, I guess instead of removing earlier line, you should replace it with the directory containing that file on your system
<unshadow> jhass: where in the readme ?
<jhass> unshadow: of crystal-toml? seriously?
havenwood has joined #crystal-lang
<BlaXpirit> jhass, oh that may be it
<vikaton> h
<jhass> unshadow: as Hash
<jhass> that's a cast
<unshadow> haaaa
<jhass> I showed that earlier for JSON.parse
<unshadow> owner = toml["owner"] as Hash
<unshadow> the f**k do I know what a cast is hahaha, yeha I remmber your example, I'll use that, thanks ;)
<unshadow> lets say I have pid_path = config["main_process"]["pid_path"], I did config = TOML.... as Hash, now, can I do "config["main_process"] as Hash["pid_path"] ?
<jhass> yeah
<unshadow> cool thanks
<jhass> might even be able to (x[y] as Hash)[z]
<jhass> never tried
<unshadow> can I do "12" as Int32 instead of "12".to_i ?
<unshadow> >> a = "12" as Int32; puts a.class
<DeBot> unshadow: Error in line 4: can't cast String to Int32 - http://carc.in/#/r/t1
<unshadow> oh
<jhass> conversion != casting
<jhass> casting is reinterpreting data as a different type, conversion is modifying data into a different type
<unshadow> this is better then 3 if's
<unshadow> daemon_port = ((config["main_process"] as Hash)["port"] as String).to_i
<jhass> I disagree, but oh well
<unshadow> tbh both are ugly :(
<unshadow> it feels like raping the language
<jhass> write toml_mapping ;)
DerisiveLogic has joined #crystal-lang
<unshadow> yeha.... can barly write a lib without half the crystal mailing list giving me a hand hahah
<unshadow> btw, there is .is_a?() is there a .is_not?()
<jhass> no, just !
<jhass> or use unless
<BlaXpirit> ./crystal_lib_gen:15:in `eval': undefined method `generate' for FFIGen:Class (NoMethodError)
<BlaXpirit> so i change to generate_cr
<BlaXpirit> but it's still an instance method
<BlaXpirit> so what the heck is this
<jhass> a bad example?
<BlaXpirit> i have no idea how to make this work
<jhass> just .new it?
<BlaXpirit> then it says argument number mismatch
<BlaXpirit> or something
<jhass> mmh, I guess there's just code missing
<jhass> yeah, looks like bad copy paste from a ruby gem https://github.com/fazibear/crystal_lib_gen/blob/master/bin/crystal_lib_gen
<BlaXpirit> what do u mean
<BlaXpirit> it IS ruby by the way
<jhass> oh
<BlaXpirit> i liked the most when it told me to install llvm with clang because some weird completely unnecessary 'bundler' is missing
<jhass> looks like it's extending a ruby gem
<jhass> how do you call it?
<BlaXpirit> oh.
<jhass> if you stubbed out the call to bundler that gem it extends is probably not loaded
<BlaXpirit> that explains a lot
<BlaXpirit> well sorry i didn't call brew install as the instructions say >_>
<BlaXpirit> oh wait, it's the bundle part
<BlaXpirit> gem install bundle worked great. then i get bundle install to tell me to give it root password or install into a directory
<BlaXpirit> pls
<jhass> BlaXpirit: bundle install --path vendor/bundle
<BlaXpirit> well that's what I did initially, but don't know how to continue with it
<BlaXpirit> so ~/.gem/ruby/2.2.0/bin/bundle install --path ~/.gem/
<BlaXpirit> and it seems to work
<jhass> ah yeah, I still need to get anatolik to ship a /etc/profile.d/ that adds the path
<BlaXpirit> well, i arrived at the same error
<BlaXpirit> /usr/include/time.h:37:11: fatal error: 'stddef.h' file not found
<BlaXpirit> something with clang... but i don't know how to pass a flag to clang through all these opaque wrappers
<jhass> clang's cli is largely compatible to gcc's
<BlaXpirit> gotta have a -L/usr/include/linux somewhere, but where....
<jhass> so just -I
<jhass> -L is for the linker
<BlaXpirit> i mean -I but where?
<BlaXpirit> oh, this one actually has a place to add flags
<BlaXpirit> yay, different error now
<BlaXpirit> unknown type name 'size_t'
<BlaXpirit> gotta get rid of GCC headers somehow and replace them with clang
<jhass> /usr/lib/clang/3.6.1/include
<BlaXpirit> '-I/usr/lib/clang/3.5.1/include/'
<jhass> seems to work
<BlaXpirit> :D
<BlaXpirit> yaaaay, got it to work! thank you, jhass!
havenwood has quit [Quit: Textual IRC Client: www.textualapp.com]
<jhass> yw
<BlaXpirit> would be able to make the other one just as well if i knew where to pass flags
ponga has quit [Quit: Leaving...]
asterite has joined #crystal-lang
a^ is now known as orliesaurus
bcardiff has joined #crystal-lang
bcardiff1 has quit [Ping timeout: 265 seconds]
kulelu88 has joined #crystal-lang
zz_Cidan is now known as Cidan
<crystal-gh> [crystal] asterite pushed 3 new commits to master: http://git.io/vkC8d
<crystal-gh> crystal/master 69a73e1 Ary Borenszweig: Disallow more types in generics: Struct, Class, Proc, Tuple, Enum, StaticArray and Pointer. Fixes #701
<crystal-gh> crystal/master c3edbbd Ary Borenszweig: Specify type of Dependency @name. Fixes #699
<crystal-gh> crystal/master 6d0de91 Ary Borenszweig: The `method_missing` macro now also accepts just one argument, a call. The 3 arguments way will be deprecated and later removed.
kulelu88 has quit [Quit: Leaving]
asterite has quit [Quit: Page closed]
shama has joined #crystal-lang
<travis-ci> manastech/crystal#2381 (master - 6d0de91 : Ary Borenszweig): The build passed.
sandelius has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
<zamith_> I have a Void*, and want to cast it to a type, but as is not working? Any help?
zamith_ is now known as zamith
sandelius has joined #crystal-lang
<BlaXpirit> i should know this..
<BlaXpirit> zamith, Type.cast(that)
<zamith> hum...
<zamith> let me try
havenwood has joined #crystal-lang
<zamith> it says cast is not defined
<zamith> I changed Type to the type I want to cast it to
<BlaXpirit> zamith, it works only for C types
<BlaXpirit> otherwise the operation is nonsense
<zamith> Yes, it is a C type
<BlaXpirit> what kind of type do you want to cast it to?
<BlaXpirit> you must cast it to a pointer type probably
<BlaXpirit> and maybe `as` is the way to go after all
ismaelga has quit [Remote host closed the connection]
<zamith> It's a C struct
<BlaXpirit> zamith, you should cast a pointer to a pointer
<BlaXpirit> then .value
<BlaXpirit> that as Pointer(Type) or maybe Pointer(Type).cast(that)
<BlaXpirit> i'm just guessing though :/
<zamith> I can't find a cast method :/
<BlaXpirit> have u tried `as`?
<BlaXpirit> forget about cast
<jhass> what's your concrete code that's failing?
<zamith> p (node.v.element.children.data[0].value as LibGumbo::GumboNode).value.type
<zamith> well, let me get a gist
<zamith> just a moment
<BlaXpirit> well u haven't tried my suggestion
<BlaXpirit> (node.v.element.children.data[0] as Pointer(LibGumbo::GumboNode)).value
<BlaXpirit> that's the general idea, not sure if this exact code would work
<jhass> I think you can only cast pointers across types
<jhass> that is you can cast Foo* into Bar* but not Foo into Bar unless Foo < Bar
<jhass> you can also cast Foo|Bar into Foo and Bar of course
<jhass> so what's the error you get?
<jhass> if I had to guess, remove the inner .value and as LibGumbo::GumboNode*
<zamith> in ./src/gumbocr.cr:192: can't cast Void to LibGumbo::GumboNode
<zamith> p (node.v.element.children.data[0].value as LibGumbo::GumboNode).type
<jhass> yup, that confirms my guess
<BlaXpirit> will u finally try my 9 minute old suggestion
<zamith> yup that works
<zamith> BlaXpirit: was that what you meant?
<zamith> I must have misunderstand you
<jhass> Foo* is just pretty for Pointer(Foo)
<zamith> yes, I know that one ;)
sandelius has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
sandelius has joined #crystal-lang
<crystal-gh> [crystal] bcardiff pushed 1 new commit to master: http://git.io/vkWnI
<crystal-gh> crystal/master 3f41f26 Brian J. Cardiff: Add HTML::Builder#doctype
bcardiff has quit [Quit: Leaving.]
asterite has joined #crystal-lang
<asterite> !memo asterite hi
<DeBot> asterite: You can't leave memos for yourself ...
<asterite> Still working :-)
<asterite> !memo wanderer_ is there a way I can contact you? It would be nice to merge and make work the windows branch, so you don't have to keep synchronizing... I'm sure it must be painful
<DeBot> asterite: Added memo for wanderer_.
<jhass> uh, it takes regex btw
<jhass> !memo /aster.+/ useful to not match the tail
<DeBot> jhass: Added memo for /aster.+/.
<asterite> Awesome!
<strcmp1> !memo /str.+/ hello
<DeBot> strcmp1: Added memo for /str.+/.
<strcmp1> cool
<sandelius> asterite is there any roadmap on when Crystal will be "stable" enough? 6 month, this year, next year. I'm really looking forward to it, awesome job you all!
<asterite> :)
<asterite> sandelius: I don't know how to estimate that
<asterite> We probably need to make a list of things we want for 1.0
<sandelius> asterite well I understand that. If I ask you this then: What's your intentions with this project?
<asterite> Well, given this is a general purpose programming language, that's a difficult question to answer
<asterite> but I guess once we have something similar to Sinatra or Rails (but not that big) working, without bugs, we can consider we reached 1.0
<asterite> or we achieved a big milestone
<asterite> We have to continue Frank with @waj, but lately we didn't have much time
<asterite> We always go back to Frank and find bugs and things to improve, and that keeps pushing the language forward
<asterite> as well as other projects others are making, like jhass
<sandelius> asterite well that sound just right up my alley, I'll start fiddling with a sinatra/express.js thingy wingy.
<asterite> The intentions would be: a language that's fast for prototyping but ends up with efficient code, with out-of-the-box support for concurrency with coroutines and channels
<asterite> but we started the last part just recently, so there's still a lot of things to do
<sandelius> asterite if that happens, it's a dream come true
zamith has quit [Quit: Be back later ...]
asterite has quit [Quit: Page closed]
<travis-ci> manastech/crystal#2382 (master - 3f41f26 : Brian J. Cardiff): The build passed.
sandelius has quit [Quit: Textual IRC Client: www.textualapp.com]
jua_ has quit [Quit: Vision[0.9.7-H-20140108]: i've been blurred!]
ismaelga has joined #crystal-lang
ismaelga has quit [Remote host closed the connection]
ismaelga has joined #crystal-lang
ismaelga has quit [Remote host closed the connection]
ismaelga has joined #crystal-lang
ismaelga has quit [Remote host closed the connection]
ismaelga has joined #crystal-lang
jtarchie has joined #crystal-lang
jbomo has joined #crystal-lang
ismaelga has quit [Remote host closed the connection]
ismaelga has joined #crystal-lang
ismaelga has quit [Remote host closed the connection]
<BlaXpirit> i wonder if crystal doc should use $(git describe --tags --exact-match || git rev-parse HEAD)
<crystal-gh> [crystal] asterite pushed 2 new commits to master: http://git.io/vkltE
<crystal-gh> crystal/master 533da5e Ary Borenszweig: Use %vars in macros, and other fixes
<crystal-gh> crystal/master edf1358 Ary Borenszweig: Don't change File::Stat#mode. Fixes #703
ismaelga has joined #crystal-lang
ismaelga has quit [Remote host closed the connection]
ismaelga has joined #crystal-lang
<crystal-gh> [crystal] asterite pushed 1 new commit to master: http://git.io/vkl33
<crystal-gh> crystal/master 67b9da8 Ary Borenszweig: Fixed `File::Stat#inspect`, and made `File::Stat` a struct
ismaelga has quit [Remote host closed the connection]
ismaelga has joined #crystal-lang
vikaton has quit []
vikaton has joined #crystal-lang
jbomo has quit [Ping timeout: 240 seconds]
jbomo has joined #crystal-lang
jbomo has left #crystal-lang [#crystal-lang]
<travis-ci> manastech/crystal#2384 (master - 67b9da8 : Ary Borenszweig): The build passed.
bcardiff has joined #crystal-lang
BlaXpirit has quit [Quit: Quit Konversation]