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
zipR4ND has quit [Ping timeout: 252 seconds]
<wanderer_> vikaton: use --single-module
<wanderer_> then execute the failing command again
<wanderer_> maybe you're missing some lib
<vikaton> I get
<vikaton> cc -o /tmp/crystal-run-hello_world.vspeL2 .crystal//root/Frank/samples/hello_world.cr/main.o -lssl -lcrypto -levent -lrt -lpcl -lpcre -lgc -lpthread -lunwind
<wanderer_> what if you execute this command yourself?
<vikaton> wanderer_: I get
<vikaton> cc: .crystal//root/Frank/samples/hello_world.cr/main.o: No such file or directory
<vikaton> thats weird
BlaXpirit-UA has quit [Quit: Quit Konversation]
<vikaton> hello_world.cr is a file
<vikaton> not folder
<vikaton> tho I'm not so knowledgable about how crystal compilation works
<wanderer_> .o is one or many .cr files compiled to object file format
<wanderer_> which is then linked to an executable by cc
<fowl> Check if .crystal/root/... Exists? Vikaton
<vikaton> ok
<vikaton> fowl, yes it does
<vikaton> after it erros
wanderer_ has quit [Quit: Page closed]
<vikaton> whats the default path for crystal ?
DerisiveLogic has quit [Ping timeout: 250 seconds]
<fowl> i think it looks at .. from the binary
willlll has quit [Read error: Connection reset by peer]
willlll has joined #crystal-lang
<vikaton> not quite sure
<fowl> the check the sh script that launches, in bin/crystal
waterlink has joined #crystal-lang
waterlink1 has quit [Ping timeout: 240 seconds]
havenwood has joined #crystal-lang
ponga has joined #crystal-lang
waterlink has quit [Quit: Leaving.]
<vikaton> after I ru crystal deps, how do I require the lib in the main file?
<vikaton> with the lib name or the dir?
shama has quit [Quit: (╯°□°)╯︵ɐɯɐɥs]
willlll has quit [Quit: willlll]
willlll has joined #crystal-lang
zz_Cidan is now known as Cidan
JBat has joined #crystal-lang
r0ast has joined #crystal-lang
r0ast has quit []
r0ast has joined #crystal-lang
j0hnnyk has joined #crystal-lang
j0hnnyk has quit [Remote host closed the connection]
j0hnnyk has joined #crystal-lang
Cidan is now known as zz_Cidan
r0ast has quit [Read error: Connection reset by peer]
r0ast has joined #crystal-lang
r0ast has quit [Client Quit]
j0hnnyk has quit [Remote host closed the connection]
j0hnnyk has joined #crystal-lang
r0ast has joined #crystal-lang
j0hnnyk has quit [Remote host closed the connection]
r0ast has quit []
j0hnnyk has joined #crystal-lang
r0ast has joined #crystal-lang
j0hnnyk has quit [Remote host closed the connection]
j0hnnyk has joined #crystal-lang
havenn has joined #crystal-lang
havenwood has quit [Ping timeout: 256 seconds]
j0hnnyk has quit [Remote host closed the connection]
j0hnnyk has joined #crystal-lang
j0hnnyk has quit [Remote host closed the connection]
panga has joined #crystal-lang
j0hnnyk has joined #crystal-lang
r0ast has quit [Read error: Connection reset by peer]
r0ast has joined #crystal-lang
BlaXpirit has joined #crystal-lang
ponga_ has joined #crystal-lang
j0hnnyk has quit [Remote host closed the connection]
ponga has quit [Ping timeout: 256 seconds]
j0hnnyk has joined #crystal-lang
ponga has joined #crystal-lang
r0ast has quit [Client Quit]
panga has quit [Ping timeout: 276 seconds]
j0hnnyk has quit [Remote host closed the connection]
j0hnnyk has joined #crystal-lang
ponga_ has quit [Ping timeout: 264 seconds]
j0hnnyk has quit [Remote host closed the connection]
j0hnnyk has joined #crystal-lang
j0hnnyk has quit [Read error: Connection reset by peer]
j0hnnyk has joined #crystal-lang
r0ast has joined #crystal-lang
r0ast has quit []
j0hnnyk has quit [Remote host closed the connection]
j0hnnyk has joined #crystal-lang
JBat has quit [Quit: Computer has gone to sleep.]
willlll has quit [Quit: willlll]
<BlaXpirit> how to deprecate?
DerisiveLogic has joined #crystal-lang
j0hnnyk has quit [Remote host closed the connection]
DerisiveLogic has quit [Ping timeout: 246 seconds]
j0hnnyk has joined #crystal-lang
j0hnnyk has quit [Max SendQ exceeded]
j0hnnyk has joined #crystal-lang
j0hnnyk has quit [Read error: Connection reset by peer]
j0hnnyk has joined #crystal-lang
j0hnnyk has quit [Max SendQ exceeded]
j0hnnyk has joined #crystal-lang
Ven has joined #crystal-lang
HakanD_ has joined #crystal-lang
strcmp1 has quit [Ping timeout: 256 seconds]
Ven has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
Ven has joined #crystal-lang
havenn is now known as havenwood
r0ast has joined #crystal-lang
r0ast has quit [Remote host closed the connection]
wanderer_ has joined #crystal-lang
<crystal-gh> [crystal] daneharrigan opened pull request #609: WIP: added expect syntax to spec (master...add-expect-to-specs) http://git.io/vJ4lw
Ven has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
JBat has joined #crystal-lang
HakanD__ has joined #crystal-lang
HakanD_ has quit [Ping timeout: 246 seconds]
<wanderer_> is there a String#index that doesn't return nil but raises?
<jhass> don't see anything
<BlaXpirit> could one write || raise ?
<jhass> so tack .not_nil! at the end if you're sure you'll get a rsult
<jhass> mh, I guess, but .not_nil! is better
Ven has joined #crystal-lang
<wanderer_> not_nil! is kinda cluttery
<jhass> why are you sure that the index exists?
<wanderer_> I like e.g. the [] and []? notation for raise and nil
<jhass> what are you using that for?
<wanderer_> I tested the Process.run with a 16k commandline and it apparently succeeded, but now if I don't use --single-module the linker invocation fails
<wanderer_> thus I try it now with using stdin and cutting off the cmd's header in its output
<jhass> so removing a known value from a string?
<jhass> or the first line I guess?
<wanderer_> command = "@echo off && echo blubb\n"; a = Process.run("cmd.exe", input: command, output: true).output.not_nil!; bla = a[(a.index(command).not_nil! + command.length)..-1].chomp
<jhass> are there multiple lines before command?
<wanderer_> yes
<jhass> and isn't it like always 3 lines?
<wanderer_> I don't know whether it differs from version to version
<wanderer_> for me it'll always be the same
<jhass> mh
<jhass> could .gsub(/.+?#{Regexp.escape(command)}$/m, '') I guess
<jhass> >> "foo\nbar\nbaz".gsub(/.+?bar$/m, '')
<DeBot> jhass: Syntax error in eval:3: unterminated char literal
<jhass> >> "foo\nbar\nbaz".gsub(/.+?bar$/m, "")
<DeBot> jhass: "foo\nbar\nbaz"
<jhass> sigh
<jhass> in theory, if we had something that that respects the m flag
<jhass> >> "foo\nbar\nbaz".gsub(/[.\n]+?bar\n/, "")
<DeBot> jhass: "foobaz"
<jhass> >> "foo\nbar\nbaz".gsub(/\A[.\n]+?bar\n/, "")
<DeBot> jhass: "foo\nbar\nbaz"
<fowl> >> lib X; enum Y; Z, W end end puts X::Y::Z
<DeBot> fowl: Syntax error in eval:3: unexpected token: puts
<jhass> >> "foo\nbar\nbaz".gsub(Regex.new(".+?bar\n", Regex::MULTILINE, "")
<DeBot> jhass: Syntax error in eval:4: expecting token ')', not 'end'
<jhass> >> "foo\nbar\nbaz".gsub(Regex.new(".+?bar\n", Regex::MULTILINE), "")
<DeBot> jhass: "baz"
<fowl> >> lib X; enum Y; Z, W end; end; puts X::Y::Z
<DeBot> fowl: Z
<fowl> >> lib X; enum Y: UInt32; Z, W end end puts X::Y::Z
<DeBot> fowl: Syntax error in eval:3: unexpected token: puts
<fowl> >> lib X; enum Y: Uint32; Z, W end; end; puts X::Y::Z
<DeBot> fowl: Error in line 3: undefined constant Uint32 (did you mean 'UInt32'?)
<wanderer_> jhass: it's nicer, but wouldn't it be slower as well?
<fowl> Hrm...
<jhass> wanderer_: a bit
<jhass> >> "foo\nbar\nbaz".gsub(/.+?bar\n/m, "")
<DeBot> jhass: "baz"
<jhass> ah, the $ doesn't match \n in multiline mode
<jhass> pcre...
<jhass> fowl: UInt32, not Uint32 ;)
<fowl> I know I'm on phone so its hard to keep copy and pasting
<wanderer_> jhass: the cmdline is approx. 24k chars
<wanderer_> when compiling the compiler without --single-module
<wanderer_> that's probably why it's failing
<jhass> hence the < stdin approach ;)
<jhass> we had the same issue on linux
<fowl> Is there package management
<jhass> very basic, just "clone this repo from GH and symlink it to the right place please" for now, basically
<wanderer_> should I use `true` instead of `STDOUT`, cut it and then append it to STDOUT?
<wanderer_> directly using STDOUT won't work obviously
<jhass> I don't follow?
<jhass> you mean to hide the cmd.exe header?
<wanderer_> yes
<wanderer_> if I pass STDOUT, I can't interfere, can I?
<jhass> yeah
<jhass> though I wonder if we need to go through a shell at all on windows, if we have a benefit from that
<jhass> Ruby seems to just eradicate what looks like shell statements and run it without
<wanderer_> how would you use stdin then?
jeromegn has quit [Ping timeout: 272 seconds]
havenwood has quit [Remote host closed the connection]
<jhass> you wouldn't, you would properly tokenize the arguments and build argv
<BlaXpirit> >> a = {a:5}; a[:b]
<DeBot> BlaXpirit: MissingKey: Missing hash value: :b
<BlaXpirit> >> Set.new [1,2,3]
<DeBot> BlaXpirit: Set{1, 2, 3}
<BlaXpirit> >> Set{1,2,3}
<DeBot> BlaXpirit: Set{1, 2, 3}
<BlaXpirit> how did that work?
<wanderer_> jhass: the cmdline is even bigger, I forgot that the full pathes are passed, it's 77k chars
<BlaXpirit> >> Set({1,2,3})
<DeBot> BlaXpirit: Failed to run your code, sorry!
<BlaXpirit> >> Set(int).new
<DeBot> BlaXpirit: Syntax error in eval:3: expecting token 'CONST', not 'int'
<BlaXpirit> >> Set(Int).new
<DeBot> BlaXpirit: Error in line 3: can't use Int as generic type argument yet, use a more specific type
<BlaXpirit> >> Set(Int32).new
<DeBot> BlaXpirit: Set{}
<jhass> wanderer_: that's too much for a single item of ARGV, but fits easily if split across multiple items, I think on linux it's something like 65k arguments you can pass
<wanderer_> jhass: hm, I wonder if it'd work on windows :D
<wanderer_> just now either case doesn't work, using a single arg nor using stdin
<jhass> wanderer_: I mean would something like `echo hi | cat` or `echo hi 2>&1` even work?
<jhass> if passed to cmd.exe
<wanderer_> yes
<jhass> mh
<wanderer_> `system "#{CC} -o #{output_filename} #{object_names.join " "} #{@link_flags} #{lib_flags}"`
<wanderer_> apparently object_names already is an array
<wanderer_> so I could try to pass that as args
<wanderer_> just to see whether it works with such an amount of arguments
Ven has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<BlaXpirit> i have [1,2,3] [4,5] . how to get [{1,4}, {1,5}, {2,4}, ...] ?
<BlaXpirit> product
<wanderer_> jhass: how would you do ["xyz", "blablubb", array, "xxx"] in ruby/crystal?
<BlaXpirit> wanderer_, alias
<BlaXpirit> alias Member = String|Member
<BlaXpirit> [] of Member
<fowl> o_O
<fowl> what is that exactly
<BlaXpirit> just trying to remember what asterite said
<jhass> >> [1, 2, 3] * [4, 5]
<DeBot> jhass: Error in line 3: undefined method '*' for Array(Int32)
<jhass> >> [1, 2, 3].product [4, 5]
<DeBot> jhass: Error in line 3: 'Array(Int32)#product' is expected to be invoked with a block, but no block was given
<jhass> huh
<BlaXpirit> calling functions with something that starts with a bracket doesn't work
<wanderer_> I didn't mean a union, but an efficient way to create an array out of an array with elements prepended and appended before it
<BlaXpirit> >> [1, 2, 3].product([4, 5])
<DeBot> BlaXpirit: Error in line 3: 'Array(Int32)#product' is expected to be invoked with a block, but no block was given
<BlaXpirit> nvm
<jhass> >> [1, 2, 3].product([4, 5]).each do |a, b| p {a, b} end
<DeBot> jhass: Syntax error in eval:3: unexpected token: }
<jhass> >> [1, 2, 3].product([4, 5]).each do |a, b| p({a, b}); end
<DeBot> jhass: Error in line 3: 'Array(Int32)#product' is expected to be invoked with a block, but no block was given
<BlaXpirit> wanderer_, ["xyz", "blablubb"] + array
<jhass> bleh
<jhass> not too useful, but in theory it's there :P
<BlaXpirit> jhass, it is strange because in source i clearly see def product(ary)
<BlaXpirit> in docs, however, it is def product(ary, &block)
<jhass> >> [1, 2, 3].product([4, 5]) do |a, b| p({a, b}); end
<DeBot> jhass: {1, 4}
<jhass> yeah, it yields
<jhass> the docs show it that way then
<jhass> it needs an iterator version
<fowl> is block_given? supported
<BlaXpirit> now... what exactly is the difference between "yields" and "iterator"
<wanderer_> `a = ["-o #{output_filename}"] + object_names + [@link_flags, lib_flags]` ?
<jhass> >> [1, 2, 3].each
<DeBot> jhass: #<Array(T)::Iterator(Int32):0x9015FC0 @array=[1, 2, 3], @index=0>
<fowl> >> def f; block_given?; end; puts f()
<DeBot> fowl: in line 3: undefined local variable or method 'block_given?'
<jhass> >> [1, 2, 3].each.map {|x| x+1 }
<DeBot> jhass: Iterator(T)::Map(Array(T)::Iterator(Int32), Int32, Int32)(@iter=#<Array(T)::Iterator(Int32):0x9320FC0 @array=[1, 2, 3], @index=0>, @func=#<(Int32 -> Int32):0x804A600>)
<BlaXpirit> fowl, maybe you can overload instead
<jhass> >> [1, 2, 3].each.map {|x| x+1 }.to_a
<DeBot> jhass: [2, 3, 4]
<fowl> nice lazy iteration
<jhass> fowl: BlaXpirit yup, we do overloads instead of block_given?
<fowl> jhass, then both functions would show in the docs the same?
<jhass> no, the docs show yielding ones with &block
<fowl> f() and f(&block) both yield so they have &block
<jhass> >> def foo(&block: -> Int32); block.call(1); end; def foo; yield 2; end; foo do |x| puts x; end
<DeBot> jhass: 2
<jhass> same signature -> overrides
<jhass> >> def foo; 1 end; def foo; yield 2; end; {foo, foo {|x| x }}
<DeBot> jhass: {1, 2}
<jhass> different signature -> overloads
<jhass> >> a = [2, 3]; [1, 2].concat(a).concat([3, 4])
<DeBot> jhass: [1, 2, 2, 3, 3, 4]
<jhass> wanderer_: ^
<fowl> jhass, so in the first example the first foo is basically irrelevant (been redefined)
<jhass> yes
<fowl> alright ty
<BlaXpirit> i'd like a way to see a warning for each override. is that possible?
<jhass> asterite doesn't like warnings and I have to agree
<BlaXpirit> that's cool
<BlaXpirit> opt-in
<fowl> lol
<jhass> and then nobody opts in except a few people and you have people yelling at each other which is better/okay
<BlaXpirit> geez i don't care
<jhass> we should as community decide what's okay and what not and either allow it or don't
<BlaXpirit> stop -__-
<BlaXpirit> i my library i don't know, there may be some unintentional overrides
<BlaXpirit> because of lax function signatures
<BlaXpirit> and i want a way to see it
<fowl> the decision making should be a unanimocracy
<BlaXpirit> no need to scold me for that
<jhass> I guess you could hack it into the compiler
<jhass> there should be a place where it detects an override, I'd expect
<BlaXpirit> uh sure
<BlaXpirit> are there even any flags to pass?
<BlaXpirit> yeah, of course there are
<wanderer_> jhass: thx, can [3, 4] also be {3, 4}?
<BlaXpirit> crystal build --show-overrides couldn't hurt anyone
<jhass> wanderer_: no idea, try it
<wanderer_> >> a = [2, 3]; [1, 2].concat(a).concat({3, 4})
<DeBot> wanderer_: [1, 2, 2, 3, 3, 4]
<jhass> >> def foo; 1; end; def foo; previous_def + 1; end; foo
<DeBot> jhass: 2
<wanderer_> >> a = {2, 3}; [1, 2].concat(a).concat({3, 4})
<DeBot> wanderer_: [1, 2, 2, 3, 3, 4]
<jhass> there's also that
<fowl> jhass, any way for a macro to call another macro?
<jhass> fowl: should just work
<jhass> macro expansion is recursive until there are none left
<fowl> i want the inside macro to expand first >_>
<jhass> uh
<jhass> maybe we can solve that in another way? :P
<fowl> i dont need to yet just trying to see if its possible
<jhass> thing is I can't really come up with a usecase, so I'm curious ;)
dhruv has joined #crystal-lang
<fowl> If m1(X) is a macro that receives semantically checked code, X can be a macro invocation or array or something more useful than "X"
Ven has joined #crystal-lang
<jhass> that's the principle, not the usecase ;)
<jhass> I'd be curious about a concrete usecase
<fowl> Ha
<fowl> I use macros in Nim like this, inside a generic function grabProcsym(x.render) pulls the symbol for render() out of that expression and returns it
<BlaXpirit> >> Set[1,2,3] - Set[3,4]
<DeBot> BlaXpirit: Error in line 3: undefined method '[]' for Set(T):Class
<BlaXpirit> >> Set{1,2,3} - Set{3,4}
<DeBot> BlaXpirit: Error in line 3: undefined method '-' for Set(Int32)
<fowl> The function is stored in a vtable to create an interface{} like type
<BlaXpirit> >> Set{1,2,3} .difference Set{3,4}
<DeBot> BlaXpirit: Error in line 3: undefined method 'difference' for Set(Int32)
<BlaXpirit> ...
<jhass> pull request time!
Ven has quit [Read error: Connection reset by peer]
strcmp1 has joined #crystal-lang
sfcgeorge has joined #crystal-lang
<wanderer_> wow, this is so annoying.. when passing all the args via an array I get ENOENT...
<wanderer_> --single-module => it works, not => ENOENT, same code
<BlaXpirit> undefined local variable or method 'retry'
<fowl> jhass: the main use I guess is macros could be typed and participate in overload resolution, can be handy
<BlaXpirit> undefined local variable or method 'b' (did you mean 'b'?)
<BlaXpirit> >> begin; a = 5; rescue; else; p a.to_f; end
<DeBot> BlaXpirit: Error in line 3: undefined method 'to_f' for Nil (did you mean 'to_i'?)
<BlaXpirit> I see this as a bug
<jhass> another PR!
<BlaXpirit> jhass, do you mean you're gonna make those?
<jhass> no, you gonna make those
<BlaXpirit> sure
r0ast has joined #crystal-lang
<jhass> or do you mean you see that a is defined as a bug?
<BlaXpirit> jhass, a can never be nil
<jhass> in this special case
<jhass> may_raise; a = 5; it can, a = may_raise, it can
<BlaXpirit> wut
<fowl> a is out of scope though?
<jhass> no, begin does not start a new scope, afaik
<BlaXpirit> even if it does, both accesses are in that scopr
<fowl> Oh but it doesn't have a type in that branch other than nil
<jhass> so yeah, maybe the compiler could recognize it can't if it's there are no potential raising expressions before it, but I think it's a minor issue
r0ast has quit []
<BlaXpirit> jhass, don't you understand that I used "else"
<wanderer_> jhass: you can create a tempfile, close it and then write to it? when is it deleted then? https://github.com/manastech/crystal/blob/4d7731a188b3e2a71165b963b58014c1d44684c3/src/compiler/crystal/command.cr#L141
<BlaXpirit> which already says that there were no exceptions
<fowl> >> if true; a = 1; end; puts a
<DeBot> fowl: 1
<fowl> Er
<jhass> mh, you're right
<jhass> I didn't understand
<BlaXpirit> maybe didnt' notice the 'else'
<fowl> >> if false; a = 1 ;end; puts a
<DeBot> fowl:
<fowl> Is that nil^
<BlaXpirit> probably
<BlaXpirit> use 'p' instead or not use anything
<BlaXpirit> a = 1 if false; a
<BlaXpirit> >> a = 1 if false; a
<DeBot> BlaXpirit: nil
<BlaXpirit> >> a = 1 if true; a.to_f
<DeBot> BlaXpirit: Error in line 3: undefined method 'to_f' for Nil (did you mean 'to_i'?)
<BlaXpirit> here it is nillable
<BlaXpirit> and that's fine
<jhass> wanderer_: you need to do it explicitly
Ven has joined #crystal-lang
<jhass> calling .delete or File.delete if you just have the path
j0hnnyk has quit [Remote host closed the connection]
<wanderer_> jhass: where is .unlink or .delete called? can't find any
<jhass> if I look at my /tmp/, it still isn't for crystal run or crystal eval
Ven has quit [Read error: Connection reset by peer]
<wanderer_> what do you mean?
<wanderer_> I've read that on linux you can immediately close temp files, then they're unlinked and hidden, but can still be used somehow
<jhass> I'd be curious where you read tha
<jhass> *that
<wanderer_> so crystal doesn't delete it's temp files?
<wanderer_> its
<jhass> doesn't look like it
<wanderer_> so Tempfile.new is only abused for a unique name?
<jhass> I wouldn't call it abused, it's pretty much its purpose
<wanderer_> I would have thought you do Tempfile.new, write to it, etc. then close/delete it
strcmp1 has quit [Ping timeout: 272 seconds]
<wanderer_> instead it's apparently opened and closed immediatly and only the path is taken
<BlaXpirit> how can I check if unpacking operation can work for a type?
<BlaXpirit> should i rely on responds_to? :[]
strcmp1 has joined #crystal-lang
<fowl> I like the Type#[] shortcut for making arrays
<jhass> BlaXpirit: what do you want to do in the else case?
<BlaXpirit> doing some pretty controversial stuff here :|
<wanderer_> jhass: sorry to bother you once again: when I create a sample program that uses `puts "hi"; Tempfile.new("x"); puts "bye"` and Tempfile#initialize has a `puts "hi again"`, then it seems that "hi again" is not printed, why is that?..
strcmp1 has quit [Client Quit]
<jhass> BlaXpirit: mh, I wonder if you could solve that with an overload for the else case and just assume [] in the unrestricted case
<BlaXpirit> jhass, of course that's what I wanted initially
<jhass> but I'd say it's acceptable anyway
<BlaXpirit> but it's too restrictive
<BlaXpirit> I can't specify any type for 2-element case and i can't specify any type for single item case
<BlaXpirit> can't thank you enough, jhass
<jhass> wanderer_: did you put it behind the super?
<jhass> looks like there's a bug where method execution isn't resumed behind super there
<fowl> jhass: are generic methods possible?
<jhass> wanderer_: although I can't reproduce in a minimal example
<jhass> fowl: I think so
<fowl> Generic constraints. I'm looking for a spec but all I see I generic class
<jhass> >> def array_of_type(a : T); [] of T; end; array_of_type("a")
<DeBot> jhass: []
<jhass> >> def array_of_type(a : T); [] of T; end; array_of_type("a").class
<DeBot> jhass: Array(String)
<jhass> >> def array_of_type(a : T); [] of T; end; {array_of_type("a").class, array_of_type(1).class}
<DeBot> jhass: {Array(String), Array(Int32)}
<BlaXpirit> wow
<jhass> wanderer_: okay, funny thing, after the super the puts from IO becomes available on self, so that's called instead
<jhass> STDOUT.puts "hi again" works after the super
<fowl> For any undeclared const? :)
<jhass> fowl: yeah
<jhass> iirc
<jhass> never tried with a non single letter one if I look back
<fowl> >> def arr(a: Set(T)); [] of T ;end; arr({'x','y'}).class
<DeBot> fowl: Error in line 3: no overload matches 'arr' with types {Char, Char}
<wanderer_> jhass: hm, I was calling it before the super, though
<wanderer_> shouldn't matter whether before or after, because it's inherited, isn't it?
<fowl> Should be set.new( damnjt
<jhass> between super and @path it works for me, I guess fd is 0 so it hits stdout or something by accident? before @path the super call fails here because @path may be nil (because we left initialize before setting it)
<BlaXpirit> wait a second...
<fowl> >> def arr(a: Set(T)); [] of T ;end; arr(Set.new('x','y')).class
<DeBot> fowl: Error in line 3: wrong number of arguments for 'Set(T)#initialize' (2 for 0)
<wanderer_> that might be
<BlaXpirit> it sux so much reading ruby documentation and then getting different result :(
<jhass> crystal isn't ruby after all :)
<fowl> It sucks getting nil errors at run time
<BlaXpirit> yeah but i don't see any other docs
<jhass> but Set.new is easy to add
<fowl> Bump that
<BlaXpirit> how do I do hash[key] and get nil instead of error?
<jhass> hash[key]?
<BlaXpirit> o.o
JBat has quit [Ping timeout: 245 seconds]
JBat has joined #crystal-lang
<fowl> >> a = {}
<DeBot> fowl: Syntax error in eval:3: for empty hashes use '{} of KeyType => ValueType'
<fowl> I was trying to make an empty tuple
<jhass> >> Tuple.new
<DeBot> jhass: {}
<fowl> Nice
<fowl> >> Tuple.new(Int32)
<DeBot> fowl: {Int32}
<fowl> Int32.methods
<fowl> >> Int32.methods
<DeBot> fowl: Error in line 3: undefined method 'methods' for Int32:Class
<fowl> >> 0.methods
<DeBot> fowl: Error in line 3: undefined method 'methods' for Int32
<BlaXpirit> btw DeBot responds to private messages
<jhass> yup, intentionally so
<fowl> Word
<vikaton> we also have crystal eval now :P
<BlaXpirit> >> s={a: 5}; s[:b] = 7
<DeBot> BlaXpirit: 7
<jhass> vikaton: hm?
<vikaton> crystal eval 'p 1' is a thing now
<vikaton> cli tool
<jhass> well, since a long time so
<jhass> guess what the bot used all along ;)
<BlaXpirit> crystal eval '1' isn't a thing though
<BlaXpirit> it's crystal exec
<fowl> Is there only single dispatch or is multiple dispatch possible?
<jhass> uh, no, it's eval
<vikaton> oh i never noticied it b4
<BlaXpirit> crystal eval '1' no output
<jhass> yes
<vikaton> cuz ur not outputting anything?
<jhass> crystal eval 'p 1'
<BlaXpirit> >> 1
<DeBot> BlaXpirit: 1
<vikaton> DeBot is special
<jhass> the bot wraps it into a template ;)
<BlaXpirit> the bot does eval
<BlaXpirit> crystal eval does exec
HakanD__ has quit [Ping timeout: 250 seconds]
<BlaXpirit> >> { {1,2} => 3}[{1, 2}]
<DeBot> BlaXpirit: 3
<vikaton> this is so strange :/
<wanderer_> doesn't File.new("bla").fd work?
<vikaton> wats .fd?
<jhass> >> File.new("bla").fd
<DeBot> jhass: Errno: Error opening file 'bla' with mode 'r': No such file or directory
<jhass> >> File.new(".bashrc").fd
<DeBot> jhass: Errno: Error opening file '.bashrc' with mode 'r': No such file or directory
<jhass> >> `ls -a`
<DeBot> jhass: ".\n..\n.crystal\n"
<jhass> >> File.new("/etc/passwd").fd
<DeBot> jhass: 6
<jhass> it does :P
<jhass> eventually
<wanderer_> I must be doing something wrong....
<wanderer_> I'm using `@path = String.new(LibC.wmktemp("#{tmpdir}#{name}.XXXXXX".to_utf16)) super(File.new(@path, "w+").fd, blocking: true)` in Tempfile#initialize
<wanderer_> upon tempfile.close I get bad file descriptor
<jhass> I guess File#finalize closes it
<wanderer_> ?
<wanderer_> the .close call is regular code, it's just not working for me on windows
HakanD__ has joined #crystal-lang
jeromegn has joined #crystal-lang
<wanderer_> just tried to reproduce the error with a minimal example
<wanderer_> works there...
<jhass> probably because the GC doesn't hit in the minimal example
<wanderer_> I'll add finalize and a puts
<wanderer_> why would the gc call it though? it's still referenced
<jhass> note that https://github.com/manastech/crystal/blob/master/src/io/file_descriptor_io.cr#L109 is significant, since File < FileDescriptorIO
<jhass> and no, File.new(...).fd doesn't keep a reference anywhere
<wanderer_> oh, ok
<wanderer_> so should I reference it or what would you do?
<jhass> I'm not sure, I'm thinking just dup it
<jhass> or if you'd do my general platform specific code design, you'd had a function to call...
<jhass> but I'm talking to walls about that, I realized
<fowl> wanderer_, i'm going to sleep, please try to commit your WIP however unworking it is i'll hopefullly be able to cross compile later today
<wanderer_> I'm just about done with the basic stuff
<wanderer_> just need tempfile working and I'll upload it
<fowl> No commit your work to a fork so you can be attributed and get a 5% stake when the language gets bought by amazon
<sfcgeorge> Hi. How would I specify an array of numbers as a type?
<jhass> sfcgeorge: depends on the kind of numbers, Array(Int32)
<jhass> or Array(Int) will work for any kind I guess
<wanderer_> jhass: tried `File.new(@path, "w+").dup.fd`, now after closing there still seems to be an open handle, though
<sfcgeorge> Aaah I see, I was trying to do the Java way `Int32[]`
<sfcgeorge> Thanks :)
<jhass> wanderer_: LibC.dup File.new(@path, "w+").fd ? just guessing...
<wanderer_> however, what if finalize isn't called? then there are two handles open
<wanderer_> fowl: will do
<wanderer_> jhass: hm, apparently it works
<wanderer_> the dup function is `def dup; FileDescriptorIO.new(LibC.dup(fd)); end`, so why didn't `File.new(@path, "w+").dup.fd` work?
<wanderer_> hm, not really working after all
<wanderer_> can't access the file, probably because of a still opened handle
<jhass> wanderer_: with .dup you just create another FileDescriptorIO that closes its fd when GCed
<wanderer_> jhass: now I did `@file = File.new(@path, "w+")` in Tempfile#initialize, would it still get GCed?
<wanderer_> I added Tempfile#close with `@file.close` and I get "closed stream"..
<jhass> no
<wanderer_> is finalize being called after I called #close explicitly?
<wanderer_> so it's closed twice?
<jhass> no
<jhass> oh, well, yes
<jhass> it's called when the object is free'd by the GC
<jhass> doesn't matter what you did to it first
<wanderer_> .. I'm kinda confused
<wanderer_> at least it's working..
<wanderer_> apparently
<sfcgeorge> If there's no eval, I was thinking about dynamically requiring a file on compile. Is there a way to do that, perhaps with a compile flag of the file name to require? Can flags have a KEY=value and can their value be accessed at compile?
<jhass> sfcgeorge: I'm not sure what you seek, ECR perhaps?
<sfcgeorge> On command line I want to do something like `crystal run -D FILE=test code.cr`. In code `require FLAG`. But it sees FLAG as a constant not the value (test)
<sfcgeorge> Can't use ARGV because that's at runtime and can't require at runtime.
<jhass> yeah, don't think you can achieve that atm, I was more asking for the usecase
<sfcgeorge> Ok. Usecase is I wrote a design-as-code tool in Ruby and was trying to port it for speed. A design file is Ruby code, but without any requires for simplicity. So a design file might be `circle(10)` and you run it on the command line, that script then includes the lib for you.
<jhass> I think you're looking for --prelude then
<jhass> mh, or let's look into how Projectfile is parsed
<sfcgeorge> Ooh ok I missed --prelude, that might work. And thanks for the tip to check out Projectfile parsing!
<jhass> so it sets up an additional source file and then calls the compiler
<jhass> since the compiler is essentially a stdlib already you could indeed do your own tool that includes it ;)
<sfcgeorge> Oh. Oh. I'll have to wrap my head around that but it seems like it could be really powerful. So far Crystal seems crazy fast, and macros can mimic most of the Ruby metaprogramming stuff. I'm excited :)
<jhass> :)
asterite has joined #crystal-lang
<asterite> BlaXpirit: about Set{1, 2, 3}, read Array's docs: http://crystal-lang.org/api/Array.html
<asterite> (the overview, it explains it there)
<asterite> wanderer_: did you start using github?
<BlaXpirit> ty
<BlaXpirit> facepalm... how could I be so stupid to use `..` for decreasing range
<jhass> >> 5.to([10, 1].sample) {|x| print x }
<DeBot> jhass: 543215
<jhass> >> 5.to([10, 1].sample) {|x| print x }
<DeBot> jhass: 56789105
<vikaton> the hell is sample
<jhass> I love that method :D
<BlaXpirit> i dont get it
<BlaXpirit> how to get [9,8,7,6] from 9 and 6?
<wanderer_> asterite: hi
<BlaXpirit> >> (6..9).to_a.reverse
<DeBot> BlaXpirit: [9, 8, 7, 6]
<wanderer_> I cloned master a week ago and applied changes to make it work better on windows, what exactly should I do now?
<wanderer_> pull all new commits to make it up-to-date and fork it?
<jhass> wanderer_: did you commit anything yet?
<asterite> The best thing would be to send a pull request against the windows branch, I don't know if you can do that (I guess yet, but I don't know much about github. Probably jhass knows how to do that)
<jhass> yes, totally possible
<jhass> wanderer_: if you answer my questions I can walk you through it ;)
<wanderer_> against the windows branch?
<vikaton> im so confused
<vikaton> with crsytal deps
<wanderer_> the changes I made shouldn't modify the behaviour on linux
<vikaton> idk what to require afterwards
<BlaXpirit> wanderer_, click fork on github
<jhass> wanderer_: first of all, did you commit yet?
<BlaXpirit> git remote add fork https://github.com/wanderer_/crystal
<jhass> BlaXpirit: step 3 & 4 ;)
<BlaXpirit> yeah lol
<wanderer_> I have a local copy in sourcetree, didn't commit to it yet
<jhass> wanderer_: alright, now commit
<jhass> do you have a thing called "git bash" so we don't need to look up how to use sourcetree? :P
<BlaXpirit> wanderer_, wait, what branch are you on?
<wanderer_> I locally cloned the master-branch
<BlaXpirit> so u modified master even though there is a windows branch?
<wanderer_> the windows branch is version 0.6.1
<BlaXpirit> ok
<jhass> asterite: mh, yeah, he started from scratch, merging into the windows branch will be no good
<BlaXpirit> so maybe u want to make branch new-windows
<asterite> No problem
DerisiveLogic has joined #crystal-lang
<wanderer_> because of the libpcl problem I couldn't compile anything newer than 0.6.1, that's why I started with 0.6.1
<jhass> asterite: we can easily push his new branch to manastech/crystal though
<wanderer_> and later applied the changes to master and compiled it with crystal-0.6.1.exe
<BlaXpirit> what u definitely should do is
<BlaXpirit> git checkout -b new-windows; git add as necessary; git commit
<wanderer_> jhass: I'll be back in half an hour, then I quickly gotta review the makefile and then I'll fork crystal and apply the changes
<wanderer_> *1,5h
<jhass> wanderer_: you don't need to copy over stuff or so
<wanderer_> ?
<jhass> we can easily push your stuff from the current clone to where ever
<jhass> you just need to commit it and add remotes accordingly
<wanderer_> err, so do I have to fork or not?
<jhass> yes, but that doesn't mean you have to use a separate working directory locally ;)
<jhass> your fork on github is just a place where you're allowed to push to
asterite has quit [Ping timeout: 246 seconds]
<BlaXpirit> git checkout -b new-windows; git add as necessary; git commit; (click fork crystal on github); git remote add fork https://github.com/wanderer_/crystal; git push fork new-windows
<BlaXpirit> i think that is the basis. merge or rebase as needed, but others can do it too
<wanderer_> my local working copy is the only copy atm, I haven't forked it yet, after forking I wouldn't use it anymore
<jhass> no you would still use it is what I'm saying
<BlaXpirit> wanderer_, if you used git clone , you can keep working with that local copy, it's fine
<BlaXpirit> i do that for all my forks
<BlaXpirit> clone the original repo and add fork as a remote
<wanderer_> k, see you later, then I'll try what you advised
wanderer_ has quit [Quit: Page closed]
<BlaXpirit> >> 5.0 .round .class
<DeBot> BlaXpirit: Float64
<BlaXpirit> i suppose there is no other way...
<jhass> of achieving what exactly?
<BlaXpirit> 5.0 .round .class == Int
<BlaXpirit> in some cases it would be nice, in other it could cause problems
<jhass> yeah, if you want rounding behavior .round.to_i
<jhass> what's with all the spaces in front of your method calls btw recently btw? :P
<BlaXpirit> well actually maybe it is worth changing because one could always do round(0) if they wanted to stay a float
<BlaXpirit> jhass, after 5.0 i couldn't not put a space, and after { | | } .abc
<jhass> dunno, seems weird
asterite has joined #crystal-lang
<jhass> >> 5.0.round.class
<DeBot> jhass: Float64
<jhass> works well?
<BlaXpirit> what do you mean
<BlaXpirit> oh spaces
<asterite> In fact, I think it would be better to make a pull request against master, we definitely want windows support, and that will put the pressure to have it up to date :-)
havenwood has joined #crystal-lang
<BlaXpirit> well sure
<jhass> asterite: you mean like 32bit support? :P
<BlaXpirit> so should we tell the guy to rebase?
<jhass> nah, no rebase for git newbies
<jhass> we can live with the merge commit
<BlaXpirit> i'm a git newbie and i find rebase easier :D
<jhass> you understood git remotes, you're not ;)
<asterite> jhass: Yes! We should have travis run for 32 bits too
<jhass> asterite: do you know a way? I thought about it yesterday but couldn't come up with anything
<jhass> tried chroot, but 32bit chroot on a 64bit machine and crystal fails completely in it
<jhass> patching up the linker to multilib fails too, even with crosscompile flags
<asterite> jhass: travis doesn't support 32 bits?
<jhass> nope
<asterite> Ugh
<asterite> Be right back
asterite has quit [Ping timeout: 246 seconds]
dhruv has quit [Ping timeout: 240 seconds]
willlll has joined #crystal-lang
asterite has joined #crystal-lang
<asterite> Maybe I can have a 32bits VM and run the specs there from time to time
<asterite> Or maybe drone.io supports 32 bits
<jhass> or maybe we find a way to link on a 64bit host, either with multilib or with a chroot
j0hnnyk has joined #crystal-lang
asterite has quit [Ping timeout: 246 seconds]
j0hnnyk has quit [Read error: Connection reset by peer]
j0hnnyk has joined #crystal-lang
<vikaton> argh
<vikaton> where did asterite go?
j0hnnyk_ has joined #crystal-lang
j0hnnyk has quit [Read error: Connection reset by peer]
<BlaXpirit> he's rarely in irc. he looks at logs
j0hnnyk_ has quit [Remote host closed the connection]
<BlaXpirit> > assuming "he"
j0hnnyk has joined #crystal-lang
j0hnnyk has quit [Remote host closed the connection]
<vikaton> well asterite, if you are reading the logs, -> https://github.com/manastech/crystal/issues/611
j0hnnyk has joined #crystal-lang
<jhass> vikaton: seriously, stop working as root
<jhass> seriously.
<vikaton> what does that ahve to do with the error?
<jhass> nothing
<vikaton> I will i guess, when I fix this
ssvb has quit [Quit: Leaving]
strcmp1 has joined #crystal-lang
Ven has joined #crystal-lang
zipR4ND has joined #crystal-lang
Ven has quit [Read error: Connection reset by peer]
Ven has joined #crystal-lang
HakanD__ has quit [Ping timeout: 272 seconds]
Ven has quit [Ping timeout: 256 seconds]
<sfcgeorge> I got embedding the compiler to work with require `"compiler/crystal/**"` but it only works with `crystal run`. If I `crystal build` then run the `./executable` I get "Error while requiring "prelude": can't find file 'prelude'" — what's the prelude and should I require it manually or something?
<jhass> mh, I guess you need to manually set ENV['CRYSTAL_CONFIG_PATH']
<jhass> and I don't think we have a way to access the value of the host compiler yet :/
<jhass> well, or set CRYSTAL_PATH when invoking your compiler
<jhass> I wonder how the specs or ecr does it.. mmh
<sfcgeorge> I'm not seeing any mention of Crystal::Compiler in specs or ecr
<jhass> so not sure why it's not working for you :/
<jhass> we really should have a way to inspect the compiler config from a program that's being compiled though anyway
<sfcgeorge> That's roughly the code I have. I see spec_helper.cr is setting CRYSTAL_PATH at the top.
<jhass> oh, indeed
dhruv has joined #crystal-lang
dhruv has quit [Quit: Leaving]
waterlink has joined #crystal-lang
<sfcgeorge> Hmm well I set the path in my term with `export CRYSTAL_PATH=/usr/local/Cellar/crystal/0.7.1/src` and now running the executable I get a different error "ld: library not found for -levent
<sfcgeorge> clang: error: linker command failed with exit code 1 (use -v to see invocation)
<sfcgeorge> Error: execution of command failed with code: 1:" And then the error goes on with lots of file names that don't exist, it seems to be looking for a "foo" file which is the name I used in this line `sources = Crystal::Compiler::Source.new("foo", %(p "foo"))` so am I using it wrong? As I said it works (prints "foo") when using the `run` command.
<havenwood> Nice to see Matz taking notice of Crystal :) https://twitter.com/yukihiro_matz/status/594536493831495682
<havenwood> 0.7.0 \o/
<sfcgeorge> Nice!
<sfcgeorge> A gist of my code & failing commands: https://gist.github.com/sfcgeorge/2a2e872ee7c3c092be17
<zipR4ND> hi, after the upgrade of crystal the compiler complains: "./libs/openssl/lib_crypto.cr:3: Bio is already defined" .. i am requiring a local copy of openssl where i made some changes ... is there a way to make my local changes work without changing code under /opt/crystal/src ?
asterite has joined #crystal-lang
<asterite> sfcgeorge: you need to install libevent
<vikaton> asterite !
<asterite> crystal comes with it statically linked so it works, but once you compile a compiler it doesn't statically link it automatically
<asterite> but our release managed does that
<vikaton> did you see my issue?
<sfcgeorge> Aaah okay, thank you I'll try it :)
<asterite> Yes, I replied. I have no idea why that happens to you
<asterite> You can try to check the things I replied in the issue
<vikaton> hm
<zipR4ND> asterite: i have this problem of the compiler complaining that i define an already defined struct (openssl binding). i have a copy of openssl in my workdir and made some changes, any idea on how to fix that without changing the files unde /opt/crystal/src ?
<asterite> an already defined constant, or struct?
<waterlink> Trying to update mocks.cr to crystal 0.7.1, and this macro is not working anymore, ant clue what is wrong?: https://gist.github.com/waterlink/b4f245d9a4e9cb77f245
<asterite> reopening a struct should work, I think
<vikaton> asterite: http://prntscr.com/70plgj
<sfcgeorge> Ok gets a little further thanks, now "ld: library not found for -lgc" so which library do I need for lgc?
<zipR4ND> hmm, it did in 0.6.* but now the compiler says: http://pastebin.com/qkB49zKr
<vikaton> this is very saddening
DerisiveLogic has quit [Remote host closed the connection]
asterite has quit [Quit: Page closed]
<waterlink> So how does one do now and Array(Object) ?
<waterlink> or how to say Array(i don't care about type)
<jhass> vikaton: provide the full error output (original command, not --single-module, not manual cc call), including invocation, including command prompt, including following command prompt
<sfcgeorge> Found it (on an old Crystal chat-log no less), I needed bdw-gc as well as libgc, now dynamic compilation works :D thanks all
<jhass> I have a hunch you only show a part of it
<jhass> waterlink: well, I think it was just allowed, we need to find different solutions now
<jhass> *just disallowed
<BlaXpirit> aww yiss. graphical and fully animated 2048 https://github.com/BlaXpirit/crsfml-examples/blob/master/2048/2048.cr
<BlaXpirit> in less lines of code than the terminal version
<jhass> :P
<jhass> I had to do all the terminally stuff on my own!
<jhass> mmh, in ./libs/crsfml/system.cr:59: undefined method '[]' for Float64
<jhass> deps not updated?
<waterlink> So is it possible to say now in crystal, that I want this thing to be of any type that supports #== ?
<jhass> I don't think so :/
<BlaXpirit> oops deps probably not updated indeed
blaix has joined #crystal-lang
<BlaXpirit> updated now
<vikaton> I hope thats what u wanted
blaix has quit [Client Quit]
<waterlink> yes, I got it ;)
<waterlink> It is still possible
<waterlink> if you create a class for that :)
<jhass> vikaton: gosh, seriously, ssh password login for root?
<vikaton> bruhhh
<BlaXpirit> :D
<jhass> shall I throw a rainbow table at it?
<vikaton> jhass, I promise to do w/e security measure on box once I fix this issue
<jhass> how much ram does it have? how did you install crystal?
<BlaXpirit> hmm should i record some gif?
<jhass> 115.54.151.46.in-addr.arpa. 800 IN PTR cock.com.
<waterlink> jhass: this solves the problem with working with any type that supports #== : https://gist.github.com/waterlink/8668a0df36cd2dae6b4b
<jhass> ...
<vikaton> remember thats not my VPS
<jhass> waterlink: good catch
<jhass> vikaton: that makes it only worse
<jhass> and I suspect it might be just a ram issue
<jhass> get tmux and launch htop in a second pane
<vikaton> wait w0t
<vikaton> I guess it is
<vikaton> its the only logical reason
DerisiveLogic has joined #crystal-lang
<jhass> if you want to pair with me give me your public SSH key
<waterlink> you can use tmate.io for pairing )
<vikaton> jhass, :/
<vikaton> brb
<vikaton> actaully
<vikaton> bbl
<sfcgeorge> Wow BlaXpirit that 2048 demo is great! I'm pretty convinced about Crystal now :)
<BlaXpirit> ty
<waterlink> sfcgeorge: hi :), yes crystal is a real thing :D
<sfcgeorge> waterlink hi :) Hah yes it does seem to be! I haven't been this excited about a language since I found Ruby. Macros and speed were the 2 things I found missing most from Ruby and it has them! :D
<jhass> the 1024 overflows the tile though :P
<BlaXpirit> oh.
havenwood has quit []
DerisiveLogic has quit [Remote host closed the connection]
DerisiveLogic has joined #crystal-lang
Ven has joined #crystal-lang
Ven has quit [Read error: Connection reset by peer]
ponga has quit [Quit: Leaving...]
Ven has joined #crystal-lang
JBat has quit [Quit: Computer has gone to sleep.]
Ven has quit [Read error: Connection reset by peer]
havenwood has joined #crystal-lang
Ven has joined #crystal-lang
Ven has quit [Read error: Connection reset by peer]
Ven has joined #crystal-lang
wanderer_ has joined #crystal-lang
Ven has quit [Read error: Connection reset by peer]
Ven has joined #crystal-lang
Ven has quit [Read error: Connection reset by peer]
Ven has joined #crystal-lang
Ven has quit [Read error: Connection reset by peer]
Ven has joined #crystal-lang
<epitron> BlaXpirit: nice demos!
<BlaXpirit> ty
<epitron> Heh, that's a lot of layers of bindings
<epitron> C++ to C to crystal to crystal objects
<BlaXpirit> hm indeed
<BlaXpirit> i have yet to test the performance
<epitron> I wonder if there's a way to cut out the middle man
<epitron> I'm thinking about maintenance
<epitron> The more layers, the more things that have to be updated when sfml changes
<BlaXpirit> well crystal can't have c++ bindings, can it?
<epitron> Not yet!
<BlaXpirit> i don't think it's worth it. it's waaay too much work
<epitron> So the c++ objects are too mismatched from crystal's?
<BlaXpirit> maybe, maybe not
<BlaXpirit> the main problem is C++ is too bloated
<BlaXpirit> i'm much better equipped for C anyway
<epitron> Sure, but putting more layers on top of the c++ isn't going to fix that
<BlaXpirit> you may not have noticed that almost all parts of the library are generated
<epitron> Okay... I'm guessing everything but the crystal objects
<BlaXpirit> everything but convenience additions to the crystal objects :D
<epitron> I see!
<epitron> That sounds pretty easy to maintain then
<BlaXpirit> CSFML, however, will need to be updated. last update actually took quite some time
<BlaXpirit> but seeing as Rust's bindings rely on it... :p
BlaXpirit_ has joined #crystal-lang
Ven has quit [Read error: Connection reset by peer]
BlaXpirit_ has quit [Quit: Quit Konversation]
<wanderer_> jhass: tv_set of timespec is either 4 bytes or 8 bytes, isn't it? at least it's defined as this, in event.cr for example it gets set to `time.to_i64` which would obviously be wrong when it's 4 bytes
<waterlink> Shit, so why `String` is not recognized as `String+` type?
<waterlink> ** shit was just an emotion **
<waterlink> I see. It happens only if you have a middleman method, that accepts a Union and then delegates to someone else (where switch on type happens)
<waterlink> that is kinda frustrating
<waterlink> But probably because of magic I'm doing with deriving from `String`, was a bad idea
<sfcgeorge> Ok I'm stuck with an odd on. I have an array, I can `p` print it and see its contents. I can see from `p nodes.class` it is of type "Array(VectorSalad::StandardShapes::N)". But as soon as I try to get an element with square brackets, or even call `to_a` on it there's a crash with "undefined method 'to_a' for Nil". So when is an array not an array?
<waterlink> You need to init this array in `initialize`
<waterlink> otherwise its type for compiler is: `Array(YourType)|Nil`
<waterlink> Or, if you know what you are doing, you can call `not_nil!` on it
<waterlink> This concept is so called nillable
<sfcgeorge> But it is initialised if I can see it's contents right? And | Nil wasn't in the .class, or does that not show the same at its type?
<waterlink> when you do `puts` or `.class` it is runtime
<waterlink> undefined method happens at compile time
<waterlink> can you show piece of code (paste or gist) ?
<waterlink> basically `|Nil` will never appear in `.class` :)
<waterlink> or any other union
<sfcgeorge> Ah okay. I read about nillable and union, I think I'm getting it.I declared it as "@nodes = [] of VectorSalad::StandardShapes::N" and then access it through a getter.
<waterlink> where have you declared it ?
<waterlink> in `#initialize`, `#certain_method` or global scope?
<sfcgeorge> Waaait, I think I see what's happening. (porting from Ruby to Crystal BTW so I know the logic is sound). Circle < Path. Path has @nodes in it's `initialize` but Circle doesn't initialize @nodes. So maybe the compiler thinks it could be nil in Circle.
<sfcgeorge> I get this slightly broken error message: "Error: instance variable '@nodes' of VectorSalad::StandardShapes::Path was not initialized in all of the 'initialize' methods, rendering it nilableinstance variable '@nodes' of VectorSalad::StandardShapes::Circle was not initialized in all of the 'initialize' methods, rendering it nilable."
<waterlink> Exactly, whenever you use `@instance_variable` that is not initialized in `#initialize`, compiler auto-marks it as a `|Nil`
<waterlink> If you are using lazy-initialization methods, then you can do that:
<waterlink> >> class X; def i_am_lazy; @_i_am_lazy ||= 3; end; end
<DeBot> waterlink: nil
<waterlink> strange, I was expecting error..
<wanderer_> jhass: ah, k, I simply did `t.tv_sec = LibC::TimeT.cast(time)`
<waterlink> >> class X; def i_am_lazy; @_i_am_lazy ||= [] of Int32; end; end; X.new.i_am_lazy
<DeBot> waterlink: []
<waterlink> That wasn't working for me before, strange..
<sfcgeorge> But I'm not actually accessing @nodes anywhere in Circle. Circle has a to_path method that does Path.new then gets the nodes from that with a getter. So I'm not sure why the compiler is making it nullable, I have initialized @nodes in all of the Path constructors.
<waterlink> but circle has its own @nodes ?
<sfcgeorge> Yes because it inherits from Path, but it's not Circle's @nodes that I'm accessing
<waterlink> Ah, I see
<waterlink> but Circle has some method inherited from Path that uses @nodes ?
<fowl> Circle descends from Path? :/
<waterlink> Do you call super from Circle's constructors ?
<sfcgeorge> Ok I stopped inheriting from Path (I can't actually remember why I did it in the first place) and now the error has gone. I still find it odd though
<waterlink> No, probably you had a derived method, that you haven't overridden, that have been using @nodes. You wasn't actually using that method. But for compiler it was there and potentially can be called. And @nodes might be not initialized at this point of time.
<waterlink> So you got @nodes nillable
<waterlink> *nilable
<sfcgeorge> Aaah, yes plenty of methods in Path use @nodes, Circle didn't instantiate @nodes as it never uses them, but compiler saw that Circle could potentially use the un-instantiated @nodes thus it was Nilable. You're right, thank you!
<sfcgeorge> In a roundabout way the compiler was telling me my design was silly ;)
<sfcgeorge> Drat, `responds_to?` is at compile time isn't it?
<sfcgeorge> Never mind I found a static way to do what I wanted. Yay it appears that I can make Crystal work for this port, despite the original Ruby version being heavily metaprogrammed.
<vikaton> jhass: whats htop?
<jhass> top in pretty
<vikaton> well I have 2 panels from tmux
<vikaton> what do u want me to do now (to fix the issue)
<vikaton> or are u convinced its a RAM issue
<jhass> run htop in one
<jhass> and the reproduce the issue in the other
<jhass> watch memory usage
<vikaton> ok
<vikaton> apt-utils is not installed
<vikaton> if thats important
<waterlink> sfcgeorge: yeah, in crystal you will have to resort to macroses or create more classes ;)
<sfcgeorge> waterlink: I'm loving macros :)
<waterlink> I like about them the fact, that you can nest macroses. ie: macro that defines macro, that defines macro ...
<waterlink> which gives lot more power than ruby :D
<waterlink> and they are scoped. Meaning that if you define macro in class or module. Then it will be possible to use it in that class/module body and all descendants' bodies
zz_Cidan is now known as Cidan
<sfcgeorge> Mmm they're impressive, and I'm sure I've only scratched the surface.
<sfcgeorge> "splatting a union (Array(VectorSalad::StandardShapes::N)) is not yet supported" —but why is that a union? Surely it's just 1 type?
<waterlink> ehm?
<waterlink> sounds like a bug
<waterlink> but why would you want to splat such a thing?
<vikaton> jhass, im having trouble swtiching panes :P
<jhass> Ctrl+B, release, arrow keys
<sfcgeorge> Well, I initiate an array of nodes "nodes = [] of VectorSalad::StandardShapes::N", then I build it up adding nodes with some logic in a loop, finally I construct a new Path from those nodes.
<vikaton> o
<vikaton> thanks
<sfcgeorge> A Path is `initialize(*nodes)` basically. E.g. Path.new([0, 0], [0, 1], [1, 1], [1, 0]). So should I open an issue or have I accidentally created a union somehow?
<sfcgeorge> oh wait maybe the error is referring to the recieving splat in Path not the sending splat. Because Path takes a splat of Array(Int64) | VectorSalad::StandardShapes::N which is a union. I guess it can't do sending a splat into a union splat.
Ven has joined #crystal-lang
<waterlink> Yeah, just convert these splats to normal array arguments maybe
<sfcgeorge> Then the API will be ugly ;(
<waterlink> or you can try to define method twice with type restriction (overloading)
<sfcgeorge> I could expose @nodes with a setter and shove them in that way, but initialize does validations I'd rather not bypass.
<waterlink> can you define initialize 2 times ?
<waterlink> with type restriction?
<sfcgeorge> Ah! Your idea of overloading might work. Nice API way for humans, array args way for internal use
<sfcgeorge> Or type restriction, either way I'll try your overloading suggestion thanks :)
Ven has quit [Read error: Connection reset by peer]
<vikaton> jhass, ram does spike
Cidan is now known as zz_Cidan
Ven has joined #crystal-lang
Ven has quit [Read error: Connection reset by peer]
DerisiveLogic has quit [Remote host closed the connection]
DerisiveLogic has joined #crystal-lang
<sfcgeorge> Am I missing something obvious, Crystal isn't using the right overload yet it suggests the right one? http://f.cl.ly/items/1C13060q1k242P0X1n3s/in%20srcvectorsaladstandardshape.txt
<waterlink> why do you need overload without options?
<waterlink> you already have the default value of {} for it
<waterlink> probably it is a compiler bug
<waterlink> it is really confusing in this case for compiler probably
<sfcgeorge> Defaults don't work with splat it seems :-/
<sfcgeorge> So to work around the not allowing splatting in some cases, and not allowing defaults after splats, I need lots of overloads and it gets messy
<waterlink> so you are trying to pass in optional args with splat?
<sfcgeorge> Well in ruby the sig was initialize(*nodes, closed: true, **options), but Crystal doesn't have doublesplat and I'm struggling to convert
<waterlink> what about initialize(*nodes, options) ?
<vikaton> jhass, http://prntscr.com/70uaen
<sfcgeorge> waterlink that's basically what I've resorted to
<sfcgeorge> Is there a way to ignore the union types not having all methods error? "undefined method '[]' for VectorSalad::StandardShapes::N node = nodes[i].is_a?(Array) ? N.new(nodes[i][0], nodes[i][1]) : nodes[i]"
<waterlink> yes, defining this method :)
<waterlink> ah
<waterlink> you are doing switch on type
<waterlink> so
<waterlink> `node = nodes[i]; node = N.new(nodes[i][0], nodes[i][1]) if node.is_a?(Array)`
<waterlink> or just `node = N.lift(nodes[i])` and `N.lift` does switch on type
<waterlink> in case of Array it constructs N object, in case of N it just returns it
<waterlink> and in `N.lift` you would actually do method overload to make types compile-enforced )
<waterlink> But to answer your original question: there are multiple ways to narrow down a union. One of them is to use `expression as Klass`
<waterlink> Other is to create additional method with type restriction (and probably overload) and pass it in
<sfcgeorge> I get the same error with your solution, weird: "undefined method '[]' for VectorSalad::StandardShapes::N node = nodes[i]; node = N.new(nodes[i][0], nodes[i][1]) if node.is_a?(Array)"
<sfcgeorge> with the little error arrow pointing to the [0]
<waterlink> I see, try this one: `node = if nodes[i].is_a?(Array) node_a = nodes[i] as Array(Int32); N.new(node_a[0], node_b[1]); else nodes[i]; end`
<waterlink> *node_b = node_a
<waterlink> and in original suggestion it was supposed to be `node[0]` instead `nodes[i][0]` - my bad. But even if fixed will probably fail with same error.
<waterlink> I think lifting solution is better, so you just make class `N` responsible for construction its value from raw values (Array[2]|N)
<sfcgeorge> That was the error actually, I just found it too
<sfcgeorge> From the docs: "This doesn’t work with instance variables, class variables or global variables. To work with these, first assign them to a variable" — I guess arrays also don't work
<waterlink> it should not be necessary `N.lift`, could be `N.build_from`
<sfcgeorge> well nodes[i][0] doesn't work and node[0] does
<waterlink> but nodes is a getter, right?
<waterlink> or parameter to function?
<sfcgeorge> Nope it's just a parameter "nodes : Array(VectorSalad::StandardShapes::N | Array(Float64))"
<waterlink> oh, strange that this works
<sfcgeorge> I guess the compiler enforces it based on only local variables. Could be improved in future probably.
<waterlink> Could be a bug of compiler that it is not working this way. Or could be that it is not working with short form `cond ? expr_a : expr_b` at all.
<sfcgeorge> Doesn't work in long form if either. So I guess it's just a todo.
<waterlink> ok
<sfcgeorge> I don't remember having that kind of issue in Java that's all
<waterlink> does java have unions like that?
<waterlink> yep, java does it through inheritance
<sfcgeorge> What does `as` do, is that for typecasting?
<BlaXpirit> i never really write comments in my code
<BlaXpirit> but it's damn nice!
<BlaXpirit> just explained my code to myself :3
<waterlink> yes it is like a typecasting
<waterlink> I don't really know what will happen if you typecast with `as` and in runtime it will be a different type (never tried)
<sfcgeorge> I just had to do it as I'm modifying the array as I go along so I know all elements are of type N but is started as a union, and during the loop I look at the previous ones (which I know must be N but the compiler doesn't) so I have to cast them.
<waterlink> yes, that is how it works
<waterlink> when you know what it is, but compiler doesn't
<willlll> In a macro, is it possible to get the line number of the caller?
<waterlink> And it actually throws compile error if you use `as` but compiler knows that type is different
<sfcgeorge> Yep :) Nice that it throws if it really knows best
<waterlink> willlll: yes. You just do this: `macro some_macro(arg_a, arg_b, file = __FILE__, line = __LINE__)`
BlaXpirit_ has joined #crystal-lang
<willlll> waterlink: great thanks! now my macro specs have the correct line when they fail :)
<wanderer_> jhass: hi, I now made the commit to my local copy
BlaXpirit has quit [Ping timeout: 256 seconds]
DerisiveLogic has quit [Remote host closed the connection]
<vikaton> :(
BlaXpirit_ has quit [Quit: Quit Konversation]
<waterlink> vikaton: look at your ./libs/ directory. The folder you have there is probably what you need to put in require
<vikaton> waterlink so I have to put the dir?
<waterlink> lets go with example
<waterlink> Imagine you have `dep "john/example.cr"`. After crystal deps, it installs `./libs/example`. So you just do `require "example"`
<vikaton> what about when u crystal init app?
<vikaton> the src code is in a different dir than the lib folder
<waterlink> There could be an exception, if `./libs/example` does not contain `./libs/example/example.cr`, in this case you will have to do `require "example/filename"`
<waterlink> what do you mean?
<vikaton> oo
<waterlink> app and lib are different only by gitignore currently )
<vikaton> waterlink: http://prntscr.com/70utrt
<vikaton> does ur example still apply?
<vikaton> apparently not
<waterlink> I don't understand what you are showing here..
<waterlink> is it in ./libs ?
<waterlink> or is it in .deps ?
<vikaton> libs is in
<waterlink> or is it just a checkout of moonshine?