<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>
<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> 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
<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> 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>
<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
<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>
<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` :/
<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> 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> 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> 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 { }`.
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