ChanServ changed the topic of #crystal-lang to: The Crystal programming language | http://crystal-lang.org | Crystal 0.31.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> <Blacksmoke16> https://play.crystal-lang.org/#/r/7vas rip
early has quit [Quit: Leaving]
<FromGitter> <Blacksmoke16> yea this is tricky
<FromGitter> <tenebrousedge> can't you do `Proc(String, _)` ?
<FromGitter> <Blacksmoke16> nope
early has joined #crystal-lang
<FromGitter> <tenebrousedge> is it necessary to use an alias?
<hightower4> Blacksmoke16 I've adapted your code and the latest version I have is https://play.crystal-lang.org/#/r/7vbf . (It is just a slight reorganization/adaptation; it doesn't add anything new except for trivial functions)
<hightower4> (you don't need to switch to this version, I'm just listing it because it's here)
<FromGitter> <Blacksmoke16> yea idk how you going to do this
<FromGitter> <Blacksmoke16> at least including the block in the new event handler
<FromGitter> <Blacksmoke16> it would be more doable if the proc would be a static type
<FromGitter> <Blacksmoke16> hm actually sec
<FromGitter> <bigeasy> Hello. I'm looking at Crystal again after a long time away. Has there been any progress on the debugger or code coverage?
<FromGitter> <tenebrousedge> I don't know what problems you had with code coverage; the tests seem pretty good to me
<FromGitter> <tenebrousedge> I don't know that anyone has taken a look at improving gdb debugging
<FromGitter> <bigeasy> A code coverage tool.
<FromGitter> <bigeasy> Last I looked there was this: github.com/anykeyh/crystal-coverage
<FromGitter> <bigeasy> Which seems to have been updated in June, so still active.
<hightower4> Blacksmoke16 that's about it for me for today, continuing tomorrow. if you come up with something, please post and/or I'll ask tomorrow if there were any news
<hightower4> thanks much for all the great help
Vexatos has quit [Quit: ZNC Quit]
Vexatos has joined #crystal-lang
<FromGitter> <Daniel-Worrall> Ooh event emiters. I'd love to join in here as I've been thinking of a better system for my lib
<FromGitter> <tenebrousedge> what's your lib?
<FromGitter> <Daniel-Worrall> I've been using onyx-eda but it has its limitations
<FromGitter> <Daniel-Worrall> Very work in progress twitch lib. I'm basically coding the functionality as and when I need it for the apps I'm making
<FromGitter> <Daniel-Worrall> z64 provided a good foundation for me
<FromGitter> <tenebrousedge> huh
<FromGitter> <Blacksmoke16> im close with what i want to do
<FromGitter> <Blacksmoke16> `Error: instance variable '@handler' of EventAdded must be Proc(Event, Bool), not Proc(EventAdded, Bool)` :sad:
HumanGeek has quit [Remote host closed the connection]
<FromGitter> <tenebrousedge> poke it with a stick
HumanGeek has joined #crystal-lang
<FromGitter> <Blacksmoke16> hmm
f1refly has quit [Ping timeout: 246 seconds]
f1refly has joined #crystal-lang
Nekka has quit [Ping timeout: 240 seconds]
<FromGitter> <ImAHopelessDev_gitlab> hey
dwdv has joined #crystal-lang
absolutejam2 has joined #crystal-lang
ht_ has joined #crystal-lang
Nekka has joined #crystal-lang
Nekka has quit [Ping timeout: 240 seconds]
Nekka has joined #crystal-lang
bazaar has quit [Ping timeout: 244 seconds]
bazaar has joined #crystal-lang
absolutejam2 has quit [Ping timeout: 240 seconds]
ht_ has quit [Quit: ht_]
DTZUZO has quit [Ping timeout: 265 seconds]
teardown has quit [Ping timeout: 268 seconds]
dwdv has quit [Ping timeout: 240 seconds]
absolutejam2 has joined #crystal-lang
<FromGitter> <absolutejam_gitlab> anyone used Onyx?
<FromGitter> <absolutejam_gitlab> ```code paste, see link``` ⏎ ⏎ Never seen a variable declared with a `?` before. I kinda like it [https://gitter.im/crystal-lang/crystal?at=5db150d6f26ea4729de6c252]
<FromGitter> <confact> Onyx looked like a abandoned project so didn't look into it.
<FromGitter> <absolutejam_gitlab> last commit was 2 months ago
<FromGitter> <absolutejam_gitlab> do you mean Amethyst?
<FromGitter> <absolutejam_gitlab> (Too many mineral related names)
<FromGitter> <absolutejam_gitlab> and then there was 'raze' which looked like a Kemal style micro framework but that's abandoned
<FromGitter> <absolutejam_gitlab> Onyx is a @vladfaust production
Nekka has quit [Ping timeout: 268 seconds]
<FromGitter> <confact> Abandoned is maybe a bit too strong word. I wanted a bit more active framework and the website was a bit broken too. Little activity is for me warning signs for soon to be abandoned.
absolutejam2 has quit [Ping timeout: 240 seconds]
absolutejam2 has joined #crystal-lang
Nekka has joined #crystal-lang
<FromGitter> <absolutejam_gitlab> I know what you mean
<FromGitter> <absolutejam_gitlab> What did you go with, Amber?
DTZUZO has joined #crystal-lang
DTZUZO has quit [Ping timeout: 268 seconds]
DTZUZO has joined #crystal-lang
DTZUZO has quit [Ping timeout: 268 seconds]
DTZUZO has joined #crystal-lang
absolutejam2 has quit [Read error: Connection reset by peer]
absolutejam2 has joined #crystal-lang
DTZUZO has quit [Ping timeout: 276 seconds]
alexherbo2 has joined #crystal-lang
<FromGitter> <confact> I went with lucky. Active and good support here on gitter.
<FromGitter> <absolutejam_gitlab> sweet
<hightower4> I used to contribute to Amber. If I were to do it again, I'd try lucky
DTZUZO has joined #crystal-lang
HumanGeek has quit [Ping timeout: 276 seconds]
Nekka has quit [Ping timeout: 268 seconds]
Nekka has joined #crystal-lang
Nekka has quit [Ping timeout: 264 seconds]
absolutejam2 has quit [Ping timeout: 265 seconds]
Nekka has joined #crystal-lang
dwdv has joined #crystal-lang
absolutejam2 has joined #crystal-lang
duane has quit [Ping timeout: 245 seconds]
HumanG33k has joined #crystal-lang
HumanG33k has quit [Remote host closed the connection]
HumanG33k has joined #crystal-lang
ma_ has joined #crystal-lang
duane has joined #crystal-lang
<FromGitter> <ImAHopelessDev_gitlab> Good morning!!
<hightower4> mornin'
<FromGitter> <absolutejam_gitlab> Why'd you say that hightower4?
<hightower4> the person above said "Good morning!!" :)
<FromGitter> <absolutejam_gitlab> > *<hightower4>* I used to contribute to Amber. If I were to do it again, I'd try lucky
<FromGitter> <absolutejam_gitlab> I guess I did reply 2 hours later haha
<FromGitter> <absolutejam_gitlab> mb
<FromGitter> <ImAHopelessDev_gitlab> I got a call from Best Buy (warehouse position). If I get it, I'm going to donate some $ to manas. The reason why I didn't donate to manas last time I got a job, is because I gave all my money to my mom for rent lol. She apparently has $30k credit card debt, and has $19k paid off so far. She showed me her national debt relief account, 13 or so credit card companies. It's gonna be a while
<FromGitter> <absolutejam_gitlab> Focus on yourself and your family first :)
<FromGitter> <absolutejam_gitlab> Contribute in time and community efforts, I'm sure Manas and the Crystal community at large would appreciate that more than monetary donations
<FromGitter> <absolutejam_gitlab> and good luck
<FromGitter> <ImAHopelessDev_gitlab> Yeah true. crystal has a big part of my life I feel like I need to give back
<FromGitter> <ImAHopelessDev_gitlab> @absolutejam_gitlab Thanks!! I'm going to need it ;D
<FromGitter> <fridgerator> Does anyone know what's going on with Serdar on Twitter?
<FromGitter> <ImAHopelessDev_gitlab> Serdar?
<hightower4> sdogruyol, author of Kemal
<FromGitter> <ImAHopelessDev_gitlab> Oh @sdogruyol
absolutejam2 has quit [Ping timeout: 245 seconds]
<FromGitter> <bajro17> Why because of Japanese :D
<FromGitter> <bararchy> @fridgerator yeha.. it was kind of a shit show :\
<FromGitter> <fridgerator> Is he ok? Lol
<FromGitter> <bararchy> I hope he is fine
<FromGitter> <bararchy> I have no clue
<hightower4> what's the summary of what happened?
<FromGitter> <bararchy> it was over 500 tweets in 3-4 hours, no way to summarized it XD
<hightower4> lol
absolutejam2 has joined #crystal-lang
<FromGitter> <ImAHopelessDev_gitlab> https://twitter.com/sdogruyol/status/1187285741879091201 ⏎ ⏎ English starts at 10:30 or so
<FromGitter> <ImAHopelessDev_gitlab> Most of his videos are in turkish, I don't know what he's saying. I think he's just ranting
<hightower4> in some he is talking to someone behind the camera (or actually in another room behind the doors)
<FromGitter> <ImAHopelessDev_gitlab> He mentioned github lol
<FromGitter> <ImAHopelessDev_gitlab> @sdogruyol and me and have something in common there :)
<FromGitter> <absolutejam_gitlab> It looks like mental health issues, and unless he wants to talk about it here, I don't really think it's the place
<hightower4> Do we know if Pragmatic Programmers have some plans to update the Crystal book?
<FromGitter> <tenebrousedge> we do not know. They don't hang out here
<hightower4> I was hoping to read something about generics and macros, but it was not covered at all
<FromGitter> <tenebrousedge> that's shocking
Nekka has quit [Ping timeout: 268 seconds]
<FromGitter> <absolutejam_gitlab> Jesus Christ
<FromGitter> <ImAHopelessDev_gitlab> sup?
Nekka has joined #crystal-lang
<FromGitter> <absolutejam_gitlab> Just spent 5 minutes look up the `render` function in Phoenix's docs
<FromGitter> <absolutejam_gitlab> to find the `partial` parameter
<FromGitter> <ImAHopelessDev_gitlab> lmao
<FromGitter> <absolutejam_gitlab> While looking at Amber framework...
<FromGitter> <ImAHopelessDev_gitlab> LOL
<FromGitter> <absolutejam_gitlab> different frameworks, different languages
<hightower4> absolutejam: (sent you a privmsg to your irc nick, check when near)
Nekka has quit [Ping timeout: 240 seconds]
<FromGitter> <ImAHopelessDev_gitlab> https://twitter.com/thomasfuchs/status/1103700462107164672 LOL ary retweeted
Nekka has joined #crystal-lang
<FromGitter> <ImAHopelessDev_gitlab> asterite's twitter is amazing
Nekka has quit [Ping timeout: 240 seconds]
ma_ has quit [Ping timeout: 264 seconds]
Nekka has joined #crystal-lang
return0e has joined #crystal-lang
return0e_ has quit [Ping timeout: 268 seconds]
alexherbo21 has joined #crystal-lang
alexherbo2 has quit [Ping timeout: 268 seconds]
absolutejam2 has quit [Ping timeout: 246 seconds]
ht__ has joined #crystal-lang
HumanG33k has quit [Remote host closed the connection]
HumanG33k has joined #crystal-lang
HumanG33k has quit [Quit: Leaving]
alexherbo216 has joined #crystal-lang
alexherbo21 has quit [Ping timeout: 265 seconds]
alexherbo216 is now known as alexherbo2
<hightower4> Blacksmoke16, Hey, if you'll be interested in looking more about the events thing from yesterday, that'd be awesome. In the meantime I worked on other parts of code during today
<FromGitter> <absolutejam_twitter> Got a repo?
<hightower4> not yet, there is around 18k lines of code to port, and I have various parts done but nothing that has any chance of working together when its run
<hightower4> Just now I am working on trying to tie together the parts that exist, so that I use that as driver towards a minimal working version
<FromGitter> <Blacksmoke16> i have some ideas but no promises
<FromGitter> <Blacksmoke16> er nvm, already tried them
<FromGitter> <Blacksmoke16> im out of ideas on the eventAdded event
<hightower4> Blacksmoke16 you mean the issue is we can't call emit(NewListener, RealEvent) ? How about if we emitted emit(NewListener, :name), where :name is a symbol/name of the event that was added? This would work just fine, because it is not used for anything anyway except for trying to determine which event was added
<FromGitter> <Blacksmoke16> passing the block is the hard part
<hightower4> And for the person doing the comparison, it's the same if they're gonna do if event == MouseEvent, or if they need to say if event == :mouse_event
<hightower4> Ah that...
<hightower4> that's not critically important to get working
<hightower4> as mentioned yesterday no place in the current code actually does something with it, they ignore it
<hightower4> they only look at the first arg which is class of event
<FromGitter> <Blacksmoke16> that makes it much easier then
<FromGitter> <Blacksmoke16> i also made a little UX update
<hightower4> wonderful
<FromGitter> <Blacksmoke16> https://play.crystal-lang.org/#/r/7vsq
<FromGitter> <Blacksmoke16> idk how you would feel about it but i like it
duane has quit [Ping timeout: 246 seconds]
<FromGitter> <Blacksmoke16> basically the handlers get passed the event obj vs each arg on its own
<hightower4> awesome, I was thinking about this earlier today!
<FromGitter> <Blacksmoke16> while still allowing passing a splat of args, it just internally news up the record with those args
<FromGitter> <tenebrousedge> event obj sounds like a good idea to me
<FromGitter> <Blacksmoke16> what was the other thing?
<hightower4> When we call emit(SomeEvent, args), the emit() itself should also emit( AnyEvent, SomeEvent, args) -- (basically those are catch-all listeners that want to see when any event is emitted)
<FromGitter> <Blacksmoke16> oh ok
<hightower4> This is actually possible/doable now when the args are packed in the struct
<FromGitter> <Blacksmoke16> indeed
<FromGitter> <Blacksmoke16> should just have to define like `record AnyEvent, event_type : Event.class, event : Event`
<hightower4> by the way, could this solve the block issue as well? Could somehow the original block/proc also be saved somewhere in a struct?, so when we call emit(NewListener, OrigEvent), the block/proc is accessible at OrigEvent.something ?
<FromGitter> <Blacksmoke16> then do a `emit AnyEvent, type, obj`
<FromGitter> <Blacksmoke16> maybe, challenge i ran into is like `Proc(Event, Bool)` doesn't work with `Proc(MouseEvent, Bool)`
<FromGitter> <ilanpillemer> to check if a certain strings exists in an array is `index` the best method to use?
<FromGitter> <Blacksmoke16> `#includes?`
<FromGitter> <ilanpillemer> thanks
<FromGitter> <tenebrousedge> ^
<FromGitter> <ilanpillemer> in `Go` its `contains`
<FromGitter> <ilanpillemer> I think
<FromGitter> <ilanpillemer> maybe not
<FromGitter> <ilanpillemer> Anyways. Thanks!
<hightower4> Blacksmoke16 yeah I saw that too, why doesn't it work? Isn't MouseEvent subclass of Event and thus guaranteed to behave like Event?
<FromGitter> <ilanpillemer> the docs are hard to grep
<FromGitter> <Blacksmoke16> idk, @asterite prob knows
<FromGitter> <tenebrousedge> @Blacksmoke16 if `MouseEvent` extends `Event`, then you can't use `MouseEvent` in a `Proc` that takes `Event` ?
<FromGitter> <Blacksmoke16> seems to me it would, but :shrug: could be some internaly thing
<FromGitter> <Blacksmoke16> correct
<hightower4> correct
<FromGitter> <tenebrousedge> that's annoying
<hightower4> asterite, could you advise on the above? I.e. why Proc(X,Y) doesn't work with a subclass of X?
<FromGitter> <Blacksmoke16> https://play.crystal-lang.org/#/r/7vsu
<FromGitter> <Blacksmoke16> example ^
<FromGitter> <Blacksmoke16> idk if its a bug or for some technical reason or something :shrug:
<FromGitter> <tenebrousedge> it does work with non-Procs though
<FromGitter> <tenebrousedge> hmmm
<FromGitter> <Blacksmoke16> hightower4: the one idea i thought of but didnt explore totally yet, is instead of passing in the proc, pass in the type
<FromGitter> <Blacksmoke16> like
<FromGitter> <Blacksmoke16> er nvm that wouldnt help, as you would be missing the proc body
dannyAAM has quit [Quit: znc.saru.moe : ZNC 1.6.2 - http://znc.in]
dannyAAM has joined #crystal-lang
alexherbo2 has quit [Quit: The Lounge - https://thelounge.chat]
<FromGitter> <ilanpillemer> is there a better way of doing this
<FromGitter> <ilanpillemer> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5db1ecf5e1c5e91508ca531a]
<FromGitter> <ilanpillemer> oops
<FromGitter> <ilanpillemer> ``` floors.each do |k, v| ⏎ return k if v.includes? "E" ⏎ end``` [https://gitter.im/crystal-lang/crystal?at=5db1ed0dfb4dab784afba319]
<FromGitter> <tenebrousedge> `floors.find {|k,v| v.includes? "E"}.first`
<FromGitter> <tenebrousedge> mm
<FromGitter> <Blacksmoke16> dont think you would need the first?
<FromGitter> <tenebrousedge> `.try &.first`
<FromGitter> <ilanpillemer> does find return the key?
<FromGitter> <tenebrousedge> it returns `{K,V} | Nil`
<FromGitter> <Blacksmoke16> 👍
<FromGitter> <asterite> the proc thing is not a bug. Maybe it can work with classes because they are always represented as pointers
<FromGitter> <asterite> but for structs and modules, if you have `->(ev : SomeEvent)` that input type is a struct, but in `->(ev : Event)` the input type is essentially a union (different binary representation) and casting one proc to another is not trivial, you have to cast the input type
<FromGitter> <asterite> It can be done and should probably be done, but it's a bit hard
<FromGitter> <asterite> the compiler would have to create a wrapper proc, I'm not sure if that needs a closure or not
<FromGitter> <asterite> As a workaround you can do this: https://play.crystal-lang.org/#/r/7vt6
<FromGitter> <Blacksmoke16> 😮
<FromGitter> <Blacksmoke16> ill have to give that a try, thanks for the explanation as well
<FromGitter> <asterite> which is essentially what the compiler could do behind the scenes, but not that the `else` branch creates a closure over `handler`, so it allocates heap memory. When implicitly casting things the compiler never does implicit heap allocations, so that's why we don't want to do it yet
<FromGitter> <tenebrousedge> oooh I think I can use that workaround for a different problem
<hightower4> this needs to be integrated in our code simply so that it exists and can be looked up by other poor souls :)
<hightower4> thanks asterite
<FromGitter> <asterite> Glad to help :-)
<FromGitter> <asterite> @Blacksmoke16 what do you want to do? I'm thinking that one can avoid using proc literal in most cases by using blocks
<FromGitter> <ilanpillemer> iterators dont yield?
<FromGitter> <tenebrousedge> ??
<FromGitter> <tenebrousedge> example?
<FromGitter> <ilanpillemer> I havent tried
<FromGitter> <ilanpillemer> just dont see it in the docs
<FromGitter> <ilanpillemer> what I have tried it just a return
<FromGitter> <ilanpillemer> but that resets each time
<FromGitter> <ilanpillemer> I am assuming a yield pauses execution in that place
<FromGitter> <tenebrousedge> yes
<FromGitter> <ilanpillemer> and a return doesnt
<FromGitter> <ilanpillemer> but if I try yield in next.. it complains
<FromGitter> <tenebrousedge> it halts the execution of a loop or method and returns the value to the right
<FromGitter> <tenebrousedge> example?
<FromGitter> <ilanpillemer> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5db1f40e9825bd6bacc0547e]
<FromGitter> <tenebrousedge> in a `next` you should `return`
<FromGitter> <ilanpillemer> but if I return a lose place
<FromGitter> <ilanpillemer> so when it comes in again it starts from the beginning
<FromGitter> <ilanpillemer> and I always get the same value
<FromGitter> <tenebrousedge> you may need an instance var to track that
<FromGitter> <ilanpillemer> but I am going through all combinations
<FromGitter> <tenebrousedge> don't pass a block then
<FromGitter> <tenebrousedge> memoize the return value of `each_combination(2)`, without passing it a block
<FromGitter> <ilanpillemer> well I wanted to do something with the combinations and yield something else
<FromGitter> <ilanpillemer> maybe it should be an enumerable?
<FromGitter> <tenebrousedge> so `@iter = ... each_combination(2); return @iter.next `
<FromGitter> <asterite> I think you need to wrap the Iterator that's returned from each_combination
<FromGitter> <asterite> Right, call next, if it's stop then stop. Otherwise do something with the value
<FromGitter> <asterite> but that's just a map iterator
<FromGitter> <asterite> so each_combination(2).map
<FromGitter> <ilanpillemer> Thanks!
rohitpaulk has joined #crystal-lang
<FromGitter> <Blacksmoke16> @asterite its for hightower4 event thing he's porting
<hightower4> @asterite I'm working on equivalent of https://github.com/chjj/blessed for crystal, and this is/was needed as part of its event system
<FromGitter> <asterite> nice
<FromGitter> <Blacksmoke16> https://play.crystal-lang.org/#/r/7vta this seems to work
<FromGitter> <Blacksmoke16> it at least compiles
duane has joined #crystal-lang
<hightower4> Blacksmoke16 oh also one thing is the ability for events to have no arguments. I added this via wrapping "...splat.., " into {% if args %}, but maybe you have a better way, and also I was unable to apply this condition to the alias Handler = line
<FromGitter> <Blacksmoke16> prob best if it was its own overload
<hightower4> aah indeed
<hightower4> this is great, thanks for help
<FromGitter> <Blacksmoke16> 👍
rohitpaulk has quit [Ping timeout: 268 seconds]
<FromGitter> <ilanpillemer> what type is the iterator
<FromGitter> <kinxer> `Iterator`?
<FromGitter> <ilanpillemer> Trying to understand what to use
<FromGitter> <ilanpillemer> if I maintain an iterator as a stateful value to support another iterator
<FromGitter> <ilanpillemer> eg
<FromGitter> <ilanpillemer> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5db202957477946badc3ba66]
<FromGitter> <ilanpillemer> the compiler complains that it cant infer the type
<FromGitter> <ilanpillemer> but my attempts to work out the type havent worked out very well
<FromGitter> <tenebrousedge> maybe try `pp typeof(expression)`
<FromGitter> <ilanpillemer> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5db2033b7477946badc3bef6]
<FromGitter> <ilanpillemer> thats what happened when I tried
<FromGitter> <kinxer> `floors[with_elevator].each.reject("E").not_nil!.each_combination(2)`?
<FromGitter> <tenebrousedge> I think you should type that as `Iterator(String)`
<FromGitter> <tenebrousedge> or `CombinationIterator(String)`
<FromGitter> <tenebrousedge> `Array` is a namespace
<FromGitter> <asterite> you can't have Iterator as an instance variable, it's a current known limitation
<FromGitter> <tenebrousedge> D:
<FromGitter> <kinxer> @asterite Why is that? Difficulty with type resolution?
<FromGitter> <ilanpillemer> hmm..
<FromGitter> <ilanpillemer> so how do I this without an instance variable?
<FromGitter> <kinxer> Are `floors` and `with_elevator` instance variables you have access to?
<FromGitter> <ilanpillemer> floors is
<FromGitter> <ilanpillemer> With_elevator is a method
<FromGitter> <kinxer> Ah... Gotcha.
<hightower4> Hey if I want getter and setter for e.g. 3 properties to be delegated to some other object, what's the most streamlined way to do it?
<FromGitter> <ilanpillemer> I am trying to learn how to use iterators
<FromGitter> <ilanpillemer> @tenebrousedge keeps telling me I should
<FromGitter> <kinxer> @hightower4 A short version of this? https://play.crystal-lang.org/#/r/7vtw
<FromGitter> <tenebrousedge> Crystal is at its most expressive and powerful when you encode your problem in an `Enumerable`/`Iterable` data structure. This seems to be an awkward edge case
<FromGitter> <tenebrousedge> there has to be some way around this <__<
<FromGitter> <tenebrousedge> @ilanpillemer how large is the array, if you do `each_combination(2).to_a` ?
<FromGitter> <tenebrousedge> this may not be a good problem for `Iterator` :/
<jhass> hightower4: https://crystal-lang.org/api/0.31.1/Object.html#delegate(*methods,toobject)-macro
<hightower4> thanks jhass , kinxer
<FromGitter> <ilanpillemer> seems you should be able to chain iterators
<FromGitter> <tenebrousedge> you can
<FromGitter> <kinxer> @hightower4 The message from @jhass above is exactly right: https://play.crystal-lang.org/#/r/7vuh ⏎ Note, however, that you must use strings if the method name (e.g. `a=`) includes certain characters.
<FromGitter> <tenebrousedge> @ilanpillemer what's the problem you're working on?
<FromGitter> <ilanpillemer> https://adventofcode.com/2016/day/11
<FromGitter> <ilanpillemer> it looks like breadth first search
<FromGitter> <ilanpillemer> I could do it other ways
<FromGitter> <ilanpillemer> I just wanted to try using iterators
<FromGitter> <ilanpillemer> but I guess you can’t chain iterators at the moment, but chaining iterators does feel like a valid use case.
<FromGitter> <tenebrousedge> what do you mean by "chain iterators" here?
<FromGitter> <ilanpillemer> in the iterator I am implementing
<FromGitter> <ilanpillemer> I call another iterator .. apply some logic and find some way to seem to “yield"
<FromGitter> <ilanpillemer> but you cant actually yield
<FromGitter> <ilanpillemer> so you need to keep the iterator you are calling as a variable
alexherbo2 has joined #crystal-lang
<FromGitter> <ilanpillemer> but if you cant have an iterator as a property
<FromGitter> <ilanpillemer> or field of the class
<FromGitter> <ilanpillemer> then its impossible?
<FromGitter> <asterite> Can you create the Iterator and pass it to the constructor of a type? Maybe showing some complete code of what you want to do might help
<FromGitter> <tenebrousedge> You can definitely do this with some things that implement `Iterator`: arrays, `StringScanner`, hashes
<FromGitter> <ilanpillemer> well I tried this
<FromGitter> <ilanpillemer> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5db20a897477946badc3ff14]
<FromGitter> <ilanpillemer> I would do more logic
<FromGitter> <ilanpillemer> but for testing purposes lets just say I pass through without any application of logic
<hightower4> Hey wouldn't it make sense that code like "n.to_s if n=10" be valid syntax? Right now it's not: https://play.crystal-lang.org/#/r/7vuq
<FromGitter> <ilanpillemer> `n==10` or `n=10`?
<hightower4> assignment, n=10
<hightower4> so it could be used in things like obj.do_something if obj=@obj, and various other uses...
<FromGitter> <asterite> actually, I got confused, you can have Iterator as a instance variable
<FromGitter> <tenebrousedge> use `try` for that, hightower
<FromGitter> <asterite> Also using getter with block: https://play.crystal-lang.org/#/r/7vux
<hightower4> tenebrousedge how do you mean?
<hightower4> ah without local var, ok
<FromGitter> <tenebrousedge> `@obj.try do |o|`
<FromGitter> <ilanpillemer> why do you need to wrap it`iter = (@iter ||= [1, 2, 3].each_combination(2))`
<FromGitter> <tenebrousedge> I don't think you do
<FromGitter> <kinxer> @hightower4 https://play.crystal-lang.org/#/r/7vv4
<FromGitter> <tenebrousedge> @ilanpillemer https://play.crystal-lang.org/#/r/7vv5
<FromGitter> <ilanpillemer> if you dont you get this error
<FromGitter> <tenebrousedge> @kinxer that works if the var has been declared already. They wanted something slightly different
<FromGitter> <ilanpillemer> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5db20c4f2f8a034357cf51c9]
<FromGitter> <ilanpillemer> but if you wrap it, you dont
<FromGitter> <ilanpillemer> Why?
<FromGitter> <tenebrousedge> @ilanpillemer you saw my example?
<FromGitter> <asterite> because the type of `@iter` is nilable
<FromGitter> <tenebrousedge> ^
<FromGitter> <asterite> the compiler will only filter the types of local variables, like when you do `||=`, `is_a?`, etc., but never for anything else (like instance variables)
<FromGitter> <kinxer> @tenebrousedge Fair point.
<hightower4> kinxer right, right, I wanted to initialize in the same line
<FromGitter> <asterite> but also, I'm almost sure you can initializer `@iter` in a constructor, which would make it non-nilable. But I don't know because I don't know what's the entire code
<FromGitter> <ilanpillemer> @tenebrousedge your example still wraps.. just without showing the temp
<FromGitter> <kinxer> Yeah, I get that now. I think you're wrong to want to, though. :P
<FromGitter> <ilanpillemer> yeah.. I cant init it
<FromGitter> <ilanpillemer> that explains it
<FromGitter> <ilanpillemer> It has to be nillable, but it mustnt be nil when I use it
<FromGitter> <ilanpillemer> so the ||= filters it
<FromGitter> <tenebrousedge> yes
<FromGitter> <ilanpillemer> I think I understand
<FromGitter> <ilanpillemer> Crystal is a large language
<FromGitter> <tenebrousedge> it doesn't have to be `nil`able
<FromGitter> <tenebrousedge> https://play.crystal-lang.org/#/r/7vv3
<FromGitter> <tenebrousedge> it just is nilable if you don't initialize it in `initialize`
<FromGitter> <tenebrousedge> or in a block
<FromGitter> <ilanpillemer> what does it get initialised to in your example?
<FromGitter> <tenebrousedge> the iterator
<FromGitter> <ilanpillemer> yes, the iterator
<FromGitter> <ilanpillemer> so an iterator poitning at nothing?
<FromGitter> <ilanpillemer> what does an iterator that is not yet have something to iterator point at?
<FromGitter> <tenebrousedge> in the link I posted, it's `[1,2,3].each_combination(2)`
<FromGitter> <ilanpillemer> Oh right.. you do init it
<FromGitter> <ilanpillemer> yeah.. if you cant it init it in the construcotr
<FromGitter> <tenebrousedge> then you have to wrap
<FromGitter> <tenebrousedge> or use a block
<FromGitter> <ilanpillemer> well that provides a default lazy init?
<FromGitter> <tenebrousedge> yes
<FromGitter> <ilanpillemer> I have used that for Hash
<FromGitter> <ilanpillemer> to give default values for kets
<FromGitter> <tenebrousedge> hash has that built-in
<FromGitter> <ilanpillemer> with the `.new`
<FromGitter> <tenebrousedge> yes
<FromGitter> <ilanpillemer> yes, thats what I used
<FromGitter> <ilanpillemer> but I assume getter is similar
<FromGitter> <tenebrousedge> yes
<FromGitter> <tenebrousedge> except it doesn't receive an argument
duane has quit [Ping timeout: 240 seconds]
ht__ has quit [Quit: ht__]
HumanG33k has joined #crystal-lang
HumanG33k has quit [Remote host closed the connection]
HumanG33k has joined #crystal-lang
<FromGitter> <didactic-drunk> Would anyone like `Mutex` and `Spinlock` to use the same duck type API? Proposed API `.lock`, `.lock { }`, `.unlock`, `.unlock { }`.
alexherbo20 has joined #crystal-lang
alexherbo2 has quit [Ping timeout: 268 seconds]
alexherbo20 has quit [Quit: The Lounge - https://thelounge.chat]
alexherbo2 has joined #crystal-lang
alexherbo28 has joined #crystal-lang
alexherbo2 has quit [Ping timeout: 268 seconds]
alexherbo28 has quit [Quit: Ping timeout (120 seconds)]
alexherbo28 has joined #crystal-lang
alexherbo28 has quit [Quit: Ping timeout (120 seconds)]
alexherbo28 has joined #crystal-lang
dwdv has quit [Ping timeout: 252 seconds]
<hightower4> Blacksmoke16 hehe I tried that `record AnyEvent, event_type : Event.class, event : Event`, and I got an error that it's a cyclic dependency where size can't be calculated, and that class should be used :)
<FromGitter> <Blacksmoke16> could use class, prob wont make a big diff
<hightower4> yes but classes can't inherit from structs and vice-versa, so Handler would need to be branched into HandlerStruct and HandlerClass
<hightower4> sorry rather Event I mean
<FromGitter> <Blacksmoke16> no i mean just make everything a class
<FromGitter> <Blacksmoke16> or could use a module
<FromGitter> <Blacksmoke16> to get the same common parent type as the abstract struct does
duane has joined #crystal-lang
alexherbo28 has quit [Quit: The Lounge - https://thelounge.chat]
alexherbo2 has joined #crystal-lang
<FromGitter> <ImAHopelessDev_gitlab> > just make everything a class ⏎ ⏎ story of my life right there
<FromGitter> <tenebrousedge> it's a thing. Crystal is a bit more OO than Ruby
<FromGitter> <tenebrousedge> seems to be an odd side effect of the type system
duane has quit [Ping timeout: 240 seconds]