Kug3lis has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
Raimondii has joined #crystal-lang
Raimondi has quit [Ping timeout: 268 seconds]
Raimondii is now known as Raimondi
txdv has quit [Ping timeout: 240 seconds]
<oprypin>
bew, is it because that initialize method is never inherited in the first place?
<oprypin>
i think it would work with any other method name
<oprypin>
just that initialize is magic - always 'protected' or something
txdv has joined #crystal-lang
_whitelogger has joined #crystal-lang
<FromGitter>
<bew> Even if it's always protected, it should be accessible from childs classes
marciogm has quit [Ping timeout: 260 seconds]
marciogm has joined #crystal-lang
dckrx has joined #crystal-lang
mark_66 has joined #crystal-lang
dckrx has quit [Client Quit]
pwned has joined #crystal-lang
Kug3lis has joined #crystal-lang
yogg-saron has joined #crystal-lang
bjz has joined #crystal-lang
bjz has quit [Client Quit]
bjz has joined #crystal-lang
Winty has joined #crystal-lang
bjz has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
<Winty>
hey guys. i'm trying to learn crystal and i can't get this program to compile: https://pastebin.com/VTv6yYPh it fails on line 20 because @tail is nil, but on line before i'm ensuring that it's not nil so where's the problem?
<Papierkorb>
Winty: @instance variables don't "work" with the nil check, as in a multithreaded program, it could be changed in between setting it to non-nil back to nil
<Papierkorb>
Winty: Instead, in line 19, do `if tail = @tail`, and then use that local variable `tail` in the following two lines
<Winty>
ok thx
<Papierkorb>
err, only in the following line. You still need to set `@tail`...
bjz has joined #crystal-lang
<Winty>
it works even without setting @tail = tail after i modify tail variable. so tail is reference to @tail and not copy? (tail = @tail)
<Papierkorb>
Yep, `class` is always heap allocated and thus you pass around references to it
<Papierkorb>
btw, line 2/3 in your snippet, you can also write `property next : Node(T)?`, you don't have to split the @instance variable definition and property macro call
<Papierkorb>
Otherwise, at least put a space before the colon, per convention
<Winty>
:D ok thanks for the help
<Papierkorb>
Line 6 isn't needed. A nilable variable defaults to `nil`. You can also make this explicit, e.g. replacing line 3 by `property next : Node(T)? = nil`, or `@next : Node(T)? = nil`
<Papierkorb>
Line 2 could also be omitted, by using `def initialize(@val : T)` instead on line 5. That'll tell Crystal that @val will always be a T. "Good enough" for the compiler :)
<Winty>
yeah i just like having all fields at the top of the class for better readability
<Papierkorb>
I do so too, just directly use `property`(or getter or setter), so it's also clear what a user of your class can do with those (if at all)
<Papierkorb>
Winty: ^
<FromGitter>
<bew> the definition of `<<` allows you to write `puts LinkedList{"Another", "Syntax with", true, "types"}` https://carc.in/#/r/21d7
<jokke>
hi
<jokke>
what's the equivalent of ruby's foo.method(:foobar) in crystal?
<jokke>
i want to pass a method of an object to a block
<jokke>
or rather to a method expecting a block
<RX14>
jokke, ->foo.foobar ?
<jokke>
ah m(
<RX14>
well, if you want to pass it to a block you need &->foo.foobar
<jokke>
of course
<jokke>
thanks :D
<RX14>
although, I think it's way way cleaner just to call the method in the block
<RX14>
and it likely has a performance advantage
<FromGitter>
<bew> ah? why?
<jokke>
alright
<RX14>
@bew procs generate a function pointer whereas using blocks emits a normal call
<RX14>
llvm might be able to optimise it but i'm not sure
<FromGitter>
<bew> Optimisation, ok !
sz0 has joined #crystal-lang
bjz_ has joined #crystal-lang
bjz has quit [Ping timeout: 246 seconds]
<crystal-gh>
[crystal] RX14 opened pull request #4426: Add warnings to MD5 and SHA1 hash documentation (master...feature/digest-doc-fix) https://git.io/v9h9h
bjz has joined #crystal-lang
Winty has quit [Ping timeout: 260 seconds]
bjz_ has quit [Ping timeout: 240 seconds]
bjz has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
gewo has quit [Ping timeout: 240 seconds]
gewo has joined #crystal-lang
gewo has quit [Ping timeout: 260 seconds]
yogg-saron has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
gewo has joined #crystal-lang
yogg-saron has joined #crystal-lang
gewo has quit [Ping timeout: 246 seconds]
gewo has joined #crystal-lang
Raimondii has joined #crystal-lang
Raimondi has quit [Ping timeout: 268 seconds]
Raimondii is now known as Raimondi
yogg-saron has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
yogg-saron has joined #crystal-lang
yogg-saron has quit [Client Quit]
yogg-saron has joined #crystal-lang
yogg-saron has quit [Client Quit]
<FromGitter>
<bigtunacan> Has anyone done a standard webserver interface for Crystal web frameworks yet?
<FromGitter>
<bigtunacan> Essentially a Ruby/Rack equivalent?
<FromGitter>
<bigtunacan> Seems like that is an HTTP library that can be built on, but I don't see how it provides a standardized interface for external app servers.
snsei has joined #crystal-lang
yogg-saron has joined #crystal-lang
yogg-saron has quit [Client Quit]
yogg-saron has joined #crystal-lang
yogg-saron has quit [Client Quit]
<FromGitter>
<fridgerator> quoting someone from earlier "Crystal has HTTP::Server and HTTP::Handler wich is a different concept, but the handlers are somewhat similar to Rack middleware."
<FromGitter>
<fridgerator> I don't have much experience with bare rack, so I'm probably not the best person answer the question
<FromGitter>
<drujensen> Hi @bigtunacan Kemal and Kemalyst both use the http::handers in a middleware stack
<FromGitter>
<drujensen> they are interchangable
<FromGitter>
<drujensen> there is implementations of http::handlers for several different tasks in the middleware stack just like Rack
<FromGitter>
<drujensen> you can remove, add or replace to the stack your own handlers
<FromGitter>
<drujensen> I believe Amber is doing this as well
<FromGitter>
<bigtunacan> But then HTTP::Server IS the app server?
<FromGitter>
<drujensen> but would need to verify
<FromGitter>
<drujensen> right, we are using the HTTP::Server implementation
<FromGitter>
<drujensen> and adding handlers to it
<FromGitter>
<drujensen> chaining them
<FromGitter>
<drujensen> it’s pretty simple to create your own
<FromGitter>
<drujensen> in Kemalyst, all the controller methods are just http::handlers that get added to the call stack
<FromGitter>
<bigtunacan> How difficult does it become to take Kemal off of HTTP::Server and just swap that out for "Super Scalable More Awesome App server"?
<FromGitter>
<bigtunacan> Is it just like flipping a switch; or are you tightly coupled to HTTP::Server?
<FromGitter>
<drujensen> checking...
<FromGitter>
<drujensen> i think we are just inheriting from it so if it supports the http::handlers, you could just swap it out
<FromGitter>
<drujensen> if the “super scalable” support http::handlers
<FromGitter>
<drujensen> the `context` can be reopened to add stuff that you need in future handlers
<FromGitter>
<bigtunacan> Very nice; similar to the Rack middleware; like you said
<FromGitter>
<drujensen> and include `include HTTP::Handler`
<FromGitter>
<drujensen> in your class
<FromGitter>
<drujensen> if anyone is interested in helping, we could use a `warden` http::handler. ;-)
<FromGitter>
<bigtunacan> :)
<FromGitter>
<straight-shoota> @bigtunacan With ruby/rack you are usually using an appserver executable (like puma, unicorn etc.) do run your application code. In crystal the binary usually binds directly to a port or listens to a socket. That's what `HTTP::Server`does and it invokes the appropriate handlers. It could be replaced by another implementation if you would need something else and still use the same handlers.
<FromGitter>
<bigtunacan> If those specs are right; why are people using Go ;)
<FromGitter>
<johnjansen> crystal is too young
<FromGitter>
<fridgerator> not backed by google
<FromGitter>
<bigtunacan> Probably true on both accounts
<FromGitter>
<bigtunacan> Go definitely has the Google machine behind it.
<FromGitter>
<bigtunacan> But I kind of hate working with it. Love Ruby; want better performance.
<FromGitter>
<bigtunacan> That's why I'm here :)
<FromGitter>
<johnjansen> so im looking forward to seeing something faster ;-)
<FromGitter>
<fridgerator> same here @bigtunacan
<FromGitter>
<johnjansen> haha, no pressure ;-)
<FromGitter>
<jwoertink> @bigtunacan I had a similar thought of taking kemal and replacing the HTTP::Server with something not built in to crystal. I started writing https://github.com/jwoertink/haywire.cr to handle doing that
<FromGitter>
<jwoertink> And as long as it had the same interface as the built in server, I think it wouldn't be too difficult to switch out
Kug3lis has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<FromGitter>
<drujensen> @jwoertink At the Code Camp, Juan Wajnerman originally tried using the libuv library instead of libevent
<FromGitter>
<drujensen> but the callbacks became problematic. May want to reach out and ask.
<FromGitter>
<drujensen> He didn’t go into details
<FromGitter>
<jwoertink> oh yeah? That might be part of some of the issues I'm running in to too
<FromGitter>
<jwoertink> On a side note, is it me, or does it seem like the crystal updates are slowing down?
<FromGitter>
<jwoertink> For a while there it was like 5~6 commits a night, but now it's like 1 every other day
<FromGitter>
<drujensen> yeah, i know the code camp was draining some time
<FromGitter>
<drujensen> but should start to pickup again??
<FromGitter>
<drujensen> not sure
<FromGitter>
<jwoertink> I figured maybe that was it
snsei has quit []
snsei has joined #crystal-lang
snsei has quit [Client Quit]
snsei has joined #crystal-lang
splitty_ has joined #crystal-lang
snsei has quit [Remote host closed the connection]
mark_66 has quit [Remote host closed the connection]
Kug3lis has joined #crystal-lang
<crystal-gh>
[crystal] bcardiff pushed 1 new commit to master: https://git.io/v9jHf
<crystal-gh>
crystal/master 2a71284 Chris Hobbs: Add range access methods to BitArray (#4397)...
<crystal-gh>
[crystal] bcardiff pushed 1 new commit to master: https://git.io/v9jHn
<FromGitter>
<bigtunacan> That is exactly the name I had in mind...
Ven_ has joined #crystal-lang
<FromGitter>
<drujensen> @bigtunacan lol. I was thinking of standardizing the http::handlers. two things I want are a standard way of configuring a handler and a standard pattern for modifying the HTTP::Server::Context
<FromGitter>
<drujensen> you could just include Crecto with Kemal and add your own set of handlers. create some generators and your off and running.. thats what i did. :-)
<FromGitter>
<drujensen> @fridgerator lol, just noticed your post
<FromGitter>
<fridgerator> ;)
<RX14>
what exactly is crystal's HTTP::Handler missing?
<FromGitter>
<drujensen> @RX14 I wouldn’t say its missing anything per say. It’s more of a convention.
<FromGitter>
<drujensen> so if your handler needs something in the HTTP::Server::Context
<RX14>
oh yeah extending HTTP::Server::Context is something that needs doing
<RX14>
I think a simple component system could do the job
<FromGitter>
<drujensen> say `params` hash, this should be done with the handler
<FromGitter>
<drujensen> another pattern i use in kemalyst is configuring each handler separately
<FromGitter>
<drujensen> so for example, the session handler needs a `secret`
<FromGitter>
<drujensen> the static handler needs a `directory` where files will be searched
<RX14>
that's easy using the stdlib's handler system...
<FromGitter>
<drujensen> the log handler...
<RX14>
I think it'd be best to architect these changes as an experiment on top of the stdlib
<RX14>
aimed at being able to be merged if it works well
<FromGitter>
<drujensen> i agree
<FromGitter>
<drujensen> would be nice to have a standard for this stuff
<FromGitter>
<drujensen> but `crack` is such a perfect name for a crystal project. ;-)
Ven_ has quit [Ping timeout: 246 seconds]
Ven has joined #crystal-lang
Ven is now known as Guest74863
TheLemonMan has joined #crystal-lang
pduncan has quit [Ping timeout: 272 seconds]
Guest74863 has quit [Ping timeout: 240 seconds]
Ven_ has joined #crystal-lang
Ven_ has quit [Ping timeout: 240 seconds]
Ven_ has joined #crystal-lang
zipR4ND has joined #crystal-lang
Ven_ has quit [Ping timeout: 260 seconds]
Ven has joined #crystal-lang
Ven is now known as Guest71934
Guest71934 has quit [Ping timeout: 240 seconds]
Ven_ has joined #crystal-lang
Ven_ has quit [Ping timeout: 246 seconds]
Ven_ has joined #crystal-lang
bjz has joined #crystal-lang
Ven_ has quit [Ping timeout: 260 seconds]
Ven_ has joined #crystal-lang
joaumg has quit [Quit: Leaving]
Ven_ has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
TheLemonMan has quit [Quit: "It's now safe to turn off your computer."]
zipR4ND has quit [Read error: Connection reset by peer]
zipR4ND1 has joined #crystal-lang
sagax has quit [Quit: Konversation terminated!]
<crystal-gh>
[crystal] RX14 opened pull request #4428: Add limits to HTTP request parsing (master...feature/http-limits) https://git.io/vHeyZ
bjz has quit [Ping timeout: 260 seconds]
bjz_ has joined #crystal-lang
bjz_ has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
go|dfish has quit [Ping timeout: 240 seconds]
<crystal-gh>
[crystal] RX14 opened pull request #4429: Add | as a string delimiter (master...feature/pipe-string-delimiter) https://git.io/vHeQV