RX14 changed the topic of #crystal-lang to: The Crystal programming language | http://crystal-lang.org | Crystal 0.27.0 | 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
<jokke> sure :)
<jokke> non-aristotelian: keep in mind that this is a very old article compared to crystal's age
<non-aristotelian> jokke: Yeah I just saw that -- 2013.
<non-aristotelian> Cool. Posted the bug-report. I see 600+ open issues. I should pick one. :)
ua has quit [Ping timeout: 246 seconds]
non-aristotelian has quit [Quit: non-aristotelian]
DTZUZO has joined #crystal-lang
return0e has quit [Read error: Connection reset by peer]
return0e has joined #crystal-lang
<FromGitter> <dscottboggs_gitlab> Is there any way to create a function/method which is only accessible by instance methods or class methods of a particlar class or within a particular file? ⏎ ⏎ I have some private def methods that I want to access from class methods basically
<FromGitter> <dscottboggs_gitlab> eh, I guess :nodoc:-ing them is good enough if there isn't anything
_whitelogger has joined #crystal-lang
return0e has quit [Remote host closed the connection]
return0e has joined #crystal-lang
DTZUZO has quit [Ping timeout: 245 seconds]
t0nyandre has joined #crystal-lang
<oprypin> dscottboggs_gitlab, that sounds exactly like `protected`
<FromGitter> <dscottboggs_gitlab> you can access protected from class-methods?
<oprypin> i think it has something about "same file" or was it"same module"access
<FromGitter> <dscottboggs_gitlab> yes, I think protected will do fine. thank you
<FromGitter> <dscottboggs_gitlab> oh, also, you can `private def self.method` which is weird and I didn't think you'd be able to do that.
rohitpaulk has quit [Ping timeout: 245 seconds]
<FromGitter> <swinSpo> does crystal not have interfaces??
<FromGitter> <icyleaf> @swinSpo You can use abstract type: https://crystal-lang.org/docs/syntax_and_semantics/virtual_and_abstract_types.html
<FromGitter> <swinSpo> Yes, but then you can only satisfy one "interface"?
<FromGitter> <Timbus> You can also use Modules with abstract defs, and `include` them into your class, if you want something more akin to a interface/trait/role.
<FromGitter> <Timbus> Personally I feel it would be nice to decouple this functionality a little.. But Ruby
<FromGitter> <swinSpo> @Timbus and what would be the point of the include be?
<FromGitter> <Timbus> To .. satisfy the interface
<FromGitter> <swinSpo> how?
<FromGitter> <Timbus> it would error if you didnt provide the definitions
<FromGitter> <Timbus> and your class can be tested against the Module.. `instance.is_a?(YourInterface)`
<FromGitter> <swinSpo> sorry i dont get it
<FromGitter> <Timbus> ? you called the module Test. Your ProviderA now conforms to the interface 'Test'
<FromGitter> <Timbus> not Provider
<FromGitter> <swinSpo> Oh I can type hint for the Module? I didnt know that
rohitpaulk has joined #crystal-lang
<FromGitter> <Timbus> Yeah.. It's not so obvious
<FromGitter> <j8r> how to print ivars? https://carc.in/#/r/5gxp
rohitpaulk has quit [Ping timeout: 264 seconds]
<FromGitter> <swinSpo> @Timbus I have no ruby experience so some "obvious" things might be missing for me
<FromGitter> <icyleaf> @j8r It could not get instance vars https://carc.in/#/r/5gxu
<FromGitter> <j8r> @icyleaf yes, that's my issue. Is there a way to do it? `JSON::Serializable` manage to do it with https://github.com/crystal-lang/crystal/blob/c7181beb12d511f95880ae013a1d8f280eba4d34/src/json/serialization.cr#L138 , but that's not a macro
<FromGitter> <Timbus> Nah @swinSpo I doubt it's obvious in ruby either :P I'd prefer an explicit 'trait' definition or something tbh
<FromGitter> <j8r> I succeed @icyleaf
<FromGitter> <icyleaf> @j8r try this https://carc.in/#/r/5gxx
<FromGitter> <j8r> https://carc.in/#/r/5gxy
<FromGitter> <icyleaf> great!
<FromGitter> <j8r> thanks for the elp @icyleaf . That was macro inside macro
<FromGitter> <icyleaf> Got new tips, thanx too :P
<FromGitter> <icyleaf> @swinSpo https://play.crystal-lang.org/#/r/5gy1
ua has joined #crystal-lang
<FromGitter> <dscottboggs_gitlab> what is `\{%` as opposed to `{%`?
<FromGitter> <j8r> this is used to generate macro with macros
rohitpaulk has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 260 seconds]
<jokke> are there any plans to tighten the type checking of abstract method implementations?
<jokke> i noticed that at least the return type isn't checked against the abstract definition
ashirase has quit [Ping timeout: 246 seconds]
ashirase has joined #crystal-lang
<FromGitter> <swinSpo> @icyleaf what are you trying to show me?
<FromGitter> <swinSpo> Oh the include? Yes thanks I figured that one out once i knew I can include modules :)
<jokke> swinSpo: i usually prefer mixins over inheritance because of the obvious reasons but also because it works both with classes and structs. (you can't let a struct inherit a class or vice versa)
<FromGitter> <vusaalab> Hey guys! is crystal good for ffmpeg processing ?
<jokke> didn't you ask this exact question a day or so ago?
<jokke> vusaalab: i'd say: if you're happy with shelling out, it's as good as any scripting language.
<jokke> vusaalab: there's no libav bindings for crystal (yet) unfortunately
<FromGitter> <vusaalab> no need binding i can create a binding
<FromGitter> <vusaalab> but i need to now if i create a binding for that which is good for production run
<FromGitter> <alehander42> @oprypin this is very cool the irc <=> gitter thing
<FromGitter> <alehander42> how do you do it? clicking on the labels doesnt work like that
<jokke> vusaalab: what do you mean? what do you expect?
<jokke> vusaalab: libav bindings aren't trivial
<jokke> depending on what you want to do
<jokke> it won't run any faster just because it's crystal. the main work is being done by libav/ffmpeg anyway
<FromGitter> <vusaalab> I want to create API for user to upload video file and it will convert to MP4
<jokke> ok. if you write bindings, i'd be interested
<jokke> crystal is great for web stuff so it's a good choice
moei has joined #crystal-lang
rohitpaulk has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 240 seconds]
<FromGitter> <swinSpo> Hey, I have read through the docs regarding splats
<FromGitter> <swinSpo> it seems like the type ends up being a Tuple
rohitpaulk has joined #crystal-lang
<FromGitter> <swinSpo> ```code paste, see link``` ⏎ ⏎ This works, but how would i "store" the provider for later use in the provider method? [https://gitter.im/crystal-lang/crystal?at=5be56ec192b7d11721605bf3]
<FromGitter> <swinSpo> ```code paste, see link``` ⏎ ⏎ This does not work [https://gitter.im/crystal-lang/crystal?at=5be56ed66b9822140d025f7c]
rohitpaulk has quit [Ping timeout: 268 seconds]
return0e has quit [Remote host closed the connection]
return0e has joined #crystal-lang
<jokke> define "does not work"
<jokke> swinSpo
<jokke> it will probably complain about not being able to infer the type of @providers
<jokke> you will probably want to store it as an array
<jokke> which is just a case of assigning providers.to_a to @providers
rohitpaulk has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 245 seconds]
rohitpaulk has joined #crystal-lang
<FromGitter> <swinSpo> @jokke how does that work?
<jokke> how does what work?
<FromGitter> <swinSpo> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5be587e53102f1452174ebf7]
<jokke> `@providers = providers.to_a`
<FromGitter> <swinSpo> Like that?
<jokke> yes
<jokke> no
<jokke> on top you need to use colon instead of equals
<FromGitter> <swinSpo> of course
<FromGitter> <swinSpo> but then i still get
<FromGitter> <swinSpo> instance variable '@provider' of MultiProvider was not initialized directly in all of the 'initialize' methods, rendering it nilable.
<jokke> yeah that should work
<FromGitter> <swinSpo> I extend Provider
<FromGitter> <j8r> I'm working on a new way to serialize, between JSON::Serializable and JSON.mapping. ⏎ I got this: ⏎ ⏎ ```code paste, see link``` ⏎ ... [https://gitter.im/crystal-lang/crystal?at=5be5882fd001b9172032ebdb]
rohitpaulk has quit [Ping timeout: 240 seconds]
<FromGitter> <swinSpo> ```abstract class Provider ⏎ abstract def provide(ke : String) ⏎ end``` [https://gitter.im/crystal-lang/crystal?at=5be5883a4e7ca145207b7415]
<jokke> yeah ok then you have an initializer in Provider which you don't cover
<jokke> ok it's the default constructor
<FromGitter> <swinSpo> I dont though
<FromGitter> <swinSpo> So how do i fix this?
<jokke> you need to define an abstract constructor in the abstract class
<jokke> or use mixins instead
<FromGitter> <swinSpo> I dont understand.. but my provider has no initialize method, how can it be an issue?
<jokke> hm i'm confused now too
<FromGitter> <swinSpo> because this here
<FromGitter> <swinSpo> also works
<FromGitter> <Blacksmoke16> that would work even if you didnt have the abstract class, its not really doing anything
<jokke> works just fine
<FromGitter> <swinSpo> @Blacksmoke16 yes that is the point though
<jokke> swinSpo i'm guessing, you're not sharing all of the relevant code. in that case i can't help you
rohitpaulk has joined #crystal-lang
<FromGitter> <cserb> Hey I'd like to do smth like this: ⏎ ⏎ ```code paste, see link``` ⏎ ⏎ but this throws `missing argument: pull` ... [https://gitter.im/crystal-lang/crystal?at=5be58b0ae8add80e63c6cc03]
<FromGitter> <Blacksmoke16> would have to make an initialize to support that syntax
<FromGitter> <vladfaust> `include JSON::Serializable` defines a `def initialize(pull : JSON::PullParser)` only
<FromGitter> <Blacksmoke16> https://play.crystal-lang.org/#/r/5gzv
<FromGitter> <swinSpo> @jokke huh
<FromGitter> <Blacksmoke16> ^^
<FromGitter> <swinSpo> Thats all the code
<FromGitter> <cserb> ugh... that was it.
<FromGitter> <cserb> so simple... thanks
rohitpaulk has quit [Ping timeout: 245 seconds]
<FromGitter> <swinSpo> @jokke oh my.. its a typo
<jokke> :D:D
<jokke> yeah
<FromGitter> <swinSpo> @providers and i use @provider
<jokke> just spotted it
<jokke> ^^
<jokke> the compiler loves you :)
<jokke> protects you from all those little mistakes that are super common and would only become apparent at runtime in most interpreted languages :)
<FromGitter> <swinSpo> Well yes the compiler did tell me it was nilable, I just didn't believe it xD
rohitpaulk has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 252 seconds]
<jokke> anyone care to implement mpris bindings for crystal? :)
<jokke> basically it's "just" dbus
rohitpaulk has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 250 seconds]
t0nyandre has quit [Quit: WeeChat 2.3]
jemc has joined #crystal-lang
<FromGitter> <j8r> How can I check if a type is included in an union?
rohitpaulk has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 252 seconds]
jemc has quit [Ping timeout: 260 seconds]
<jokke> in macro context?
rohitpaulk has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 245 seconds]
rohitpaulk has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 244 seconds]
rohitpaulk has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 268 seconds]
rohitpaulk has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 260 seconds]
rohitpaulk has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 240 seconds]
moei has quit [Read error: Connection reset by peer]
moei has joined #crystal-lang
<FromGitter> <j8r> yes, it can be
<FromGitter> <j8r> I would like to do it for a generic
<FromGitter> <swinSpo> hi
<FromGitter> <swinSpo> Why do the docs not have any function return types?
<FromGitter> <swinSpo> Oh it seems like sometimes it does and sometimes it does not?
<FromGitter> <swinSpo> for example https://crystal-lang.org/api/0.27.0/Array.html#last%28n%3AInt%29-instance-method
<FromGitter> <swinSpo> "Returns the last n elements of the array." but it has no return type there
<FromGitter> <kinxer> Won't the return type just be whatever type the array holds (or a union of types, if your array contains different types)?
<FromGitter> <swinSpo> yes, so ```Array(T)```
<FromGitter> <swinSpo> Which is why it is confusing for me
<FromGitter> <swinSpo> for example in the same Array class docs, it gives me
<FromGitter> <swinSpo> ```def skip(count : Int) : Array(T) ```
<FromGitter> <swinSpo> ```def sort : Array(T) ```
<FromGitter> <kinxer> Could you give an example of where the docs do give a return type?
<FromGitter> <swinSpo> i just did, right above u
<FromGitter> <swinSpo> skip and sort have them
<FromGitter> <swinSpo> https://crystal-lang.org/api/0.27.0/Array.html#skip%28count%3AInt%29%3AArray%28T%29-instance-method
<FromGitter> <kinxer> Huh. Yeah, I suppose that is pretty inconsistent.
<FromGitter> <kinxer> Are these docs directly generated with `crystal doc`?
<FromGitter> <swinSpo> Looking at the source, it seems like the issue is that those methods actually have return types declared in the source file
<FromGitter> <kinxer> Yeah, I was wondering if the difference was from the source.
<FromGitter> <swinSpo> that seems to be it.. which is a bit unfortunate because I do believe that the docs should definitely have return types
<FromGitter> <cserb> Does anyone understand this error message: ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5be5beb0bb88787474a23ec5]
<FromGitter> <kinxer> @swinSpo But does that reflect the behavior of the actual code? Crystal allows methods that will return an indeterminate type.
<FromGitter> <kinxer> @cserb Could you provide some context about what you're trying to do that caused this?
<FromGitter> <swinSpo> @kinxer what do you mean?
<FromGitter> <sam0x17> any idea when the crystal alpine linux package will get updated to 0.27.0?
<FromGitter> <kinxer> @swinSpo Are you proposing that every method in the docs give its return type, or just the ones that have a specific type or union that they can return? For example, you could write a method ⏎ ⏎ ```def give_back(object) ⏎ object ⏎ end``` ⏎ ⏎ I know this is an extreme example, but this method couldn't possibly have a return type in the docs. [https://gitter.i
<FromGitter> ... m/crystal-lang/crystal?at=5be5c1e89600d10e64841644]
<FromGitter> <swinSpo> what about ⏎ ⏎ ```def give_back(object : T) : T``` [https://gitter.im/crystal-lang/crystal?at=5be5c241bb88787474a25b85]
<FromGitter> <kinxer> @swinSpo Touche. I'd have to bow to more knowledgeable developers to say whether there's a cost (other than a visual one) to specifying all your types like that. It does make me wonder if it's feasible to include type resolution in `crystal doc`, but that might be going a bit overboard.
rohitpaulk has joined #crystal-lang
johndescs has quit [Ping timeout: 268 seconds]
johndescs has joined #crystal-lang
<FromGitter> <swinSpo> Since crystal is a statically typed language, it kind of already knows all the types a function returns, for example ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5be5c3e03102f1452176b7e2]
<FromGitter> <swinSpo> it already knows that o(T) returns T and knows the methods i can call on it
rohitpaulk has quit [Ping timeout: 244 seconds]
tilpner has quit [Remote host closed the connection]
tilpner has joined #crystal-lang
rohitpaulk has joined #crystal-lang
tilpner has quit [Remote host closed the connection]
rohitpaulk has quit [Ping timeout: 252 seconds]
<FromGitter> <straight-shoota> @sam0x17 see alpinelinux/aports#5560
tilpner has joined #crystal-lang
<FromGitter> <swinSpo> hey, I'd like some help
<FromGitter> <swinSpo> ``````
<FromGitter> <swinSpo> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5be5ceb5bb88787474a2b8f0]
<FromGitter> <swinSpo> Is there some way to support Initialization with 1 to n providers?
<FromGitter> <swinSpo> I want to ensure that it has at least 1
<FromGitter> <swinSpo> i dont care "how", splat would also be ok, but that didn't work for me either
<FromGitter> <kinxer> In what way did splat not work?
<FromGitter> <swinSpo> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5be5cf9f4e7ca145207d8b11]
<FromGitter> <swinSpo> instance variable '@providers' of MultiProvider must be Array(Provider), not Array(EnvProvider)
<FromGitter> <swinSpo> that only works at 2 or more
non-aristotelian has joined #crystal-lang
<FromGitter> <kinxer> Could you do ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5be5d05e4e7ca145207d8fbf]
rohitpaulk has joined #crystal-lang
<FromGitter> <swinSpo> that seems to work (if you remove the type from *others )
<FromGitter> <swinSpo> I dont really understand the splat typehint, it does not really seem to do anything?
<FromGitter> <swinSpo> My thinking was that If i declare my initialize method like this ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5be5d1f2c0e6da07fefe51e3]
rohitpaulk has quit [Ping timeout: 252 seconds]
<FromGitter> <swinSpo> I thought that I would now get a splat (an array of providers) so that to_a would return an array of Providers too
<FromGitter> <kinxer> Yeah, that's what I would expect.
<FromGitter> <swinSpo> But yeah that doesnt work.. ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5be5d28847217e07fff85669]
<FromGitter> <kinxer> What about ⏎ ⏎ ```def initialize(*providers : Provider) ⏎ @providers += others.to_a ⏎ end``` [https://gitter.im/crystal-lang/crystal?at=5be5d300e8add80e63c8e397]
<FromGitter> <kinxer> I'm assuming that EnvProvider is a subclass of Provider, but it seems like by assigning `@providers` directly you're causing it to be an array specifically composed of `EnvProvider`s, not more generally of `Provider`s.
rohitpaulk has joined #crystal-lang
<FromGitter> <swinSpo> Your suggestion seems to work! But it is odd, considering that the type of @providers is : Array(Provider)
<FromGitter> <kinxer> Yeah, that is odd. I wonder if that's intended behavior.
rohitpaulk has quit [Ping timeout: 252 seconds]
DTZUZO has joined #crystal-lang
rohitpaulk has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 252 seconds]
<FromGitter> <Blacksmoke16> @swinSpo this might be related to an issue i found: https://github.com/crystal-lang/crystal/issues/6996
<FromGitter> <Blacksmoke16> maybe...just at a glance :p
rohitpaulk has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 276 seconds]
rohitpaulk has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 252 seconds]
rohitpaulk has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 268 seconds]
rohitpaulk has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 260 seconds]
DTZUZO has quit [Ping timeout: 246 seconds]
rohitpaulk has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 272 seconds]
rohitpaulk has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 268 seconds]
jemc has joined #crystal-lang
jemc has quit [Client Quit]
rohitpaulk has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 244 seconds]
<FromGitter> <dscottboggs_gitlab> @swinSpo I figured it ou!!!
blassin has joined #crystal-lang
<FromGitter> <dscottboggs_gitlab> here, this works, but it makes me suspect that there's a bug that you've just found ⏎ ⏎ https://carc.in/#/r/5h4v ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5be6142e6b9822140d06e045]
ashirase has quit [Ping timeout: 264 seconds]
dostoyevsky has quit [Quit: leaving]