00:15
bcardiff has quit [Quit: Leaving.]
00:26
canhtak has quit [Quit: canhtak]
00:35
zz_Cidan is now known as Cidan
00:44
waterlink1 has quit [Ping timeout: 255 seconds]
01:09
havenwood has quit [Ping timeout: 252 seconds]
01:21
willlll has quit [Quit: willlll]
02:02
willlll has joined #crystal-lang
02:54
vikaton has quit []
03:02
vikaton has joined #crystal-lang
03:02
<
vikaton >
Does crystal have chain comparisons?
03:04
<
vikaton >
>> "Hello" "World"
03:04
<
DeBot >
vikaton: Syntax error in eval:3: unexpected token: DELIMITER_START
03:07
<
vikaton >
>> [1,2,3,4,5][-1]
03:07
havenwood has joined #crystal-lang
03:32
willlll has quit [Quit: willlll]
03:33
willlll has joined #crystal-lang
03:42
vikaton has quit []
04:21
broz has quit [Remote host closed the connection]
04:35
bcardiff has joined #crystal-lang
04:38
bcardiff has quit [Client Quit]
04:43
JBat has joined #crystal-lang
05:03
datanoise has joined #crystal-lang
05:49
havenwood has quit [Ping timeout: 256 seconds]
06:10
willlll has quit [Quit: willlll]
06:10
havenwood has joined #crystal-lang
06:14
canhtak has joined #crystal-lang
06:15
datanoise has quit [Ping timeout: 245 seconds]
06:50
willlll has joined #crystal-lang
06:57
strcmp1 has quit [Ping timeout: 276 seconds]
07:14
BlaXpirit has joined #crystal-lang
07:24
willlll has quit [Quit: willlll]
07:26
bcardiff has joined #crystal-lang
08:16
havenwood has quit [Ping timeout: 264 seconds]
08:44
Cidan is now known as zz_Cidan
09:00
bcardiff has quit [Quit: Leaving.]
09:07
<
BlaXpirit >
I often wonder how optimized some things are
09:07
<
BlaXpirit >
is `5.to_i32` a noop?
09:18
<
BlaXpirit >
is `if responds_to?` evaluated at compile time?
09:21
sardaukar has joined #crystal-lang
09:46
<
BlaXpirit >
any better way to do this?
09:46
<
BlaXpirit >
woops, that 2nd line is gone
10:07
canhtak has quit [Quit: canhtak]
10:21
canhtak has joined #crystal-lang
12:05
canhtak has quit [Quit: canhtak]
12:06
canhtak has joined #crystal-lang
12:37
datanoise has joined #crystal-lang
12:42
leafybasil has quit [Remote host closed the connection]
13:14
<
jeromegn >
hey datanoise :)
13:14
<
jeromegn >
just got the specs passing locally
13:46
BlaXpirit has quit [Quit: Quit Konversation]
13:52
leafybasil has joined #crystal-lang
13:58
leafybasil has quit [Ping timeout: 272 seconds]
14:03
BlaXpirit has joined #crystal-lang
14:49
waj has joined #crystal-lang
14:50
<
datanoise >
jeromegn: great
15:06
<
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?
15:10
<
datanoise >
jeromegn: i'm ok with that. would it require using git submodule in this case?
15:12
<
jhass >
no, you'd use the crystal deps feature
15:13
bcardiff has joined #crystal-lang
15:15
<
datanoise >
i need to read on that. never used it before
15:16
leafybasil has joined #crystal-lang
15:25
<
jhass >
it basically just clones and symlinks stuff into the default load path when you run crystal deps
15:27
<
datanoise >
i see, so i need to add libs folder to gitignore
15:34
canhtak has quit [Remote host closed the connection]
15:34
canhtak has joined #crystal-lang
15:48
willlll has joined #crystal-lang
16:14
waj has quit [Quit: waj]
16:49
canhtak has quit [Quit: canhtak]
16:49
bcardiff has quit [Quit: Leaving.]
16:50
canhtak has joined #crystal-lang
16:59
strcmp1 has joined #crystal-lang
17:18
canhtak has quit [Quit: canhtak]
17:28
BlaXpirit has quit [Remote host closed the connection]
17:29
DerisiveLogic has quit [Ping timeout: 255 seconds]
17:30
BlaXpirit has joined #crystal-lang
17:30
havenwood has joined #crystal-lang
17:44
zz_Cidan is now known as Cidan
18:15
havenwood has quit [Ping timeout: 240 seconds]
18:53
waterlink has joined #crystal-lang
19:06
havenwood has joined #crystal-lang
19:29
datanoise has quit [Ping timeout: 240 seconds]
19:39
mah has joined #crystal-lang
19:39
<
jeromegn >
is it possible to have variable return values for procs?
19:41
mah has quit [Client Quit]
19:41
<
jhass >
yeah, I think it accepts a free var there
19:42
<
jhass >
>> def foo(bar : ->); puts bar.call; end; foo(-> { 1 });
19:42
<
DeBot >
jhass: in /usr/lib/crystal/io.cr:180: undefined method 'to_s' for Void
19:42
<
jhass >
>> def foo(bar : -> R); puts bar.call; end; foo(-> { 1 });
19:42
<
jhass >
>> def foo(bar : -> R); puts bar.call; end; foo(-> { "1" });
19:44
<
jeromegn >
free var, interesting
19:45
<
jeromegn >
are those documented somewhere?
19:48
<
jhass >
no idea if we really call them like that :P
19:49
<
jhass >
ah, we actually do :D
20:01
<
crystal-gh >
crystal/master 8140320 Sergio Gil Pérez de la Manga: Iterator#cons(n)
20:01
<
crystal-gh >
crystal/master 895b06b Ary Borenszweig: Merge pull request #648 from porras/each-cons...
20:05
<
crystal-gh >
[crystal] asterite closed pull request #649: Documentation for most methods in Enumerable (master...enumerable-docs)
http://git.io/vUspo
20:12
kulelu88 has joined #crystal-lang
20:14
<
travis-ci >
manastech/crystal#2330 (master - 895b06b : Ary Borenszweig): The build was fixed.
20:14
<
sardaukar >
is there a way to get the current file path of a lib being required via deps?
20:16
<
travis-ci >
manastech/crystal#2331 (master - aae059c : Ary Borenszweig): The build was fixed.
20:16
<
jhass >
there are the
__FILE__ and
__DIR__ magic constants being replaced with the current file
20:16
HakanD has joined #crystal-lang
20:17
<
sardaukar >
so, if I have a lib and I want to set it’s “root” folder, will that work?
20:17
<
sardaukar >
picture Rails.root
20:17
<
sardaukar >
could I set that on a lib I’m depping?
20:17
<
jhass >
I'm not sure if I'm following
20:17
<
sardaukar >
all I get with
__FILE__ is the libs location (after being depped)
20:18
<
sardaukar >
I want to set, on my lib, a #root method, so I can render a view relative to the lib’s location
20:19
<
sardaukar >
oh wait, the whole lib gets imported
20:19
<
sardaukar >
nevermind! :D
20:26
datanoise has joined #crystal-lang
20:30
<
sardaukar >
I keep getting in ./libs/bunny/bunny.cr:12: undefined method 'replace' for String
20:31
<
jhass >
last real update in september...
20:31
<
sardaukar >
so it’s gsub now? was it ever replace?
20:31
<
jhass >
crystal moved on a lot since ;)
20:32
<
sardaukar >
there’s a commit 8 days ago
20:32
<
jeromegn >
>> class Foo; def bar;
20:32
<
DeBot >
jeromegn: Syntax error in eval:5: expecting identifier 'end', not 'rescue'
20:32
<
jhass >
yes, saying "use ecr instead", effectively
20:33
<
jeromegn >
>> class Foo; def bar; "hello"; end; def call; with self yield; end; end; Foo.new.call { bar }
20:33
<
DeBot >
jeromegn: "hello"
20:33
<
sardaukar >
oh ok. I’ll try that
20:33
<
jeromegn >
>> class Foo; def bar; "hello"; end; def call(&block); instance_eval █ end; end; Foo.new.call { bar }
20:33
<
DeBot >
jeromegn: Error in line 3: undefined local variable or method 'bar'
20:35
bcardiff has joined #crystal-lang
20:35
<
jeromegn >
>> class Foo; def bar; "hello"; end; def call; with self yield; end; end; proc = -> { bar }; Foo.new.call &proc
20:35
<
DeBot >
jeromegn: Error in line 3: undefined local variable or method 'bar'
20:36
<
jhass >
yeah, with x yield doesn't work for Procs
20:36
<
jhass >
blocks only for now
20:37
<
jeromegn >
I thought they were the same
20:38
<
sardaukar >
is ECR working at the moment? I get “can’t define def inside def” :/
20:38
<
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.
20:38
<
crystal-gh >
crystal/master 4cb719e Ary Borenszweig: Fixed #647: Calling singleton method in lambda inside module causes internal compilation error
20:38
<
jhass >
sounds like you call the ecr_file macro inside a method
20:38
<
jhass >
there use the embed_ecr macro instead
20:39
<
jeromegn >
>> class Foo; def bar; "hello"; end; def call(&block); instance_eval █ end; end; proc = -> { bar }; Foo.new.call &proc
20:39
<
DeBot >
jeromegn: Error in line 3: undefined local variable or method 'bar'
20:39
asterite has joined #crystal-lang
20:39
vikaton has joined #crystal-lang
20:39
asterite has quit [Client Quit]
20:40
<
vikaton >
Question: is (0..15).each faster than 15.times ?
20:40
<
jhass >
I wouldn't think so
20:40
<
jhass >
but benchmark
20:40
<
jhass >
doubt you'll measure much of a difference in release mode
20:40
<
sardaukar >
embed_ecr needs a StringIO, right?
20:41
<
jhass >
you can wrap it into a String.build for example, yeah
20:42
asterite has joined #crystal-lang
20:42
<
asterite >
vikaton: no difference, llvm optimizes the hell out of both. But as jhass says, benchmark and see
20:43
<
sardaukar >
yeah, but I get undefined marco variable view_file
20:43
<
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
20:43
<
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
20:44
<
asterite >
Have a nice day ;-)
20:44
asterite has quit [Client Quit]
20:44
<
jhass >
sardaukar: embed_ecr is a macro, view_file is a runtime variable
20:44
<
jhass >
macros are evaluated at compile time
20:45
<
sardaukar >
crap, yeah
20:45
<
sardaukar >
I have to take the same approach as with the routes for the views
20:46
JBat has quit [Quit: Computer has gone to sleep.]
20:47
<
vikaton >
In the meantime, check out the little things I ddi with Crystal webdev :P
20:47
<
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
20:47
<
sardaukar >
vikaton: pretty cool :D
20:48
<
vikaton >
sardaukar: thanks :P
20:48
<
sardaukar >
how did you deploy it?
20:48
<
vikaton >
a bash script that runs "crystal server.cr --release" in the bg
20:49
<
jhass >
how are you supposed to copy paste the password? :P
20:49
<
vikaton >
yeahh I gotta fix that :/
20:49
<
travis-ci >
manastech/crystal#2332 (master - 4cb719e : Ary Borenszweig): The build was broken.
20:49
<
vikaton >
I'm using this for my project in Java class in HS
20:50
<
vikaton >
since AP Java is over
20:51
<
sardaukar >
so, is there a way to get the current class and method name in a macro?
20:59
<
sardaukar >
argh, just figured out my controllers only work if shipped with the web framework lib :/
21:00
bcardiff has quit [Quit: Leaving.]
21:00
<
sardaukar >
I can’t seem to be able to require files from outside the lib
21:00
<
sardaukar >
I did get to parse the routes file, though, through a DSL
21:01
<
sardaukar >
is it possible to do the same to plain Crystal files?
21:03
HakanD has quit [Quit: Be back later ...]
21:04
HakanD has joined #crystal-lang
21:09
HakanD has quit [Ping timeout: 272 seconds]
21:15
vikaton has quit []
21:28
willlll has quit [Quit: willlll]
21:40
sardaukar has quit [Quit: sardaukar]
21:41
<
jeromegn >
>> proc = -> { "hello" }; proc.call
21:41
<
DeBot >
jeromegn: "hello"
21:58
<
jeromegn >
>> proc = -> { "hello" }; proc
21:58
<
DeBot >
jeromegn: #<( -> String):0x8049E90>
21:58
<
jeromegn >
>> proc = -> { puts "hello" }; proc
21:58
<
DeBot >
jeromegn: #<( -> Nil):0x8049E90>
21:58
DerisiveLogic has joined #crystal-lang
21:59
<
jeromegn >
>> proc = -> { puts "hello" }; proc.call; proc
21:59
<
DeBot >
jeromegn: hello
21:59
<
jeromegn >
>> proc = -> { puts "hello" }; proc
21:59
<
DeBot >
jeromegn: #<( -> Nil):0x8049E90>
22:00
<
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)"
22:01
<
jhass >
what's typeof(proc) ?
22:01
<
jhass >
maybe it's a union?
22:02
<
jeromegn >
I'm not messing with C bindings right now :)
22:02
<
jeromegn >
just pure Crystal
22:02
<
jeromegn >
I'm building an Express-like web framework... I'm dynamically setting the next middleware to call
22:02
DerisiveLogic has quit [Ping timeout: 240 seconds]
22:07
<
jeromegn >
if I add a random argument when calling, I get the correct error
22:08
<
jeromegn >
wrong number of arguments for '( -> Nil)#call' (1 for 0)
22:08
<
jeromegn >
very weird
22:29
<
jhass >
I'm still suspecting a union though
22:29
vikaton has joined #crystal-lang
22:30
<
vikaton >
>> 65.chr
22:30
<
DeBot >
vikaton: 'A'
22:30
<
vikaton >
>> 65.char
22:30
<
DeBot >
vikaton: Error in line 3: undefined method 'char' for Int32 (did you mean 'chr'?)
22:30
<
vikaton >
Why is it chr and not char?
22:32
<
jhass >
inherited from ruby
22:32
<
jhass >
and probably inherited it from perl or something
22:32
<
vikaton >
tbh I would rather have .char
22:32
<
vikaton >
more readable
22:36
<
vikaton >
what does .tr mean?
22:36
<
vikaton >
the word it derives from?
22:37
<
jhass >
translate I guess
22:44
<
jeromegn >
>> proc = -> (p : Proc) { p.call } ; proc.call -> { }
22:44
<
DeBot >
jeromegn: Error in line 3: wrong number of arguments for '(Pointer(Void) -> Void)#call' (0 for 1)
22:44
<
jeromegn >
that's the minimal failure jhass
22:45
<
jhass >
I guess that's a union for every proc in existence then
22:46
<
jeromegn >
not good
22:46
<
jeromegn >
for me :)
22:46
<
jeromegn >
>> proc = -> (p : Proc) { p.call(nil) } ; proc.call -> { }
22:46
<
DeBot >
jeromegn: Error in line 3: wrong number of arguments for '( -> Nil)#call' (1 for 0)
22:46
<
jhass >
>> proc = -> (p : ->) { p.call }; proc.call -> { }
22:46
<
DeBot >
jhass: in /usr/lib/crystal/io.cr:442: undefined method 'inspect' for Void
22:46
<
jhass >
>> proc = -> (p : ->) { p.call; 1 }; proc.call -> { }
22:47
<
jeromegn >
what just happened
22:47
<
jhass >
I properly type restricted it
22:47
<
jhass >
type restrictions on generics don't work well yet
22:48
<
jhass >
(on generics without specifying the free var that is)
22:48
<
jeromegn >
so why does -> work better than Proc^
22:49
<
jeromegn >
thought they were the same
22:49
<
jhass >
-> is Proc(Void, Void)
22:49
<
jhass >
essentially
22:49
<
jhass >
I'm not sure if there's a way to express it
22:49
<
jhass >
differently
22:50
<
jhass >
Proc is a bit special, it's a generic but not really, special cased by the compiler
22:50
<
DeBot >
notfowl: Syntax error in eval:3: unterminated parenthesized expression
22:51
<
notfowl >
>> (->).is_a? Proc
22:51
<
DeBot >
notfowl: Syntax error in eval:3: unexpected token: )
22:51
<
jhass >
that's only valid in type restrictions
22:51
<
jhass >
>> -> { }.is_a? Proc
22:51
<
DeBot >
jhass: true
22:52
<
notfowl >
Are all generic types without params (say Vector instead of Vector(int)) is that a constraint without the specification
22:53
willlll has joined #crystal-lang
22:59
<
BlaXpirit >
notfowl, uhh yes
23:05
<
notfowl >
jhass: meaning that Vector matches for any Vector(t)
23:05
<
vikaton >
wait Crystal has Vectors?
23:05
<
vikaton >
>> sizeof(Vector)
23:05
<
DeBot >
vikaton: Error in line 3: undefined constant Vector
23:06
<
vikaton >
Its only Array and sized Array right?
23:06
<
notfowl >
I was just using that as an example
23:07
<
BlaXpirit >
i can guess where the example comes from :p
23:11
bcardiff has joined #crystal-lang
23:12
<
vikaton >
now I can
23:13
datanoise has quit [Ping timeout: 252 seconds]
23:33
bcardiff has quit [Quit: Leaving.]
23:35
vikaton has quit []
23:41
datanoise has joined #crystal-lang
23:42
BlaXpirit has quit [Quit: Quit Konversation]
23:59
DerisiveLogic has joined #crystal-lang