RX14 changed the topic of #crystal-lang to: The Crystal programming language | http://crystal-lang.org | Crystal 0.27.1 | Fund Crystal's development: http://is.gd/X7PRtI | GH: https://github.com/crystal-lang/crystal | Docs: http://crystal-lang.org/docs/ | API: http://crystal-lang.org/api/ | Gitter: https://gitter.im/crystal-lang/crystal
<FromGitter> <paulcsmith> Does anyone know how to create a Proc/block that doesn't return? This works but is quite verbose: https://play.crystal-lang.org/#/r/6ft6
<FromGitter> <paulcsmith> Is there a way to either change the type signature or some way to create a proc that returns void that doesn't require so much verbosity. I was hoping I could change the type to `-> Nil` or `-> _` but that doesn't seem to work
MeiQianChiFan has joined #crystal-lang
DTZUZU has quit [*.net *.split]
badeball has quit [*.net *.split]
bazaar has quit [*.net *.split]
baweaver has quit [*.net *.split]
daemonwrangler has quit [*.net *.split]
justinmcp has quit [*.net *.split]
Liothen has quit [*.net *.split]
chemist69 has quit [Ping timeout: 252 seconds]
chemist69 has joined #crystal-lang
MeiQianChiFan is now known as glibc
DTZUZO has joined #crystal-lang
DTZUZU has joined #crystal-lang
daemonwrangler has joined #crystal-lang
bazaar has joined #crystal-lang
badeball has joined #crystal-lang
justinmcp has joined #crystal-lang
baweaver has joined #crystal-lang
Liothen has joined #crystal-lang
mjblack has quit [Ping timeout: 244 seconds]
mjblack has joined #crystal-lang
DTZUZO has quit [Ping timeout: 250 seconds]
DTZUZO has joined #crystal-lang
<FromGitter> <HarrisonB> What's the reason that proc instantiation creates closure,s but method definitions do not? E.g. https://play.crystal-lang.org/#/r/6fu0 fails to compile, but https://play.crystal-lang.org/#/r/6ftz succeeds. I read the closure section in the guide but i'm not seeing an explanation
return0e_ has joined #crystal-lang
return0e has quit [Ping timeout: 252 seconds]
glibc has quit [Remote host closed the connection]
laaron- has quit [Remote host closed the connection]
<FromGitter> <bew> @paulcsmith indeed it's not easy or not nice.. Could still do this though https://play.crystal-lang.org/#/r/6fuu
<FromGitter> <bew> @HarrisonB I don't remember it being explained, I guess you could see it as procs can be created on the fly, with values from around your context, they can also be captured for a block (the method get a proc that closures variables around its call)
<FromGitter> <bew> Methods are more static, can't be created on the fly
laaron has joined #crystal-lang
laaron has quit [Remote host closed the connection]
laaron has joined #crystal-lang
ashirase has quit [Ping timeout: 255 seconds]
mps has quit [Ping timeout: 245 seconds]
_whitelogger has joined #crystal-lang
ashirase has joined #crystal-lang
<FromGitter> <straight-shoota> @HarrisonB A method can never create a closure because it's scope is not statically connected to the surrounding scope. Your example *could* however work with global variables and it would essentially be the same as a closure (but technically different). Yet, in Crystal we decided not to have global variables to reduce complexity and possibly surprising side effects. So `foo` is just a local variable in
<FromGitter> ... the top level scope. It's accessible from within a block because it's declared in the same scope, but not from method scope.
mps has joined #crystal-lang
return0e has joined #crystal-lang
return0e_ has quit [Ping timeout: 255 seconds]
ma_ has joined #crystal-lang
ma_ has quit [Client Quit]
ternarysolo has joined #crystal-lang
lucasb has joined #crystal-lang
<jokke> there's also each.with_index :)
<FromGitter> <paulcsmith> @bew very clever! Thanks for sharing!
<FromGitter> <bew> You're welcome :) But I agree it would be nice to be able to put `->` as a restriction, and be able to pass `->{ p "foo" }` without type errors
<FromGitter> <paulcsmith> Yeah it’s kind of confusing because a type restriction of Nil on a regular method is basically Void. So even if you return an Int it’ll work. But if you put return type of Nil on a prod you have to actually return Nil which is unexpected
<FromGitter> <paulcsmith> I’ll probably create an issue because being able to restrict return type to Nil or Void and work like regular methods would be more intuitive and make it easier to use procs . As they are now it’s cumbersome so I avoid using them which is too bad. It’s a super nice feature
<FromGitter> <bew> Oh that's right, forgot about that behavior for normal methods, yeah totally agree with you!
<FromGitter> <HarrisonB> Thanks @bew & @straight-shoota !
rkeene has left #crystal-lang [#crystal-lang]
ternarysolo has quit [Ping timeout: 246 seconds]
ternarysolo has joined #crystal-lang
<sagax> hi all!
<sagax> we have some `awesome-crystal` with list modules, plugins, etc...
<sagax> ?
<FromGitter> <bew> Yes
sagax has quit [Quit: Konversation terminated!]
sagax has joined #crystal-lang
<FromGitter> <Prutheus> Hello. I am on Ubuntu Server. I am using selenium-webdriver, on my macbook following code works well: ⏎ ⏎ ` ⏎ ⏎ ```code paste, see link``` ... [https://gitter.im/crystal-lang/crystal?at=5c816a33e527821f0a1e5a32]
<FromGitter> <Prutheus> why happens that error? o.O
<FromGitter> <Prutheus> Can please someone help me … I need to fix that asap
<FromGitter> <Prutheus> how can this happen? Cannot define class using reflection
DTZUZO has quit [Ping timeout: 268 seconds]
<z64> thats an error from selenium's API it looks like. if you google that error message, you can find some cases of other users getting it, but i don't know anything about selenium to derive what the issue might be
<FromGitter> <Prutheus> okay thans
<FromGitter> <HCLarsen> Hey folks, haven't been at this in a while, can someone remind me how to see the code generated by my macro? I remember there's a debug keyword, I just don't remember how to use it.
<z64> {% debug %} ; https://carc.in/#/cr
<FromGitter> <HCLarsen> Thanks.
<z64> yw
ternarysolo has quit [Ping timeout: 245 seconds]
sagax has quit [Read error: Connection reset by peer]
sagax has joined #crystal-lang
ternarysolo has joined #crystal-lang
ternarysolo has quit [Ping timeout: 245 seconds]
<FromGitter> <vladfaust> Not sure if it is a dirty hack or not, but `Type | _` restriction looks powerful and works in my case 💪 ⏎ ⏎ ```def get(path, &proc : ::HTTP::Server::Context -> View | _)``` [https://gitter.im/crystal-lang/crystal?at=5c81aa588f294b134a069b83]
<FromGitter> <vladfaust> cc @paulcsmith
<FromGitter> <dscottboggs_gitlab> what's the advantage of that over `-> _` ?
lucasb has quit [Quit: Connection closed for inactivity]
<FromGitter> <vladfaust> None, I guess :thinking:
<FromGitter> <dscottboggs_gitlab> I mean, it's definitely super powerful. Generics in crystal are awesome
<FromGitter> <dscottboggs_gitlab> There's also ` -> View | T forall T`
<robacarp> I _do not_ get forall T
<robacarp> the docs just did not land for me on that one
<FromGitter> <vladfaust> You can understand it as a separate method is generated for every argument type used in the program ⏎ ⏎ ```def foo(bar : T) forall T ⏎ end ⏎ ⏎ foo("bar") ⏎ foo(42)``` ⏎ ⏎ Two methods in this case [https://gitter.im/crystal-lang/crystal?at=5c81ace5f895944c085a611d]
<FromGitter> <vladfaust> And the T can be access in macro
<FromGitter> <dscottboggs_gitlab> interesting... I always thought of it as just generic functions... is it not?
<robacarp> what's the benefit to doing that vs just leaving it untyped
<FromGitter> <dscottboggs_gitlab> back in a few
<FromGitter> <vladfaust> @dscottboggs_gitlab I don't know how it is inside. But it can be *understood* as I described
<FromGitter> <vladfaust> @robacarp oh so many cases. Knowing `T` in macros is super-useful
<robacarp> okay, so the use case is that you know T pre-compile time
<robacarp> I've been wanting to enforce duck-typing at the method level, will this allow that sort of thing with some macro manipulation?
<FromGitter> <vladfaust> Yeah, `T` is fully known at this moment. You can do `.has_method?`, for example
<FromGitter> <vladfaust> Also *annotations*
<robacarp> I've been dreaming about something like this: `def method(arg : #duck_typed)`
<FromGitter> <vladfaust> Nope
<FromGitter> <vladfaust> With modules, may be
<robacarp> well, for example maybe I want it to respond to #to_i, and any object which can be converted to an Int is acceptable
<robacarp> it gets complicated quick
<robacarp> when you leave the types off of an interface, the stack traces become really intractable to the next developer
<robacarp> my goal is really to reduce that, so the developer has some idea what they did wrong and how to fix it
<robacarp> especially because so often the method isn't actually called on the passed-in-object until several calls down the stack
<FromGitter> <dscottboggs_gitlab> > *<robacarp>* my goal is really to reduce that, so the developer has some idea what they did wrong and how to fix it ⏎ ⏎ that would be really nice
<FromGitter> <dscottboggs_gitlab> I use `forall` with blocks a lot to annotate that the block return value is returned from the method, like ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5c81b06a25e4e24c0731efce]