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
bcardiff has joined #crystal-lang
havenwood has quit []
ponga has joined #crystal-lang
ponga has quit [Remote host closed the connection]
bcardiff has quit [Quit: Leaving.]
shama has quit [Quit: (╯°□°)╯︵ɐɯɐɥs]
ponga has joined #crystal-lang
ponga has quit [Ping timeout: 264 seconds]
havenwood has joined #crystal-lang
strcmp1 has quit [Ping timeout: 256 seconds]
a5i has quit [Quit: Connection closed for inactivity]
DerisiveLogic has quit [Ping timeout: 255 seconds]
BlaXpirit has joined #crystal-lang
bcardiff has joined #crystal-lang
bcardiff has quit [Quit: Leaving.]
Ven has joined #crystal-lang
BlaXpirit_ has joined #crystal-lang
BlaXpirit has quit [Ping timeout: 244 seconds]
havenwood has quit [Remote host closed the connection]
ponga has joined #crystal-lang
ponga has joined #crystal-lang
HakanD__ has joined #crystal-lang
HakanD__ has quit [Ping timeout: 248 seconds]
Ven has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
HakanD__ has joined #crystal-lang
ponga has quit [Remote host closed the connection]
colorisco has joined #crystal-lang
<BlaXpirit_> dang it, i can't implement class method constructors as discussed yesterday
<BlaXpirit_> what I do is call allocate and then call a method that sets the instance variables
<BlaXpirit_> the problem: the type of the instance variables is now nillable
ponga has joined #crystal-lang
<jhass> yeah, initialize is special cased on the compiler for tracking these
ponga has quit [Remote host closed the connection]
<BlaXpirit_> what can be done then?
<BlaXpirit_> seems like a critical problem in the language to me
<jhass> depends, what's the relevant code? (both constructors)
<jhass> can't you add initialize(@this, @owned) and go through that?
<BlaXpirit_> jhass, uhhhh that's kinda wrong
<jhass> well, you should be able to make the corresponding new private at the same time, in some way
<BlaXpirit_> does that work with modules?
<jhass> I'm not sure
<jhass> mh, you could always do an included hook and do whatever
flan3002 has quit [Ping timeout: 264 seconds]
colorisco has quit [Ping timeout: 246 seconds]
colorisco has joined #crystal-lang
<BlaXpirit_> pretty good
<BlaXpirit_> ah, that initialize is not private
<BlaXpirit_> and that "allocate.tap do |obj|" is ... wut?
<jhass> tap is just def tap; yield self; self
<jhass> and initialize is automatically protected
<jhass> try A.new.initialize(Pointer(Void).null, true)
ponga has joined #crystal-lang
BlaXpirit_ has quit [Quit: Quit Konversation]
zipR4ND has joined #crystal-lang
<zipR4ND> hi all, trying to use this library: https://github.com/trans/clik i get an error upon compilation: "clik/src/clik.cr:48: splatting a union (Array(String)) is not yet supported" (https://github.com/trans/clik/blob/master/src/clik.cr#L48). it seems splatting arrays into functions is not supported. is there any workaround to this preserving the libs functionality?
<jhass> zipR4ND: looks like somebody just took a ruby script and slapped .cr to it
<jhass> I don't think it ever worked
<zipR4ND> oh sad
<zipR4ND> i think it could work if this splatting was somehow possible ..
<jhass> I don't think it ever will be for this case
<jhass> the compiler can't generate the correct call since the contents of argv there are only known on runtime
<zipR4ND> if i have a proc, can i somehow inspect the arguments it is taking on compile time?
<jhass> mh, in a macro that should be possible
<zipR4ND> ok thanks jhass
<jhass> at least quite easy to expose
<zipR4ND> can i define blocks like that {|f| p f} ?
JBat has joined #crystal-lang
<jhass> in a method call, yes
<jhass> >> [1, 2, 3].map {|n| n*2 }
<DeBot> jhass: [2, 4, 6]
<jhass> the proc/lambda syntax is ->(n : Int32) { n*2 }
<zipR4ND> ah ok, that would have been the next question
<zipR4ND> so there is no distinction between blocks and lambda in crystal?
<jhass> There's no distinction between Procs and lambdas, however blocks are something a bit different
<jhass> are proc is more like an anonymous function
<jhass> *a
<jhass> while a non-captured block has a good chance to generate code that never does a function call
<jhass> (or is actually guaranteed to never do so? I can never remember)
<zipR4ND> thanks. do you have a usage example for option_parser?
HakanD___ has joined #crystal-lang
<zipR4ND> nevermind, already found one ...
<jhass> spec/ is always a good source to look into, but this time how about the compiler itself: https://github.com/manastech/crystal/blob/master/src/compiler/crystal/command.cr#L257
HakanD__ has quit [Ping timeout: 256 seconds]
a5i has joined #crystal-lang
JBat has quit [Quit: Computer has gone to sleep.]
Ven has joined #crystal-lang
<zipR4ND> how can I make an argument obligtory with option_parser?
<zipR4ND> hey, just found out: this doesn't work: if (hash.has_key[:some_bool_key] && hash[:some_bool_key]) because the second boolean expression is evaluated, although the first one is already false .... throws an error ..
<jhass> >> h = {a: 1}; h.has_key?(:b) && h[:b]
<DeBot> jhass: false
<jhass> >> h = {a: 1}; h.has_key?(:b) && h[:a]
<DeBot> jhass: false
<jhass> >> h = {a: 1}; h.has_key?(:a) && h[:a]
<DeBot> jhass: 1
<jhass> >> h = {a: 1}; h.has_key?(:a) && h[:b]
<DeBot> jhass: MissingKey: Missing hash value: b
<jhass> seems to work like expected
jtarchie has joined #crystal-lang
<jtarchie> morning, channel.
<crystal-gh> [crystal] asterite pushed 1 new commit to master: http://git.io/vf2mN
<crystal-gh> crystal/master a2c3aef Ary Borenszweig: Use memmove/memcpy llvm instrinsics in Pointer operations when possible
<jhass> jtarchie: hi!
<travis-ci> manastech/crystal#2256 (master - a2c3aef : Ary Borenszweig): The build is still failing.
Ven has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
DerisiveLogic has joined #crystal-lang
DerisiveLogic has quit [Ping timeout: 245 seconds]
sadin has joined #crystal-lang
<a5i> hey sadin !
<sadin> a5i: hows it goin!
* sadin has been offline due to finals prep D:
<a5i> nothing much, still planning on binding lwan to crystal ? :P
<a5i> and that sucks, I have an AP Java exam in 1 week
<sadin> a5i: good luck with that! Java was never my favorite thing in the world. If I was writing java it was because my prof made me xD
<sadin> a5i: absolutely as soon as I catch up with some work for Fedora!
<a5i> sadin: yeah but they have softened up on the exam, and cool! looking forward to it
<sadin> the first obstacle is to just better familiarize myself with lwan so Im probably gonna write my personal site using its API
strcmp1 has joined #crystal-lang
asterite has joined #crystal-lang
JBat has joined #crystal-lang
<a5i> I hope to do that too with Crystal
sadin has quit [Remote host closed the connection]
JBat has quit [Quit: Computer has gone to sleep.]
Ven has joined #crystal-lang
DerisiveLogic has joined #crystal-lang
wanderer_ has joined #crystal-lang
Ven has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
HakanD___ has quit [Quit: Be back later ...]
Ven has joined #crystal-lang
HakanD___ has joined #crystal-lang
Ven has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
Ven has joined #crystal-lang
<zipR4ND> is there a to.sym method for a string?
<asterite> zipR4ND: Nope, symbols can't be generated dynamically
<zipR4ND> ok ..
<asterite> On the other hand, the same constant string across the program is always the same (i.e.: same object id)
<asterite> so there's no real need for dynamic symbols
<strcmp1> maybe it's a feature ;) dynamic symbols were at the bottom of the recent rails security issues.
flan3002 has joined #crystal-lang
bcardiff has joined #crystal-lang
<asterite> And memory leaks. Yes, we don't want to revisit that route
<asterite> Also, dynamic symbols introduce concepts like HashWithIndifferentAccess and so on...
havenwood has joined #crystal-lang
ponga has quit [Remote host closed the connection]
bcardiff has quit [Quit: Leaving.]
<crystal-gh> [crystal] asterite pushed 1 new commit to master: http://git.io/vfawU
<crystal-gh> crystal/master 779470b Ary Borenszweig: Moved compiler's SimilarName class to Levenshtein::Finder, because it's useful as a general class
BlaXpirit has joined #crystal-lang
Ven has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
Ven has joined #crystal-lang
strcmp1 has quit [Ping timeout: 250 seconds]
<travis-ci> manastech/crystal#2257 (master - 779470b : Ary Borenszweig): The build has errored.
rrrrrrrr has joined #crystal-lang
asterite has quit [Ping timeout: 246 seconds]
wanderer_ has quit [Quit: Page closed]
shama has joined #crystal-lang
Ven has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
HakanD___ has quit [Ping timeout: 244 seconds]
Ven has joined #crystal-lang
strcmp1 has joined #crystal-lang
Ven has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<a5i> >> File.exist?("image.png")
<DeBot> a5i: Error in line 3: undefined method 'exist?' for File:Class (did you mean 'exists?'?)
<a5i> >> File.exists?("image.png")
<DeBot> a5i: false
<a5i> whats with the differences with 's'
<jhass> Crystal goes with what "sounds better", Ruby is fairly strict on "use singular infinitive" these days
<a5i> oh
ponga has joined #crystal-lang
DerisiveLogic has quit [Ping timeout: 264 seconds]
<a5i> par1 = (JSON.parse(File.open("list.json")) as Hash) returns a Hash, but when doing 'to_a' on it I get an error saying
<a5i> its an error so I didnt bother gisting
<jhass> JSON.parse is hard to use in Crystal, use json_mapping, it's much easier
<a5i> hmm
<a5i> jhass, any documentation explaining how to use json_mapping ?
<jhass> you should have seen plenty of examples by now
<jhass> both the twitter client and crystalshards use it
<a5i> Yes but I dont fully understand it fully yet :/
<jhass> maybe do some more Ruby, Crystal is not yet a good language to strengthen ones programming skills
<a5i> It has tbh
<a5i> jhass, OKay, My json, when turned into a hash, has a github repo name and descripton
<a5i> so I created a class with a json mapping of name and description with the types of String
ssvb has quit [Ping timeout: 248 seconds]
<jhass> that's expecting {"name": "foo", "description": "bar"}
<jhass> you might just want to Hash(String, String).from_json there I guess
<a5i> my hash is Hash(String, JSON::Type) though
<jhass> your JSON.parse result is you mean
<a5i> oh yeah
<jhass> that's not what I suggested
<a5i> ohhhh
<a5i> so
<a5i> jhass, what do I replace 'Hash(String, String)' with in your example ?
<a5i> or should I just follow what you did with GitHubrepos
<jhass> I can't give any clear recommendations, you're waaay too vague about everything
DerisiveLogic has joined #crystal-lang
<a5i> the goal is in the comment
<jhass> why do you call .to_h.to_a?
<jhass> and as said, just Hash(String, String).from_json File.read("list.json")
<a5i> thanks !
DerisiveLogic has quit [Ping timeout: 264 seconds]
havenwood has quit []
havenwood has joined #crystal-lang
<a5i> so far so good
rrrrrrrr has quit [Quit: Page closed]
ponga has quit [Quit: Leaving...]
JBat has joined #crystal-lang
Kache has joined #crystal-lang
havenwood has quit [Remote host closed the connection]
Kache is now known as Kache4
Kache4 is now known as Kache4_
Kache4_ is now known as Kache
Kache has left #crystal-lang [#crystal-lang]
Kache4 has joined #crystal-lang
strcmp1 has quit [Ping timeout: 245 seconds]
zipR4ND has quit [Ping timeout: 264 seconds]
DerisiveLogic has joined #crystal-lang
JBat has quit [Quit: Computer has gone to sleep.]
a5i has quit [Quit: Connection closed for inactivity]
DerisiveLogic_ has joined #crystal-lang
DerisiveLogic_ has quit [Remote host closed the connection]
DerisiveLogic_ has joined #crystal-lang
DerisiveLogic has quit [Ping timeout: 256 seconds]
waj has joined #crystal-lang
orliesaurus has quit [Ping timeout: 276 seconds]
BlaXpirit has quit [Quit: Quit Konversation]
orliesaurus has joined #crystal-lang
<crystal-gh> [crystal] asterite pushed 1 new commit to master: http://git.io/vfrza
<crystal-gh> crystal/master 9fd3bd6 Ary Borenszweig: Better error message, location and trace when assigning a wrong type to a variable/instance-var with a fixed type
shaundavis has joined #crystal-lang
shaundavis is now known as davissp14
<davissp14> Hows it going?
<travis-ci> manastech/crystal#2258 (master - 9fd3bd6 : Ary Borenszweig): The build passed.
a5i has joined #crystal-lang
<a5i> I think it's finished
waj has quit [Quit: waj]
<a5i> >> Time.now.hours
<DeBot> a5i: Error in line 3: undefined method 'hours' for Time (did you mean 'hour'?)
<a5i> >> Time.now.hour
<DeBot> a5i: 23
<a5i> darn it