ChanServ changed the topic of #crystal-lang to: The Crystal programming language | http://crystal-lang.org | Crystal 0.21.1 | Fund Crystal's development: http://is.gd/X7PRtI | Paste > 3 lines of text to https://gist.github.com | GH: https://github.com/crystal-lang/crystal | Docs: http://crystal-lang.org/docs/ | API: http://crystal-lang.org/api/ | Logs: http://irclog.whitequark.org/crystal-lang
<FromGitter> <bew> what does this error mean? `instance variable @captures of Match was inferred to be Nil, but Nil alone provides no information`
<FromGitter> <KCreate> The compiler could only find an assignment to it that's nil, and only having nil as a type doesn't make much sense
<FromGitter> <KCreate> btw, is this a parsing bug? ⏎ ⏎ ```puts typeof('0' == '0'..'9') # => Range(Bool, Char)``` [https://gitter.im/crystal-lang/crystal?at=58f16d614cb8d091739043a4]
<FromGitter> <KCreate> looks like `==` has higher precedence than `..`
<FromGitter> <bew> ty!
<FromGitter> <bew> not a bug, but kinda weird^^
<FromGitter> <KCreate> I'll open an issue about that
<FromGitter> <bew> it allows to do `0..size - 1` without putting parens everywhere, but it's maybe too permissive..
<FromGitter> <KCreate> that actually makes sense
bjz has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
zipR4ND has quit [Ping timeout: 260 seconds]
greengriminal has quit [Quit: This computer has gone to sleep]
Philpax has joined #crystal-lang
<FromGitter> <khepin> What would I write to match the type of a tuple of varying size? ⏎ I’ve tried ⏎ ⏎ ```alias Ints = Int32 | (Int32, Ints) ⏎ Tuple(Ints)``` ⏎ ... [https://gitter.im/crystal-lang/crystal?at=58f19006881b89e10150a3b9]
<FromGitter> <khepin> or, related, how would I capture a block that takes an unknown number of arguments?
<FromGitter> <khepin> ```def initialize(*@inputs, &block : T -> Int32) forall T ⏎ end``` ⏎ ⏎ `undefined constant T` [https://gitter.im/crystal-lang/crystal?at=58f191af8bb56c2d11ac08f1]
<FromGitter> <fridgerator> `def initialize(**opts)`
<FromGitter> <khepin> hah!
<FromGitter> <codenoid> sir, can i get free ticket to crystal conf ?
<FromGitter> <khepin> nah, looks like the block still needs to be defined on its own, and then it wants the proc’s type to be fully specified
<FromGitter> <fridgerator> you want to pass the inputs to the block?
<FromGitter> <fridgerator> like: https://play.crystal-lang.org/#/r/1v7q
<FromGitter> <fridgerator> ?
<FromGitter> <khepin> yeah, but I wasn’t able to use yield because the block needs to be captured
<FromGitter> <khepin> to be used later
<FromGitter> <fridgerator> ah
<FromGitter> <khepin> so the compiler was mad that my block had one argument, but it was declared without any
<FromGitter> <codenoid> sir, i want to make crystal indonesian official
<FromGitter> <khepin> I’ve found a way around my problem since there’s always either 1 or 2 args with multiple definitions
<FromGitter> <codenoid> / i want make crystal documentation indonesian version
<FromGitter> <khepin> but no general way that would solve this for everything
<FromGitter> <fridgerator> @codenoid that would be cool
<FromGitter> <codenoid> @fridgerator and where I should start sir ?
<FromGitter> <fridgerator> thats a good question, should probably contact one of the core members of the team
<FromGitter> <codenoid> ok,
_whitelogger has joined #crystal-lang
Raimondii has joined #crystal-lang
Raimondi has quit [Ping timeout: 268 seconds]
Raimondii is now known as Raimondi
McSoFake has joined #crystal-lang
_whitelogger has joined #crystal-lang
bjz has joined #crystal-lang
McSoFake has quit [Ping timeout: 252 seconds]
<FromGitter> <schoening> This line provokes me xD https://github.com/crystal-lang/crystal/blob/master/src/enumerable.cr#L127 ⏎ Because if there isnt passed an array its the same as if reuse is false xP
McSoFake has joined #crystal-lang
<FromGitter> <schoening> It's so cool that crystal is self hosted. It's freaking wizardry
McSoFake has quit [Ping timeout: 260 seconds]
_whitelogger has joined #crystal-lang
A124 has joined #crystal-lang
j2k has joined #crystal-lang
Qchmqs has joined #crystal-lang
bjz has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
j2k has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<FromGitter> <codenoid> please. elseif syntax in crystal
<BlaXpirit> elsif?
<FromGitter> <codenoid> yes
<FromGitter> <codenoid> elsif in crystal ?
<jhass> it's elsif
<FromGitter> <codenoid> ok, thanks
<FromGitter> <codenoid> i miss that, hmm, sorry,, & thanks
Philpax_ has joined #crystal-lang
Philpax has quit [Ping timeout: 258 seconds]
zipR4ND has joined #crystal-lang
zipR4ND has quit [Ping timeout: 268 seconds]
<FromGitter> <schoening> I find it confusing that I can pass blocks to functions that don't have a block parameter... can I pass a block to any method?
<FromGitter> <schoening> (I'm not from a ruby background)
<FromGitter> <schoening> what im talking about: https://github.com/crystal-lang/crystal/blob/master/src/enumerable.cr#L399 ⏎ But there isnt a &block in the parameters of the method.
greengriminal has joined #crystal-lang
<FromGitter> <KCreate> You can pass a block to every method that yields
<FromGitter> <KCreate> Use the `&block` syntax to capture a block (turn it into a proc)
<BlaXpirit> schoening, yes, having `yield` anywhere in a method adds an implicit block parameter
<FromGitter> <schoening> Ah. Thanks you two. That seems like a valuable thing to know xP
<FromGitter> <schoening> Still a bit confusing tho. Callbacks are easier to grasp. So it's always executed in place of the yield keyword?
<BlaXpirit> schoening, you could view `yield` as "paste the code of the passed block here" because the code is inlined
<FromGitter> <schoening> Ahh! Thanks :smile:
<FromGitter> <KCreate> Or if you're familiar with generators in javascript, yield just talks to the passed block instead of the return value
<BlaXpirit> it is best to not compare this to generators. that has caused me a lot of grief, coming from Python. this is much more limited.
<FromGitter> <bew> @BlaXpirit limited in which ways?
<BlaXpirit> generators allow pausing execution
<BlaXpirit> you can write a loop and then call each iteration whenever you please
<BlaXpirit> it's like creating an Iterator without making a class
xmonader has joined #crystal-lang
<FromGitter> <bew> Why https://carc.in/#/r/1v80 : `interpolation not allowed in named argument`
<RX14> you forgot .new
<FromGitter> <bew> oooooh
<FromGitter> <bew> but what does this error mean exactly?
<RX14> well
<RX14> you were trying to pass a string as a generic
<RX14> which clearly breaks the lexer
<FromGitter> <bew> lol clear explanation
<FromGitter> <bew> but yeah I dont know how it could find a named ar here^^
<FromGitter> <bew> +argument
<RX14> well
<RX14> Foo(bar: String) is a valid type
<RX14> for example
<RX14> NamedTuple(foo: String)
<FromGitter> <bew> hmm
<RX14> so NamedTuple("foo bar": String) is also valid
<RX14> which means it gets to Type("#{foo}" and stops
<RX14> it doesn't lookahead any further
<RX14> it just sees that and thinks named arg
<FromGitter> <bew> but why "named arg" and not "String"?
<RX14> because it is a named arg
<RX14> to the type
<RX14> NamedTuple("foo": String)
<RX14> the "foo" is the name of the named arg
sz0 has joined #crystal-lang
<FromGitter> <bew> ok, it's a bit weird but it makes sense!
<FromGitter> <eliasjpr> Is there a way to get the clients IP address?
<FromGitter> <sdogruyol> that's still an open issue
<FromGitter> <sdogruyol> if you're using `nginx` as a reverse proxy you can get the ip from http headers
<FromGitter> <eliasjpr> I see I will have to use a web server to inject it to the headers
<FromGitter> <eliasjpr> thanks @sdogruyol
<FromGitter> <sdogruyol> well, you'll have to use something :P
<FromGitter> <sdogruyol> either `nginx` e.g
<FromGitter> <bew> an issue? there is a syscall to get that ip address of a socket iirc...
<FromGitter> <schoening> Add a form asking them to send their ip address. Bam! Problem solved
<FromGitter> <bew> oh no I'm wrong, you mean the client computer's ip address, not the ip address/port they're connected to, don't know then
<FromGitter> <eliasjpr> yes the client IP address I mean
<FromGitter> <bew> maybe with `getpeername` but I'm not sure http://beej.us/guide/bgnet/output/html/multipage/syscalls.html#getpeername
<FromGitter> <eliasjpr> I think it is normal for application servers not to have the client IP address
<FromGitter> <eliasjpr> since is behind a proxy or load balancer
<FromGitter> <sdogruyol> yes
Qchmqs has quit [Ping timeout: 252 seconds]
LastWhisper____ has joined #crystal-lang
<FromGitter> <codingphasedotcom> hey guys
<FromGitter> <codingphasedotcom> in kemal
<FromGitter> <sdogruyol> yo
<FromGitter> <codingphasedotcom> can i have multiple content_for or yield_for in a page
sz0 has quit [Quit: Connection closed for inactivity]
<FromGitter> <codingphasedotcom> I ask because I want to create a section for scripts another for the current content of the page.
<FromGitter> <sdogruyol> yeah
<FromGitter> <sdogruyol> just name them differently
<FromGitter> <sdogruyol> check http://kemalcr.com/docs/views/
<FromGitter> <codingphasedotcom> i'm trying to understand it
<FromGitter> <codingphasedotcom> but having issue reading the documentation
<FromGitter> <sdogruyol> what's your issue? maybe we can improve the doc
<FromGitter> <codingphasedotcom> ok so i got the first part using "content" to split up the content and the layout page
<FromGitter> <codingphasedotcom> now i'm trying to use the second part "content_for and yield_content"
<FromGitter> <sdogruyol> cool
<FromGitter> <codingphasedotcom> for example if have scritps.ecr on "src/views/includes" how can I add that to my layouts page
<FromGitter> <codingphasedotcom> ok now i get it
<FromGitter> <codingphasedotcom> so it has to be in the same view file
<FromGitter> <sdogruyol> nope
<FromGitter> <sdogruyol> these are seperate views
greengriminal has quit [Quit: Leaving]
<FromGitter> <codingphasedotcom> ok but how does it now which view file to get it from
bjz has joined #crystal-lang
<FromGitter> <sdogruyol> ```render "src/view.ecr", "src/layout.ecr"```
<FromGitter> <sdogruyol> first is the subview the second is the main layout
<FromGitter> <codingphasedotcom> lets say we have a layout "views/layouts/main.ecr", content page "views/homepage", and then scripts include "views/includes/scripts.ecr"
<FromGitter> <sdogruyol> yeah
<FromGitter> <sdogruyol> you use `render "views/includes/scripts.ecr"` in your `ecr`
<FromGitter> <sdogruyol> inside your view
<FromGitter> <codingphasedotcom> what i'm getting is the text "render "views/includes/scripts.ecr"" when i go to the "/" route
<FromGitter> <codingphasedotcom> https://github.com/codingphasedotcom/rocky
<FromGitter> <codingphasedotcom> just uploaded to github maybe you can see what i'm doing wrong
<FromGitter> <sdogruyol> oh
bjz has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
<FromGitter> <sdogruyol> you need to do ```<%= render %>```
LastWhisper____ has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
<FromGitter> <stereosteve> I’m looking at this crystal-leveldb project… running the specs fails at this line: ⏎ https://github.com/greyblake/crystal-leveldb/blob/master/spec/leveldb/db_spec.cr#L23 ⏎ which tests that an exception is raised on double open. Really any time there is an error, I get output like: ⏎ ⏎ ```code paste, see link``` ... [https://gitter.im/crystal-lang/crystal?at=58f24152ad849bcf4288c72a]
<FromGitter> <codingphasedotcom> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=58f241688fcce56b200535f1]
<FromGitter> <codingphasedotcom> getting this error now
<FromGitter> <sdogruyol> is you path correct?
<FromGitter> <codingphasedotcom> do i have to put a full path
<FromGitter> <codingphasedotcom> like "./includes/scritps.ecr" or can I do "include/scripts.ecr"
<FromGitter> <sdogruyol> no, it's relative to your current folder so `"./includes/..."`
xmonader2 has joined #crystal-lang
xmonader has quit [Ping timeout: 240 seconds]
<FromGitter> <codingphasedotcom> ok i got the yield_content and content for working. It has to be in the view to work. but can't get to use an include how you are telling me
bjz has joined #crystal-lang
<FromGitter> <sdogruyol> not sure what you're doing tbh :P
<FromGitter> <codingphasedotcom> ok so i'm going to break it down
lacour has joined #crystal-lang
<jhass> stereosteve: could be, this really just should be specified as an out param in the lib binding
bjz has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
<FromGitter> <codingphasedotcom> I want to be able to include a navigation file "views/includes/navigation.ecr" inside of the master layout "views/layouts/main.ecr" when i go to the route "/" i want the content to show "views/pages/homepage"
<FromGitter> <codingphasedotcom> @sdogruyol finally got it i have to put a full path <%= render "src/views/includes/navigation.ecr" %> I put this on the layout. I will be making a video tutorial on this.
<FromGitter> <sdogruyol> oh
<FromGitter> <sdogruyol> yeah you need to be careful about your `src` and `views` file structure
<FromGitter> <stereosteve> @jhass - thanks… is this the right way to use an out param? ⏎ https://github.com/greyblake/crystal-leveldb/compare/master...stereosteve:out-param?expand=1
<FromGitter> <stereosteve> the err out param is intended to be a c string: https://github.com/google/leveldb/blob/master/include/leveldb/c.h#L72-L75
<jhass> you shouldn't need to explicitly do the uninitialized
<jhass> the compiler should do it for you
<FromGitter> <stereosteve> okay I think I’m figuring it out… there is a problem further down in the `check_error!` function too. I am getting a leveldb error string out now
<FromGitter> <stereosteve> will try a few more things and make a PR. Thanks for your help.
<jhass> yw
<FromGitter> <codingphasedotcom> @sdogruyol thanks will be making a video tutorial on this. Been getting alot of my youtube viewers trying out crystal and kemal lol trying to convert people from node one at a time
<FromGitter> <fridgerator> hell yeah !
<FromGitter> <fridgerator> down with node
<FromGitter> <sdogruyol> @codingphasedotcom that's awesome
Raimondii has joined #crystal-lang
Raimondi has quit [Ping timeout: 268 seconds]
Raimondii is now known as Raimondi
Philpax_ has quit [Ping timeout: 240 seconds]
Philpax has joined #crystal-lang
bjz has joined #crystal-lang
bjz has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
<FromGitter> <CodelessFuture> Hi, when you generate a new project in crystal the .gitignore contains a /bin/ directory entry. What goes inside?
<FromGitter> <sdogruyol> you binary
<FromGitter> <sdogruyol> when you do `shards build`
Ven has joined #crystal-lang
Ven is now known as Guest55325
Guest55325 has quit [Ping timeout: 240 seconds]
<FromGitter> <CodelessFuture> @sdogruyol so when you build with crystal build —release you don’t have an independent binary?
Ven_ has joined #crystal-lang
<FromGitter> <sdogruyol> What do you mean by independent?
A124 has quit [Quit: '']
<FromGitter> <CodelessFuture> Whats the difference between the binary created by shards build and crystal build?
<FromGitter> <sdogruyol> Nothing
<FromGitter> <sdogruyol> Just convention
bjz has joined #crystal-lang
<FromGitter> <CodelessFuture> 8003412 2312 -rwxr-xr-x 1 max staff 1180128 15 Apr 22:10 prova -> generated by crystal build —release
<FromGitter> <CodelessFuture> 8005734 6184 -rwxr-xr-x 1 max staff 3163312 15 Apr 22:57 prova -> generated by shards build
<FromGitter> <CodelessFuture> 3 times bigger….
<BlaXpirit> CodelessFuture, why dont you compare just `crystal build`
<FromGitter> <sdogruyol> you can also do --release with shards build
<FromGitter> <CodelessFuture> Ok I think that since there is a crystal deps command shards in optional…probably an old package now integrated in crystal?
<FromGitter> <CodelessFuture> I’m new and trying to understand the right things to do
<BlaXpirit> CodelessFuture, crystal deps used to be a different simpler thing, now it's an alias to shards
<BlaXpirit> hard to say which of them is preferred
<FromGitter> <CodelessFuture> I’m playing with Crystal and Kemal last couple of day and I want to try for some project from next week and I want to implement a methodologi
<FromGitter> <CodelessFuture> Methodology
<FromGitter> <CodelessFuture> From project creation to deploy
<BlaXpirit> CodelessFuture, it just calls `shards`, so it's probably better to use shards directly if you like https://github.com/crystal-lang/crystal/blob/8717b32f8810cbeb489c185df74ec1ff2094e047/src/compiler/crystal/command/deps.cr#L5
<FromGitter> <CodelessFuture> ok I see
LastWhisper____ has joined #crystal-lang
LastWhisper____ has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
Ven_ has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
splitty_ has quit [Read error: Connection reset by peer]
splitty_ has joined #crystal-lang
bjz has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
LastWhisper____ has joined #crystal-lang
lacour has quit [Quit: Leaving]
<BlaXpirit> i remember hearing something like... if you have more than one `yield` in a method, it's gonna get bad performance or something.. what is the actual effect of this?