jhass changed the topic of #crystal-lang to: The Crystal programming language | http://crystal-lang.org | Crystal 0.7.1 | Paste > 3 lines of text to https://gist.github.com | GH: https://github.com/manastech/crystal - Docs: http://crystal-lang.org/docs/ | API: http://crystal-lang.org/api/ | Logs: http://irclog.whitequark.org/crystal-lang
bcardiff has quit [Quit: Leaving.]
canhtak has quit [Quit: canhtak]
zz_Cidan is now known as Cidan
waterlink1 has quit [Ping timeout: 255 seconds]
havenwood has quit [Ping timeout: 252 seconds]
willlll has quit [Quit: willlll]
willlll has joined #crystal-lang
vikaton has quit []
vikaton has joined #crystal-lang
<vikaton> Does crystal have chain comparisons?
<vikaton> >> "Hello" "World"
<DeBot> vikaton: Syntax error in eval:3: unexpected token: DELIMITER_START
<vikaton> >> [1,2,3,4,5][-1]
<DeBot> vikaton: 5
havenwood has joined #crystal-lang
willlll has quit [Quit: willlll]
willlll has joined #crystal-lang
vikaton has quit []
broz has quit [Remote host closed the connection]
bcardiff has joined #crystal-lang
bcardiff has quit [Client Quit]
JBat has joined #crystal-lang
datanoise has joined #crystal-lang
havenwood has quit [Ping timeout: 256 seconds]
willlll has quit [Quit: willlll]
havenwood has joined #crystal-lang
canhtak has joined #crystal-lang
datanoise has quit [Ping timeout: 245 seconds]
willlll has joined #crystal-lang
strcmp1 has quit [Ping timeout: 276 seconds]
BlaXpirit has joined #crystal-lang
willlll has quit [Quit: willlll]
bcardiff has joined #crystal-lang
havenwood has quit [Ping timeout: 264 seconds]
Cidan is now known as zz_Cidan
bcardiff has quit [Quit: Leaving.]
<BlaXpirit> I often wonder how optimized some things are
<BlaXpirit> is `5.to_i32` a noop?
<BlaXpirit> is `if responds_to?` evaluated at compile time?
sardaukar has joined #crystal-lang
<BlaXpirit> in my bindings i ended up with code like this https://bpaste.net/show/5acd0d924661
<BlaXpirit> any better way to do this?
<BlaXpirit> woops, that 2nd line is gone
canhtak has quit [Quit: canhtak]
canhtak has joined #crystal-lang
canhtak has quit [Quit: canhtak]
canhtak has joined #crystal-lang
datanoise has joined #crystal-lang
leafybasil has quit [Remote host closed the connection]
<jeromegn> hey datanoise :)
<jeromegn> just got the specs passing locally
BlaXpirit has quit [Quit: Quit Konversation]
leafybasil has joined #crystal-lang
leafybasil has quit [Ping timeout: 272 seconds]
BlaXpirit has joined #crystal-lang
waj has joined #crystal-lang
<datanoise> jeromegn: great
<jeromegn> datanoise: I was thinking of separating the BSON class into mutliple files. if you don't mind. also, how about a separate repo altogether?
<datanoise> jeromegn: i'm ok with that. would it require using git submodule in this case?
<jhass> no, you'd use the crystal deps feature
bcardiff has joined #crystal-lang
<datanoise> i need to read on that. never used it before
leafybasil has joined #crystal-lang
<jhass> it basically just clones and symlinks stuff into the default load path when you run crystal deps
<jhass> for now
<datanoise> i see, so i need to add libs folder to gitignore
<jhass> yeah
canhtak has quit [Remote host closed the connection]
canhtak has joined #crystal-lang
willlll has joined #crystal-lang
waj has quit [Quit: waj]
canhtak has quit [Quit: canhtak]
bcardiff has quit [Quit: Leaving.]
canhtak has joined #crystal-lang
strcmp1 has joined #crystal-lang
canhtak has quit [Quit: canhtak]
BlaXpirit has quit [Remote host closed the connection]
DerisiveLogic has quit [Ping timeout: 255 seconds]
BlaXpirit has joined #crystal-lang
havenwood has joined #crystal-lang
zz_Cidan is now known as Cidan
havenwood has quit [Ping timeout: 240 seconds]
waterlink has joined #crystal-lang
havenwood has joined #crystal-lang
datanoise has quit [Ping timeout: 240 seconds]
mah has joined #crystal-lang
<jeromegn> is it possible to have variable return values for procs?
<jeromegn> like V
mah has quit [Client Quit]
<jhass> yeah, I think it accepts a free var there
<jhass> >> def foo(bar : ->); puts bar.call; end; foo(-> { 1 });
<DeBot> jhass: in /usr/lib/crystal/io.cr:180: undefined method 'to_s' for Void
<jhass> >> def foo(bar : -> R); puts bar.call; end; foo(-> { 1 });
<DeBot> jhass: 1
<jhass> >> def foo(bar : -> R); puts bar.call; end; foo(-> { "1" });
<DeBot> jhass: 1
<jeromegn> free var, interesting
<jeromegn> are those documented somewhere?
<jhass> no idea if we really call them like that :P
<jhass> ah, we actually do :D
<jeromegn> nice
<jeromegn> thanks!
<crystal-gh> [crystal] asterite pushed 2 new commits to master: http://git.io/vUCyf
<crystal-gh> crystal/master 8140320 Sergio Gil Pérez de la Manga: Iterator#cons(n)
<crystal-gh> crystal/master 895b06b Ary Borenszweig: Merge pull request #648 from porras/each-cons...
<crystal-gh> [crystal] asterite closed pull request #649: Documentation for most methods in Enumerable (master...enumerable-docs) http://git.io/vUspo
kulelu88 has joined #crystal-lang
<travis-ci> manastech/crystal#2330 (master - 895b06b : Ary Borenszweig): The build was fixed.
<sardaukar> is there a way to get the current file path of a lib being required via deps?
<travis-ci> manastech/crystal#2331 (master - aae059c : Ary Borenszweig): The build was fixed.
<jhass> there are the __FILE__ and __DIR__ magic constants being replaced with the current file
HakanD has joined #crystal-lang
<sardaukar> so, if I have a lib and I want to set it’s “root” folder, will that work?
<sardaukar> picture Rails.root
<sardaukar> could I set that on a lib I’m depping?
<jhass> I'm not sure if I'm following
<sardaukar> all I get with __FILE__ is the libs location (after being depped)
<sardaukar> I want to set, on my lib, a #root method, so I can render a view relative to the lib’s location
<sardaukar> oh wait, the whole lib gets imported
<sardaukar> nevermind! :D
datanoise has joined #crystal-lang
<sardaukar> does anyone here tried using Bunny? https://github.com/samsheff/Bunny
<sardaukar> I keep getting in ./libs/bunny/bunny.cr:12: undefined method 'replace' for String
<jhass> last real update in september...
<sardaukar> so it’s gsub now? was it ever replace?
<jhass> crystal moved on a lot since ;)
<jhass> I guess
<sardaukar> there’s a commit 8 days ago
<jeromegn> >> class Foo; def bar;
<DeBot> jeromegn: Syntax error in eval:5: expecting identifier 'end', not 'rescue'
<jeromegn> oops
<jhass> yes, saying "use ecr instead", effectively
<jeromegn> >> class Foo; def bar; "hello"; end; def call; with self yield; end; end; Foo.new.call { bar }
<DeBot> jeromegn: "hello"
<sardaukar> oh ok. I’ll try that
<jeromegn> >> class Foo; def bar; "hello"; end; def call(&block); instance_eval &block; end; end; Foo.new.call { bar }
<DeBot> jeromegn: Error in line 3: undefined local variable or method 'bar'
bcardiff has joined #crystal-lang
<jeromegn> >> class Foo; def bar; "hello"; end; def call; with self yield; end; end; proc = -> { bar }; Foo.new.call &proc
<DeBot> jeromegn: Error in line 3: undefined local variable or method 'bar'
<jeromegn> yea...
<jhass> yeah, with x yield doesn't work for Procs
<jhass> blocks only for now
<jeromegn> :(
<jeromegn> I thought they were the same
<sardaukar> is ECR working at the moment? I get “can’t define def inside def” :/
<crystal-gh> [crystal] asterite pushed 2 new commits to master: http://git.io/vUCFg
<crystal-gh> crystal/master e62f9a1 Ary Borenszweig: Moved Enumerable method that rely on an `each` method returning an Iterator to a new Iterable interface. Also: added an overview for the Enumerable module.
<crystal-gh> crystal/master 4cb719e Ary Borenszweig: Fixed #647: Calling singleton method in lambda inside module causes internal compilation error
<jhass> sounds like you call the ecr_file macro inside a method
<jhass> there use the embed_ecr macro instead
<jeromegn> >> class Foo; def bar; "hello"; end; def call(&block); instance_eval &block; end; end; proc = -> { bar }; Foo.new.call &proc
<DeBot> jeromegn: Error in line 3: undefined local variable or method 'bar'
asterite has joined #crystal-lang
vikaton has joined #crystal-lang
asterite has quit [Client Quit]
<vikaton> Question: is (0..15).each faster than 15.times ?
<jhass> I wouldn't think so
<jhass> but benchmark
<jhass> doubt you'll measure much of a difference in release mode
<sardaukar> embed_ecr needs a StringIO, right?
<jhass> you can wrap it into a String.build for example, yeah
asterite has joined #crystal-lang
<asterite> vikaton: no difference, llvm optimizes the hell out of both. But as jhass says, benchmark and see
<sardaukar> yeah, but I get undefined marco variable view_file
<vikaton> ah :)
<asterite> BlaXpirit: 1.to_i32 is a no-op. You can always do `fun foo : Int32; 1.to_i32; end` and compile in --release --emit llvm-ir (or asm) and see
<sardaukar> jhass: http://paste.mrzyx.de/ppzoplezy :/
<BlaXpirit> nice
<asterite> Finally, I'm slowly documenting things in the official docs, so hopefully in two or three weaks most of the answers and doubts will be there
<asterite> Have a nice day ;-)
asterite has quit [Client Quit]
<vikaton> you too
<jhass> sardaukar: embed_ecr is a macro, view_file is a runtime variable
<jhass> macros are evaluated at compile time
<sardaukar> crap, yeah
<sardaukar> I have to take the same approach as with the routes for the views
JBat has quit [Quit: Computer has gone to sleep.]
<vikaton> In the meantime, check out the little things I ddi with Crystal webdev :P
<sardaukar> is there a way to get the current class and method in a macro? I could make the render calls on the controllers expand at compile time
<sardaukar> vikaton: pretty cool :D
<vikaton> sardaukar: thanks :P
<sardaukar> how did you deploy it?
<vikaton> a bash script that runs "crystal server.cr --release" in the bg
<jhass> how are you supposed to copy paste the password? :P
<vikaton> yeahh I gotta fix that :/
<travis-ci> manastech/crystal#2332 (master - 4cb719e : Ary Borenszweig): The build was broken.
<vikaton> I'm using this for my project in Java class in HS
<vikaton> since AP Java is over
<sardaukar> so, is there a way to get the current class and method name in a macro?
<sardaukar> argh, just figured out my controllers only work if shipped with the web framework lib :/
bcardiff has quit [Quit: Leaving.]
<sardaukar> I can’t seem to be able to require files from outside the lib
<sardaukar> I did get to parse the routes file, though, through a DSL
<sardaukar> is it possible to do the same to plain Crystal files?
HakanD has quit [Quit: Be back later ...]
HakanD has joined #crystal-lang
HakanD has quit [Ping timeout: 272 seconds]
vikaton has quit []
willlll has quit [Quit: willlll]
sardaukar has quit [Quit: sardaukar]
<jeromegn> >> proc = -> { "hello" }; proc.call
<DeBot> jeromegn: "hello"
<jeromegn> hmm
<jeromegn> >> proc = -> { "hello" }; proc
<DeBot> jeromegn: #<( -> String):0x8049E90>
<jeromegn> >> proc = -> { puts "hello" }; proc
<DeBot> jeromegn: #<( -> Nil):0x8049E90>
DerisiveLogic has joined #crystal-lang
<jeromegn> >> proc = -> { puts "hello" }; proc.call; proc
<DeBot> jeromegn: hello
<jeromegn> >> proc = -> { puts "hello" }; proc
<DeBot> jeromegn: #<( -> Nil):0x8049E90>
<jeromegn> when I try to call a proc that looks like #<( -> Nil):0x100622870:closure> (well, that's the result of inspecting it), I get "wrong number of arguments for '(Pointer(Void) -> Void)#call' (0 for 1)"
<jhass> what's typeof(proc) ?
<jhass> maybe it's a union?
<jeromegn> Proc(T)
<jeromegn> I'm not messing with C bindings right now :)
<jeromegn> just pure Crystal
<jeromegn> I'm building an Express-like web framework... I'm dynamically setting the next middleware to call
DerisiveLogic has quit [Ping timeout: 240 seconds]
<jeromegn> if I add a random argument when calling, I get the correct error
<jeromegn> wrong number of arguments for '( -> Nil)#call' (1 for 0)
<jeromegn> very weird
<jhass> indeed
<jhass> I'm still suspecting a union though
vikaton has joined #crystal-lang
<vikaton> >> 65.chr
<DeBot> vikaton: 'A'
<vikaton> >> 65.char
<DeBot> vikaton: Error in line 3: undefined method 'char' for Int32 (did you mean 'chr'?)
<vikaton> Why is it chr and not char?
<jhass> inherited from ruby
<jhass> and probably inherited it from perl or something
<vikaton> tbh I would rather have .char
<vikaton> more readable
<vikaton> what does .tr mean?
<vikaton> the word it derives from?
<jhass> translate I guess
<vikaton> .
<jeromegn> >> proc = -> (p : Proc) { p.call } ; proc.call -> { }
<DeBot> jeromegn: Error in line 3: wrong number of arguments for '(Pointer(Void) -> Void)#call' (0 for 1)
<jeromegn> that's the minimal failure jhass
<jhass> I guess that's a union for every proc in existence then
<jeromegn> not good
<jeromegn> for me :)
<jeromegn> >> proc = -> (p : Proc) { p.call(nil) } ; proc.call -> { }
<DeBot> jeromegn: Error in line 3: wrong number of arguments for '( -> Nil)#call' (1 for 0)
<jhass> >> proc = -> (p : ->) { p.call }; proc.call -> { }
<DeBot> jhass: in /usr/lib/crystal/io.cr:442: undefined method 'inspect' for Void
<jhass> >> proc = -> (p : ->) { p.call; 1 }; proc.call -> { }
<DeBot> jhass: 1
<jeromegn> hmm
<jeromegn> what just happened
<jhass> I properly type restricted it
<jhass> type restrictions on generics don't work well yet
<jhass> (on generics without specifying the free var that is)
<jeromegn> so why does -> work better than Proc^
<jeromegn> ?
<jeromegn> thought they were the same
<jhass> no
<jhass> -> is Proc(Void, Void)
<jhass> essentially
<jhass> I'm not sure if there's a way to express it
<jhass> differently
<jhass> Proc is a bit special, it's a generic but not really, special cased by the compiler
<notfowl> >> (
<DeBot> notfowl: Syntax error in eval:3: unterminated parenthesized expression
<notfowl> >> (->).is_a? Proc
<DeBot> notfowl: Syntax error in eval:3: unexpected token: )
<jhass> that's only valid in type restrictions
<jhass> >> -> { }.is_a? Proc
<DeBot> jhass: true
<notfowl> ah
<notfowl> Are all generic types without params (say Vector instead of Vector(int)) is that a constraint without the specification
<jhass> I'm sorry?
willlll has joined #crystal-lang
<BlaXpirit> notfowl, uhh yes
<notfowl> Thx
<notfowl> jhass: meaning that Vector matches for any Vector(t)
<vikaton> wait Crystal has Vectors?
<vikaton> >> sizeof(Vector)
<DeBot> vikaton: Error in line 3: undefined constant Vector
<vikaton> Its only Array and sized Array right?
<notfowl> I was just using that as an example
<vikaton> o
<BlaXpirit> i can guess where the example comes from :p
bcardiff has joined #crystal-lang
<vikaton> now I can
datanoise has quit [Ping timeout: 252 seconds]
bcardiff has quit [Quit: Leaving.]
vikaton has quit []
datanoise has joined #crystal-lang
BlaXpirit has quit [Quit: Quit Konversation]
DerisiveLogic has joined #crystal-lang