jhass changed the topic of #crystal-lang to: The Crystal programming language | http://crystal-lang.org | Crystal 0.28.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
DTZUZO has quit [Ping timeout: 245 seconds]
alexherbo22 has joined #crystal-lang
alexherbo2 has quit [Ping timeout: 258 seconds]
alexherbo22 has quit [Ping timeout: 258 seconds]
<FromGitter> <franciscoadasme> hey, everyone, quick question. Is there a way to enforce that subclasses must have a method with the first argument of type `T`, but further arguments are allowed as well?, e.g., `A.foo(bar : Bar)` and `B.foo(bar: Bar, fuz = 1, ...)` are acceptable, but `C.foo(foo : Number)` isn't
<FromGitter> <Blacksmoke16> do you want to allow *any* additional arguments, or a specific set?
<FromGitter> <Blacksmoke16> https://play.crystal-lang.org/#/r/6s5g
<FromGitter> <Blacksmoke16> might be best you can get w/o having to do overloads for each
<fullforce> blacksmoke sorry I went to bed
<fullforce> this is essentially what I want to do
<fullforce> just pass on the self from the Test class to #puts_self
<FromGitter> <Blacksmoke16> hmm
<FromGitter> <Blacksmoke16> i dont have any good workarounds, but what is the use case for this?
<FromGitter> <dscottboggs_gitlab> if you're talking about a superclass of type `T` then `abstract def`s don't pay attention to argument numbers or types, you're free to do as you please
<FromGitter> <Blacksmoke16> they do
<FromGitter> <Blacksmoke16> https://play.crystal-lang.org/#/r/6s5s
<fullforce> event system
<fullforce> I want to be able to reference the class that the event was called from
<FromGitter> <Blacksmoke16> could do something like
<FromGitter> <Blacksmoke16> er why not just use inheritence?
<FromGitter> <Blacksmoke16> also might be able to use macros, however id need to see a more complete example
<fullforce> alright ill try to make a more complete one
<FromGitter> <Blacksmoke16> perfect
<FromGitter> <Blacksmoke16> however im not sure if that error is expected or a bug
<FromGitter> <Blacksmoke16> @dscottboggs_gitlab you know of any ways to restrict a method arg to a tuple of n members all of the same type?
<FromGitter> <Blacksmoke16> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5cbfd479375bac7470f5c566]
<FromGitter> <Blacksmoke16> i suppose that works?
rohitpaulk has joined #crystal-lang
<FromGitter> <Blacksmoke16> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5cbfd52e97dcb371d802ce0c]
<FromGitter> <Blacksmoke16> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5cbfd5341cd0b8307d619024]
<FromGitter> <Blacksmoke16> works for me?
<FromGitter> <Blacksmoke16> :shrug:
<FromGitter> <franciscoadasme> @Blacksmoke16 I also tried that, but I was wondering if the additional arguments in the subclass's method can be defined regularly, i.e., `A.foo(foo : Foo, arg1, arg2 = 2, ...)` instead of `A.foo(foo : Foo, **options)` and extract `arg1` and `arg2` (with default value) in the body
<FromGitter> <Blacksmoke16> could maybe use a macro to do something similar
<FromGitter> <Blacksmoke16> but using standard abstract defs i dont think you can since the signatures wouldnt match
<FromGitter> <franciscoadasme> But first, how can I get the subclass' methods?, I tried `@type.methods` inside the `macro inherited` but it's empty
<FromGitter> <franciscoadasme> and even if I get the subclass' methods somehow, how do I check the first argument's type?, this didn't work either: `B.methods[0].args[0].restriction == Int` (`restriction` is an `ASTNode`, where the documentation of `#==` states that it returns true if the node's textual representation is the same as the other node)
rohitpaulk has quit [Remote host closed the connection]
teardown has quit [Quit: Changing server]
teardown has joined #crystal-lang
laaron has quit [Quit: ZNC 1.7.1 - https://znc.in]
laaron has joined #crystal-lang
DTZUZO has joined #crystal-lang
azuri5 has joined #crystal-lang
<FromGitter> <j8r> I agree totally this shell script will better be removed
<FromGitter> <j8r> It also complexify debugging
azuri5 has quit [Quit: azuri5]
wuehlmaus has quit [Read error: Connection reset by peer]
wuehlmaus has joined #crystal-lang
<wuehlmaus> yesterday i deleted my crystal git because i thought that there were some files lying around so i wanted everything to be fresh. make takes so long and i am not even sure it will result in a crystal-git version now, even ``make docs'' takes so long ....
<wuehlmaus> [ on an Applebook from 2012 ]
azuri5 has joined #crystal-lang
laaron has quit [Quit: ZNC 1.7.1 - https://znc.in]
laaron has joined #crystal-lang
ashirase has quit [Ping timeout: 250 seconds]
ashirase has joined #crystal-lang
azuri5 has quit [Quit: azuri5]
azuri5 has joined #crystal-lang
<wuehlmaus> for the record, my problem was a recursion problem, now that i removed the link to ~/crystal/bin/crystal it builds very fast
<mps> wuehlmaus: interesting. you removed crystal script in bin dir?
azuri5 has quit [Quit: azuri5]
azuri5 has joined #crystal-lang
<wuehlmaus> yah, that seemed to be a big problem for compiling here
<wuehlmaus> mps: ^^^^
<mps> wuehlmaus: aha, will try same on alpine linux. thanks for info
alexherbo22 has joined #crystal-lang
<wuehlmaus> mps: i would be very glad if that solves something for you!
<FromGitter> <Blacksmoke16> @franciscoadasme https://play.crystal-lang.org/#/r/6s87
azuri5 has quit [Quit: azuri5]
<mps> wuehlmaus: no, I maintain crystal for Alpine linux
azuri5 has joined #crystal-lang
<wuehlmaus> ah
azuri5 has quit [Quit: azuri5]
azuri5 has joined #crystal-lang
<FromGitter> <aarongodin> Hi πŸ‘‹ does anyone have ideas about this question regarding kemal's `add_context_storage_type`? https://forum.crystal-lang.org/t/usage-of-kemals-add-context-storage-type/697
<FromGitter> <vladfaust> @aarongodin you could debug `StoreTypes`, printing its types in compilation time
laaron has quit [Remote host closed the connection]
laaron has joined #crystal-lang
<FromGitter> <vladfaust> Also https://gitter.im/sdogruyol/kemal
lucasb has joined #crystal-lang
azuri5 has quit [Read error: Connection reset by peer]
<FromGitter> <aarongodin> @vladfaust good call. I'll try seeing what's inside StoreTypes
fullforce has quit [Ping timeout: 268 seconds]
<FromGitter> <franciscoadasme> @Blacksmoke16 thanks... this will help me a lot
laaron has quit [Quit: ZNC 1.7.1 - https://znc.in]
<FromGitter> <Blacksmoke16> np
laaron- has joined #crystal-lang
rohitpaulk has joined #crystal-lang
laaron- has quit [Remote host closed the connection]
laaron has joined #crystal-lang
laaron has quit [Remote host closed the connection]
laaron has joined #crystal-lang
<FromGitter> <franciscoadasme> @Blacksmoke16 hey, I just realized that changing the first argument's type to `String` doesn't work, it still raises the error
<FromGitter> <franciscoadasme> https://play.crystal-lang.org/#/r/6s9g
<FromGitter> <Blacksmoke16> moment
<FromGitter> <Blacksmoke16> https://play.crystal-lang.org/#/r/6s9i my bad
<FromGitter> <Blacksmoke16> missed some `.id`
<FromGitter> <franciscoadasme> ohhh, one needs to compare the `MacroId`s... but why the need to do that if the textual representations don't seem to change?
rohitpaulk has quit [Ping timeout: 250 seconds]
<FromGitter> <bararchy> Is there a sure way to validate if a specific data is text (ASCII or UTF8) or binary data (random bytes, file, etc..)
<FromGitter> <j8r> @bararchy you have a Slice of UInt8?
<FromGitter> <j8r> you can do `String.new bytes`, then use https://crystal-lang.org/api/master/String.html#ascii_only%3F-instance-method and https://crystal-lang.org/api/master/String.html#valid_encoding%3F-instance-method
<FromGitter> <Blacksmoke16> @franciscoadasme `==` also does type checking, so are prob of diff types thus not equal
livcd has joined #crystal-lang
<FromGitter> <Blacksmoke16> i dont know types they are bug `.id` makes them both be `MacroId` so can compare the values
<FromGitter> <jwoertink> Is there something special needed to add `@[Deprecated]` to an enum? Or is only methods supported on that?
<FromGitter> <bararchy> Thanks @j8r
<FromGitter> <jwoertink> also, what do you call this thing? `@[Whatever]`. Is that a "flag"?
<FromGitter> <vladfaust> Annotation
<FromGitter> <jwoertink> Ah, right. Thanks
<FromGitter> <Blacksmoke16> :p
<FromGitter> <Blacksmoke16> i remember reading it was only methods @jwoertink, however not sure if that changed at some point inbetween
<FromGitter> <jwoertink> Yeah, I tried it on a few things and couldn't get it to show the warnings outside of methods
<FromGitter> <jwoertink> so I guess that's the case for now
<FromGitter> <Blacksmoke16> πŸ‘
<FromGitter> <j8r> wuehlmaus I'm opening a PR to remove the shell script :)
<mps> j8r: please don't. it doesn't work in my case
<FromGitter> <jwoertink> Is there a way with enums to have some sort of "constant_missing" type method? Like if I call an enum that doesn't exist, it calls a method similar to method_missing?
rohitpaulk has joined #crystal-lang
<FromGitter> <Blacksmoke16> i dont think it would even compile?
<FromGitter> <Blacksmoke16> if you reference an enum member that doesnt exist
<FromGitter> <jwoertink> I guess that's true
<FromGitter> <Blacksmoke16> https://play.crystal-lang.org/#/r/6s9r
<FromGitter> <j8r> mps It doesn't work in your case?
<FromGitter> <j8r> what do you mean? It's harder to debug when bin/crystal shell script calls the actual binary
<FromGitter> <jwoertink> I was just hoping for an alternative to the Deprecated annotation not working on enums lol
<FromGitter> <Blacksmoke16> :S
<FromGitter> <Blacksmoke16> could make your own
<mps> j8r: didn't investigated much, but it doesn't work because static crystal missing libs/shards
<FromGitter> <Blacksmoke16> er nvm that would be a bit challenging
<FromGitter> <j8r> I've made `make` working
<mps> there were alert of some special flag 'do_what_I_told_you', not these words but this meaning
<FromGitter> <j8r> I know, I've done a dirty hack for this
<mps> ok, will try again then
<FromGitter> <j8r> I'll just send a draft PR
<FromGitter> <j8r> to have the core members opinions
<FromGitter> <j8r> then I'll clean this up
<mps> np, if you know it works then I'm fine with it
<FromGitter> <j8r> Rust and and Go don't need a shell script, I don't know why it won't :)
<mps> also, I don't know. I'm not proficient with shell programming
<mps> it looks more cryptic than perl to me
<FromGitter> <j8r> I'm fighting with Makefile
<FromGitter> <j8r> a nightmare
alexherbo22 has quit [Quit: The Lounge - https://thelounge.chat]
DTZUZO has quit [Ping timeout: 245 seconds]
rohitpaulk has quit [Read error: Connection reset by peer]
yxhuvud has quit [Remote host closed the connection]
yxhuvud has joined #crystal-lang
<FromGitter> <j8r> How is it possible https://m.youtube.com/watch?v=7WgCt0Wooeo
<FromGitter> <j8r> I see, Nim uses DLL to hot reload code at runtime
gangstacat has quit [Quit: Ĝis!]
gangstacat has joined #crystal-lang
<FromGitter> <jwoertink> I think the compiler having an interpreter helps. I think that's how Julia is able to do their REPL
<oprypin> so julia is able to have an interpreter by having an interpreter. gotcha
<oprypin> code reloading is not even new. not that anyone takes it seriously
<FromGitter> <jwoertink> julia is able to have a repl by having an interpreter
<oprypin> sorry. my point is that having an interpreter is 99.9% of the difficulty of having a REPL
alexherbo2 has joined #crystal-lang
gangstacat has quit [Ping timeout: 276 seconds]