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
vikaton has joined #crystal-lang
shama has quit [Quit: (╯°□°)╯︵ɐɯɐɥs]
vikaton has quit []
datanois1 has joined #crystal-lang
kulelu88 has quit [Quit: Leaving]
Cidan has joined #crystal-lang
DerisiveLogic has joined #crystal-lang
Cidan is now known as zz_Cidan
havenwood has quit [Ping timeout: 256 seconds]
datanois1 has quit [Quit: leaving]
JBat has joined #crystal-lang
datanois1 has joined #crystal-lang
datanois1 has quit [Client Quit]
datanois1 has joined #crystal-lang
datanois1 has quit [Quit: leaving]
havenwood has joined #crystal-lang
datanoise has quit []
ponga has joined #crystal-lang
datanoise has joined #crystal-lang
datanoise has quit [Quit: WeeChat 1.1.1]
datanoise has joined #crystal-lang
datanoise has joined #crystal-lang
JBat has quit [Quit: Computer has gone to sleep.]
unshadow has joined #crystal-lang
<unshadow> jhass, I know what's your next project should be ! a build bot ! :)
<unshadow> with containers of like 5 different dists, I upload code, and get back 5 named Bineries
datanoise has quit [Ping timeout: 258 seconds]
ponga has quit [Read error: Connection reset by peer]
JBat has joined #crystal-lang
ponga has joined #crystal-lang
ponga has quit [Read error: Connection reset by peer]
ponga has joined #crystal-lang
havenwood has quit [Ping timeout: 245 seconds]
datanoise has joined #crystal-lang
datanoise has quit [Ping timeout: 240 seconds]
BlaXpirit has joined #crystal-lang
Ven has joined #crystal-lang
ponga has quit [Quit: Leaving...]
DerisiveLogic has quit [Ping timeout: 244 seconds]
datanoise has joined #crystal-lang
datanoise has quit [Ping timeout: 264 seconds]
<unshadow> Something wierd... or not XD In Ruby I can do this: "char_gender = gets until char_gender =~ /(f|m)/i", in crystal I get the following error: "read before definition of 'char_gender'"
<unshadow> I guess this has something to do with the compiler not knowing what the defenition of char_gender is going to be... or that it tries to create a loop with an undefined object
<unshadow> But how does it work in Ruby then ?
Ven has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
leafybasil has quit [Remote host closed the connection]
ponga has joined #crystal-lang
sandelius has joined #crystal-lang
<jhass> unshadow: and regarding the build bot, we probably should get it running on OBS
<unshadow> What's obs ?
<unshadow> Oh well... (about issue 549) I guess as long as I know :)
ponga has quit [Quit: Leaving...]
leafybasil has joined #crystal-lang
leafybasil has quit [Remote host closed the connection]
leafybasil has joined #crystal-lang
sandelius has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
leafybas_ has joined #crystal-lang
leafybasil has quit [Ping timeout: 244 seconds]
<unshadow> I can supply the hardware, and ip\port
<unshadow> and install the OBS,
<unshadow> or should we use amazon\azure ?
BlaXpirit-UA has joined #crystal-lang
sandelius has joined #crystal-lang
<jhass> there's a public instance
BlaXpirit has quit [Ping timeout: 252 seconds]
<unshadow> jhass: you mean this https://build.opensuse.org/ ?
<unshadow> ok :)
<unshadow> jhass: How can you add the repo for crystal to the Ubuntu istalltion ? (on site) I'm not relly sure what I'm doing lol
<jhass> on the OBS?
<jhass> no idea, I never tried
leafybas_ has quit [Remote host closed the connection]
leafybasil has joined #crystal-lang
Ven has joined #crystal-lang
sandelius has quit [Quit: Textual IRC Client: www.textualapp.com]
chrisseaton has joined #crystal-lang
<chrisseaton> Hi - I'm having trouble getting started with Crystal. I've installed via HomeBrew. I try crystal build test.cr, and I get: Error: execution of command failed with code: 1: `cc -o test .crystal//Users/chrisseaton/Documents/ruby/jruby/test.cr/main.o etc etc etc
Benoist has joined #crystal-lang
<Benoist> Hi guys
<Benoist> I've just published a msgpack unpacker implementation. I'd love some feedback before I start implementing the packer
leafybas_ has joined #crystal-lang
Benoist has quit [Quit: Page closed]
leafybasil has quit [Ping timeout: 264 seconds]
datanoise has joined #crystal-lang
datanoise has quit [Ping timeout: 265 seconds]
strcmp1 has quit [Ping timeout: 258 seconds]
<jhass> hard to give feedback if one doesn't stick around...
Ven has quit [Read error: No route to host]
Ven has joined #crystal-lang
<jhass> mmh, I think I broke it http://carc.in/#/r/bm
ponga has joined #crystal-lang
datanoise has joined #crystal-lang
datanoise has quit [Ping timeout: 252 seconds]
leafybas_ has quit [Remote host closed the connection]
leafybasil has joined #crystal-lang
havenwood has joined #crystal-lang
ponga has quit [Quit: Leaving...]
leafybas_ has joined #crystal-lang
leafybas_ has quit [Remote host closed the connection]
leafybas_ has joined #crystal-lang
leafybasil has quit [Read error: Connection reset by peer]
datanoise has joined #crystal-lang
datanoise has quit [Ping timeout: 252 seconds]
BlaXpirit_UA has joined #crystal-lang
BlaXpirit-UA has quit [Ping timeout: 252 seconds]
datanoise has joined #crystal-lang
<crystal-gh> [crystal] asterite pushed 3 new commits to master: http://git.io/vTXAi
<crystal-gh> crystal/master 983bac7 Ary Borenszweig: Fixed #680: crash with instance variable read in super call
<crystal-gh> crystal/master db7f604 Ary Borenszweig: Optimized samples/mandelbrot2.cr by using Iterator.of instead of creating an array
<crystal-gh> crystal/master 6219f8f Ary Borenszweig: Hierarchy tool: don't crash on missing instance vars types, and show them in red
<unshadow> I really want someone to do an NTLM haha
<unshadow> btw, why don't we use {bar: "1", foo: "2"} for hashes ?
<unshadow> and we stick to the old way of rockts
<unshadow> nm... I see you can use both
<jhass> note there's a difference to Ruby 2.2
<jhass> >> {"foo": "bar"}
<DeBot> jhass: # => {"foo" => "bar"} - http://carc.in/#/r/c9
<jhass> in Ruby 2.2 that's {:foo => "bar"}
<jhass> (and a syntax error prior)
<unshadow> >> {foo: "bar"}
<DeBot> unshadow: # => {:foo => "bar"} - http://carc.in/#/r/ca
<unshadow> >> {"foo": "bar"}
<DeBot> unshadow: # => {"foo" => "bar"} - http://carc.in/#/r/cb
<unshadow> >> {"foo" => "bar"}
<DeBot> unshadow: # => {"foo" => "bar"} - http://carc.in/#/r/cc
<unshadow> What's the point of tuple ? , it's like how one would use array in Ruby no ?
<unshadow> oh... but you can't add to them
<unshadow> >> b = Tuple.new; b << "a"
<DeBot> unshadow: Error in line 4: undefined method '<<' for {} - http://carc.in/#/r/cf
<unshadow> >> b = Tuple.new; b[0] = "a"
<DeBot> unshadow: Error in line 4: undefined method '[]=' for {} - http://carc.in/#/r/cg
<jhass> they're compile time introspectable
<jhass> so it's what allows splats in crystal for example
<jhass> and they don't have an object allocated in the generated code iirc
<travis-ci> manastech/crystal#2360 (master - 6219f8f : Ary Borenszweig): The build passed.
<jhass> so you can return two values from a method with them for example without allocating an array
<jhass> note things like:
<unshadow> how would one use them in a real wolrd scenario ?
<jhass> >> t = {1, "foo"}; {t[0] * 3, t[1].upcase}
<DeBot> jhass: # => {3, "FOO"} - http://carc.in/#/r/ch
<jhass> >> t = [1, "foo"]; {t[0] * 3, t[1].upcase}
<DeBot> jhass: Error in line 4: undefined method 'upcase' for Int32 - http://carc.in/#/r/ci
<jhass> >> def foo; 1, 2; end; foo.class
<DeBot> jhass: Syntax error in eval:4: unexpected token: ; - http://carc.in/#/r/cj
<jhass> meh
<jhass> >> def foo; {1, 2}; end; foo.class
<DeBot> jhass: # => {Int32, Int32} - http://carc.in/#/r/ck
<jhass> >> def foo; {1, 2}; end; a, b = foo; a*b
<DeBot> jhass: # => 2 - http://carc.in/#/r/cl
<unshadow> it looks like json
<jhass> it doesß
<jhass> ?
<unshadow> to me at lest :)
<unshadow> >> a = {-1, 1}; a.class
<DeBot> unshadow: # => {Int32, Int32} - http://carc.in/#/r/cm
<unshadow> >> a = {-1, 1}; a.is_a?(Tuple)
<DeBot> unshadow: # => true - http://carc.in/#/r/cn
<unshadow> >> a = {-1, 1}; puts a.class
<DeBot> unshadow: {Int32, Int32} - more at http://carc.in/#/r/co
<unshadow> so its just values, no object around them ?
<unshadow> >> a = {-1, 1}; p a
<DeBot> unshadow: {-1, 1} - more at http://carc.in/#/r/cp
<jhass> In most cases at least afaik
<jhass> well, from your point of view you have an object
<jhass> just in the code that's generated it's gone, opposed to say an Array
<unshadow> A tuple is a sequence of immutable Python objects. Tuples are sequences, just like lists. The differences between tuples and lists are
<unshadow> thats from python
<unshadow> so its a list of values I cannot change
<jhass> yes
<jhass> well, you cannot change the list, the values you can change as they allow it ;)
<unshadow> Then, what's the point of a = Tuple.new ?
<jhass> that's an empty tuple
<jhass> sometimes useful if you use them for iteration
<unshadow> yeha, which I cannot change or add too
<unshadow> it looks like somone created an Array of constants and locked it
<jhass> >> def dumb_sum(collection); x = 0; x.each do |i| x += i; end; x; end; {dumb_sum([1, 2 3]), dumb_sum({2, 3, 4}), dumb_sum([] of Int32), dumb_sum(Tuple.new)}
<DeBot> jhass: Syntax error in eval:4: unexpected token: 3 - http://carc.in/#/r/cq
<jhass> >> def dumb_sum(collection); x = 0; x.each do |i| x += i; end; x; end; {dumb_sum([1, 2, 3]), dumb_sum({2, 3, 4}), dumb_sum([] of Int32), dumb_sum(Tuple.new)}
<DeBot> jhass: in line 4: undefined method 'each' for Int32 - http://carc.in/#/r/cr
<jhass> oh
<jhass> >> def dumb_sum(collection); x = 0; collection.each do |i| x += i; end; x; end; {dumb_sum([1, 2, 3]), dumb_sum({2, 3, 4}), dumb_sum([] of Int32), dumb_sum(Tuple.new)}
<unshadow> so no itiration ?
<DeBot> jhass: # => {6, 9, 0, 0} - http://carc.in/#/r/cs
<jhass> no, I'm just as dumb as my sum ;P
<unshadow> hahaha
<unshadow> I see, so you populate the Tuple.new with the sums
<jhass> no
<jhass> the difference between the last two which both return 0 is that the array variant allocates that array
<jhass> the tuple variant after the optimizer will probably replace the entire function call with a 0 scalar
<unshadow> sometime I just feel dumb... like the sums... what is scalar ?
<jhass> a value
<jhass> in this case I mean it'll be in the binary as that value
<unshadow> haaa Ok, makes sense
<unshadow> crazy rubists hahahah
DerisiveLogic has joined #crystal-lang
<unshadow> jhass: how do I get back output from Process.run ?
<jhass> the output parameter can be true, then Process:Status#output will be populated, or you can set it to any kind of IO object, then the output will be written to it
<unshadow> >> a = Process.run("ls", "-la", STDOUT)
<DeBot> unshadow: in /usr/lib/crystal/process/run.cr:8: undefined method 'each' for String - http://carc.in/#/r/cy
<unshadow> >> a = Process.run("ls", , STDOUT)
<DeBot> unshadow: Syntax error in eval:4: unterminated call - http://carc.in/#/r/cz
<unshadow> >> a = Process.run("ls", nil, STDOUT)
<DeBot> unshadow: # => #<Process::Status:0x9094F18 @pid=82, @exit=0, @output=nil> - http://carc.in/#/r/d0
<unshadow> >> a = Process.run("ls", nil, true); a.status
<DeBot> unshadow: Error in line 4: undefined method 'status' for Process::Status - http://carc.in/#/r/d1
<jhass> >> Process.run("ls", output: STDOUT)
<unshadow> >> a = Process.run("ls", nil, true); a.output
<DeBot> jhass: # => #<Process::Status:0x8881F18 @pid=82, @exit=0, @output=nil> - http://carc.in/#/r/d2
<DeBot> unshadow: # => "" - http://carc.in/#/r/d3
<jhass> >> Process.run("ls", {"-a"}, output: STDOUT)
<DeBot> jhass: . - more at http://carc.in/#/r/d4
<jhass> >> Process.run("ls", {"-a"}, output: true).output
<DeBot> jhass: # => ".\n..\n.crystal\n" - http://carc.in/#/r/d5
<unshadow> >Process.run("ls", nil, true).output
<unshadow> >> Process.run("ls", nil, true).output
<DeBot> unshadow: # => "" - http://carc.in/#/r/d6
<unshadow> >> Process.run("ls /tmp/", nil, true).output
<DeBot> unshadow: # => "" - http://carc.in/#/r/d7
<unshadow> >> Process.run("ls /tmp/", {-lah}, true).output
<DeBot> unshadow: Error in line 4: undefined local variable or method 'lah' - http://carc.in/#/r/d8
<unshadow> >> Process.run("ls /tmp/", {"-lah"}, true).output
<DeBot> unshadow: # => "" - http://carc.in/#/r/d9
<unshadow> >> Process.run("ls /tmp/", ["-lah"], true).output
<DeBot> unshadow: # => "" - http://carc.in/#/r/da
<jhass> unshadow: maybe we should use the site to experiment :) you can jump to the edit view by pressing e and submit by pressing Ctrl+Enter
<unshadow> nice ! you should add the shourtcuts in the site
<jhass> yeah, didn't find a good place yet
<unshadow> you have any expireance with Curses ?
BlaXpirit_UA has quit [Remote host closed the connection]
BlaXpirit has joined #crystal-lang
<jhass> no
Ven has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<unshadow> how would you rate converting this to Crystal in terms of difficulty https://github.com/WinRb/rubyntlm ?
<jhass> probably not too hard, just time consuming
Ven has joined #crystal-lang
Ven_ has joined #crystal-lang
Ven has quit [Ping timeout: 276 seconds]
leafybasil has joined #crystal-lang
shama has joined #crystal-lang
leafybas_ has quit [Ping timeout: 256 seconds]
Ven_ has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
aemadrid has joined #crystal-lang
<tkrajcar> anyone know if waj is on irc ever?
<jhass> rarely
<jhass> but it does happen
<jhass> tkrajcar: try /msg NickServ INFO waj
<tkrajcar> oh neat, I didn't know nickserv could do that.
jua_ has joined #crystal-lang
wanderer_ has joined #crystal-lang
DerisiveLogic has quit [Ping timeout: 244 seconds]
leafybasil has quit [Remote host closed the connection]
<chrisseaton> I'm trying to build Crystal on the Mac. The instructions say not to use LLVM from homebrew, but the Makefile specifically looks for it there. What do I do?
<wanderer_> shouldn't sizeof() return a LibC::SizeT value insteaf of Int32?
<wanderer_> jhass: hi :) do you know how to get a void pointer to `var :: LibC::IntT` as Void Pointer? `pointerof(var) as Void*` gives me "can't cast Int32 to Pointer(Void)"
<datanoise> chrisseaton: brew install llvm36
<datanoise> chrisseaton: i think it should also work if you do $ brew install llvm
<datanoise> since homebrew upgraded it to verion 3.6
<chrisseaton> ah ok - so this doesn't apply any more? https://github.com/manastech/crystal/blob/master/Contributing.md
<jhass> wanderer_: tricky, I'd say depends whether you categorize sizeof to the C binding part of crystal or to the day to day usage part
<jhass> that the cast fails might be a bug
<datanoise> chrisseaton: no, it was referring to llvm 3.5 which had a bug in libunwind
<jhass> >> var :: LibC::IntT; pointerof(var)
<DeBot> jhass: # => Pointer(Int32)@0xBFF21874 - http://carc.in/#/r/dl
<jhass> >> var :: LibC::IntT; pointerof(var) as Void*
<DeBot> jhass: # => Pointer(Void)@0xBF952214 - http://carc.in/#/r/dm
<jhass> well, actually it seems to work?
<chrisseaton> datanoise: ok, but the problem I now get is "Error: No available formula for llvm36", which is true it's called just 'llvm' I think
<jhass> chrisseaton: didn't have the brew formula a --with-llvm flag or something?
* jhass not a mac user
strcmp1 has joined #crystal-lang
<datanoise> chrisseaton: my guess is that homebrew deleted llvm36 formula after upgrading to 3.6
<chrisseaton> ok if I change the Makefile to llvm from llvm36 it works
<jhass> first pull request opportunity! \o/
<datanoise> yep :)
<chrisseaton> I guess none of the core team uses Mac regularly?
leafybasil has joined #crystal-lang
asterite has joined #crystal-lang
asterite has quit [Client Quit]
<wanderer_> jhass: oh, actually it was another parameter that was causing the error which happens to be an Int32, my bad, ehm, how would I interpret that correctly as a void pointer?
<jhass> interpret?
<jhass> chrisseaton: actually they both use macs afaik, I guess the never updated?
<wanderer_> it's like an uintptr_t
<jhass> I have not the slightest idea what that is ;)
<wanderer_> it's just an address
<wanderer_> and I want to pass it as Void*
<jhass> what's the error?
<wanderer_> the one from earlier, can't cast Int32 to Pointer(Void)
<jhass> ah
<chrisseaton> Whenever I run the Makefile after my first build it always says nothing to do, due to this .build file
<jhass> Pointer(Void).new ptr
<wanderer_> thx :)
<jhass> chrisseaton: sounds like it compiled correctly?
<jhass> check with bin/crystal version
<chrisseaton> yeah, but then I change things, and it doesn't want to build it again
<jhass> hum
<jhass> that issue I never had
<jhass> but you can workaround with touch src/compiler/crystal.cr I guess
<crystal-gh> [crystal] waj pushed 1 new commit to master: http://git.io/vTMwN
<crystal-gh> crystal/master e87ce77 Juan Wajnerman: Channels can send an receive values
leafybasil has quit [Remote host closed the connection]
<wanderer_> jhass: where is sizeof used elsewise? I'd guess functions that expect a parameter that probably needs a sizeof should also expect it to be UInt32/UInt64, but yes I'm mostly thinking of C binding atm
<wanderer_> also atm sizeof doesn't work with variables, does it? sizeof(type) is actually bad practice
<jhass> wanderer_: It can be useful for low level data structures: https://github.com/manastech/crystal/blob/master/src/string.cr#L111
<jhass> or think things like binary network protocols
<chrisseaton> Ok I've got it working on Mac I think
<chrisseaton> I work on a new implementation of Ruby btw - so I'm seeing what Crystal is like
<jhass> not ruby :P
<wanderer_> but to be precise HEADER_SIZE is always >=0
<wanderer_> so LibC::SizeT would be fitting, or UInt32 at least
<jhass> wanderer_: oh, signed vs unsigned? I didn't notice, yeah there I agree it should be unsigned
<datanoise> wanderer_: sizeof is a compile level directive, do not expect it to work in runtime, so you need to know which type you are working with
<wanderer_> size_t maps either to UInt32/UInt64 being able to hold the size of the biggest object that can exist in memory
<wanderer_> datanoise: sizeof(variable) should map to sizeof(typeof(variable)), it's not runtime
<wanderer_> >> var = 0; sizeof(typeof(var))
<DeBot> wanderer_: # => 4 - http://carc.in/#/r/e3
<wanderer_> oh, it actually works
<wanderer_> with typeof
<jhass> until you hit one of the cases where typeof fails :P
<wanderer_> >> var = 0; sizeof(var)
<DeBot> wanderer_: Syntax error in eval:4: expecting token 'CONST', not 'var' - http://carc.in/#/r/e4
<chrisseaton> I saw that there is a Crystal talk at CurryOn - will be interesting
<jhass> yeah, won't make it there sadly :/
<wanderer_> jhass: is there something wrong with sizeof(var) why it can't be implemented or sth?
<jhass> will it be recorded? never checked
<chrisseaton> jhass: they don't often record talks at these conferences
<jhass> wanderer_: I guess it's simply harder to implement and you can do the construct you showed when you need it
<travis-ci> manastech/crystal#2361 (master - e87ce77 : Juan Wajnerman): The build passed.
<wanderer_> yes, didn't think of typeof at first, sizeof(var) is more intuitive though I'd say
<wanderer_> hm, what's this: "unexpected ',' in type (use parenthesis to disambiguate)" ?
<wanderer_> when removing `pointerof(buf) as Void*` from the function call it works
<jhass> not enough context :)
<jhass> might need (pointerof(buf) as Void*)
<wanderer_> buf :: UInt8[12] if (proc = @@proc) && (addr = @@addr) LibWin32.readprocessmemory(proc, Pointer(Void).new(addr), pointerof(buf) as Void*, 12_u32, nil) String.new buf.buffer else "" end
<jhass> mh, sounds like it reads the , 12_u32, nil into the typedef for some reason
<jhass> the parens should work
<wanderer_> yep, they do
<wanderer_> just tested it, I don't understand why, though
<jhass> mmh, I guess because Foo, Bar -> is a valid type declaration, so it consumes the , as part of it
<jhass> and doesn't backtrack
DerisiveLogic has joined #crystal-lang
DerisiveLogic has quit [Remote host closed the connection]
DerisiveLogic has joined #crystal-lang
zz_Cidan is now known as Cidan
<crystal-gh> [crystal] waj pushed 1 new commit to master: http://git.io/vTDeU
<crystal-gh> crystal/master 118d6da Juan Wajnerman: Channels can be closed (thanks @datanoise!)
<BlaXpirit> is there a way to generate lib from headers?
<jhass> there are one or two more, I'm not sure if any ever reached feature completeness yet
<BlaXpirit> and no instructions :p
<BlaXpirit> @[Link(ldflags: "-L`xcode-select --print-path`/Toolchains/XcodeDefault.xctoolchain/usr/lib")]
<BlaXpirit> kk
aemadrid has quit [Quit: Connection closed for inactivity]
<travis-ci> manastech/crystal#2362 (master - 118d6da : Juan Wajnerman): The build passed.
datanoise has quit [Ping timeout: 264 seconds]
<BlaXpirit> it gives me error: must use 'struct' tag to refer to type
<BlaXpirit> i'm sure there is a compiler flag that allows this, but even then I don't know how to pass it through crystal_lib
wanderer_ has quit [Ping timeout: 246 seconds]
JBat has quit [Quit: Computer has gone to sleep.]
<crystal-gh> [crystal] asterite pushed 1 new commit to master: http://git.io/vTD2I
<crystal-gh> crystal/master f57a889 Ary Borenszweig: Added Channel#receive?
sandelius has joined #crystal-lang
<travis-ci> manastech/crystal#2363 (master - f57a889 : Ary Borenszweig): The build passed.
datanoise has joined #crystal-lang
vikaton has joined #crystal-lang
datanoise has quit [Ping timeout: 264 seconds]
wanderer_ has joined #crystal-lang
<wanderer_> jhass: does goto actually exist? :D
<jhass> I hope not!
<jhass> >> goto
<DeBot> jhass: Error in line 4: undefined local variable or method 'goto' - http://carc.in/#/r/e6
<wanderer_> what a shame
<jhass> not really :P
<jhass> we don't have ruby's weird throw/catch either, luckily!
<wanderer_> I don't really like pascal-like code which looks like from a control flow graph
<wanderer_> sometimes goto and another exit point is much nicer than saving results in variables and unrolling every loop, etc.
<jhass> I think in most cases somebody was just too lazy to extract something into a small method
waterlink has joined #crystal-lang
<jhass> it's amazing how many mid level returns you can avoid even, just by bit rearrangement
leafybasil has joined #crystal-lang
<wanderer_> e.g. if you have a file open and there are multiple error conditions, on error you return 0 and have to close the file, "goto error; error: close(file); return 0" would come in handy
<wanderer_> elsewise you'd need to repeat that "close(file); return 0" for every error condition
<jhass> ensure; close(file) if file && file.open?
<jhass> and then just raise for the error condition
<wanderer_> this however would induce overhead and is kinda something I meant with "saving results in variables and unrolling every loop" with an `error: ...` you wouldn't need checks like `if file && file.open?`
<jhass> well, a sane file.close would do that check anyhow
<jhass> I don't see a nil check as problematic as the harder to follow control flow of goto
<crystal-gh> [crystal] asterite pushed 1 new commit to master: http://git.io/vTyTS
<crystal-gh> crystal/master 695f839 Ary Borenszweig: Added AutoflushBufferedIO and use it for STDOUT. Removed CFileIO
<wanderer_> hm, C is different in regards to such checks because they are mostly superfluous if you're coding tidy
waterlink has quit [Ping timeout: 265 seconds]
<wanderer_> jhass: https://github.com/xwanderer/mutarr.c/blob/master/mutarr.c#L232 I wouldn't recommend it for everything, but sometimes it's kinda handy I think
<jhass> apples and oranges really, an OOP language with exception support makes use of these and wouldn't use error return codes in the first place
<wanderer_> so you would rather use a `raise` instead of those `goto error`?
<wanderer_> sadly, I wasn't able to get exceptions working on windows yet :D
<wanderer_> also I'm not familiar with OOP and exception handling, that's why I'd use a more C-like programming style
<wanderer_> and in C you sometimes use goto to avoid deep nesting like pascal ppl would do
<wanderer_> *pascal ppl do the deep nesting, not using goto
<jhass> yes, you can even do something like catching an exception, doing something and then reraising it
<jhass> which ends up very much like being an error handling goto
<strcmp1> jhass, throw/catch is useful if you want to break out of a deeply nested loop though
<jhass> it's not different from goto IMO
sandelius has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
<willllll> almost maybe got goto working, but I'm giving up since the joke isn't that worth it https://gist.github.com/will/c4021a5493e400c08fcc
<BlaXpirit> willllll pls
<jhass> I don't want to know how much that breaks :D
ismaelga has joined #crystal-lang
unshadow_ has joined #crystal-lang
<crystal-gh> [crystal] asterite pushed 2 new commits to master: http://git.io/vTy8L
<crystal-gh> crystal/master 2110d08 Ary Borenszweig: Fixed: check isatty in STDIN, STDOUT and STDERR to know if it's blocking or not
<crystal-gh> crystal/master d1ddc36 Ary Borenszweig: Removed broken "windows" sample (wasn't very useful)
jua_ has quit [Ping timeout: 264 seconds]
<unshadow_> We should open a page that centralize all the project people made in crystal
<BlaXpirit> there is
<jhass> unshadow_: like http://crystalshards.herokuapp.com/?
squixy has joined #crystal-lang
jua_ has joined #crystal-lang
<travis-ci> manastech/crystal#2365 (master - 2110d08 : Ary Borenszweig): The build was fixed.
<unshadow_> Oh... Thats cool :) even my game is there haha
<unshadow_> jhass , is it a project of yours ?
<jhass> no
unshadow_ has quit [Quit: AndroIRC - Android IRC Client ( http://www.androirc.com )]
squixy has quit [Quit: Page closed]
datanoise has joined #crystal-lang
datanois1 has joined #crystal-lang
datanois1 has quit [Ping timeout: 272 seconds]
jua_ has quit [Quit: Vision[0.9.7-H-20140108]: i've been blurred!]
datanois1 has joined #crystal-lang
ismaelga has quit [Remote host closed the connection]
BlaXpirit has quit [Quit: Quit Konversation]
havenwood has quit [Ping timeout: 252 seconds]
DerisiveLogic has quit [Ping timeout: 255 seconds]
tdc has joined #crystal-lang
DerisiveLogic has joined #crystal-lang
DerisiveLogic has quit [Remote host closed the connection]
waterlink has joined #crystal-lang
vikaton has quit [Quit: Connection closed for inactivity]
tdc has quit [Quit: Leaving]
havenwood has joined #crystal-lang
DerisiveLogic has joined #crystal-lang
wanderer_ has quit [Quit: Page closed]