<hightower2>
Still perplexed by the ->(){}, not sure why in Proc(Event,Nil).new the return value would be ignored, but in ->(){} wouldn't.
<hightower2>
or rather,
<hightower2>
why when passing a block defined as Event -> Nil it is ignored regardless of what the block exits with and it matches the overload, while when passing a ->(){} for a Proc it isn't
<hightower2>
yes that's not the problem, or rather that's exactly what I wanted to show
<FromGitter>
<Blacksmoke16> so in reality the return value of the proc is `Int32` implicitly
<hightower2>
no no, yes
<hightower2>
I mean to show that the first two variants, which don't return Nil (they return what p returns), do get their return value ignored and replaced with Nil
<hightower2>
whereas the third example does not, it remains being inferred as Proc(Int32,Int32), and fails to match the on() overload
<FromGitter>
<Blacksmoke16> well the first one is explicitly setting its return type to `Nil` in the proc type def
<FromGitter>
<Blacksmoke16> the second is returning nil so its return type is inferred to be `Nil`
<FromGitter>
<Blacksmoke16> not sure i see the issue?
<hightower2>
Well, yes, right, I meant to show the difference between the third example and the behavior of a block
<hightower2>
Case 3 and 4 are comparable, that's what I wanted to show originally
<hightower2>
both don't return a nil, but block version works, while the ->(){} one doesn't
<FromGitter>
<Blacksmoke16> heres what i think is going on
<FromGitter>
<Blacksmoke16> first example explicitly setting its return type to Nil in the proc type def
<FromGitter>
<Blacksmoke16> second is returning nil so its return type is inferred to be Nil
<FromGitter>
<Blacksmoke16> third is using the block overload of `on` which explicitly says the return type is `Nil`, similar to the first one
<hightower2>
right
<FromGitter>
<Blacksmoke16> the fourth example is using the non block overload which requires the passed proc to have a return type of `Nil`, but it has a return type of `Int32` so it isnt compatible, thus errors saying there isnt an overload for the proc
<hightower2>
yes, but go back to the third example.. this block doesn't return a Nil, yet it does match the overload which says that Block is of type Int32 -> Nil
<hightower2>
Whereas that same situation, but with overload 1 and Proc, doesn't work
<FromGitter>
<Blacksmoke16> the `Nil` return type is defined in the type restriction of the block `&handler : Int32 -> Nil) ā `
<FromGitter>
<Blacksmoke16> which is similar to the first example
<hightower2>
Yes, agreed. Let me change the order of examples in that paste:
<FromGitter>
<Blacksmoke16> which doesn't happen for a proc unless you give it the return type
<hightower2>
yes, yes, agreed on all of that. But I mean, block does not return Nil, yet his return type is overriden by the overload which says that block is "Int32 -> Nil"
<hightower2>
Whereas when Proc doesn't return nil, its return type is not overriden by the overload which says Proc(Int32,Nil)
<hightower2>
So it looks like not blocks, but procs defined with ->(){} notation, will be the edge case where specifying "nil" at the end is required...
<FromGitter>
<Blacksmoke16> im 99% sure both wouldn't work if you used a return type other than Nil
<hightower2>
Sure, fully agree on that. We're talking about the behavior of Nil
<FromGitter>
<Blacksmoke16> maybe someone else can explain it better but im quite certain its just special behavior with declared `Nil` return type so that you don't have to add a new line with just `nil` on it
<FromGitter>
<Blacksmoke16> but im just not seeing the problem you're describing :/
<FromGitter>
<Blacksmoke16> > but procs defined with ->(){} notation, will be the edge case where specifying "nil" at the end is required... ā ā ah i think i see
<FromGitter>
<Blacksmoke16> the main difference there is the return type is specified to be `Nil` so its inferred from the body, which if you dont explicitly say it returns nil, it wont do the special nil case for you
<FromGitter>
<Blacksmoke16> isn't specified*
<FromGitter>
<Blacksmoke16> afaik there isnt anything you can do there
<hightower2>
Yeah, other than using Proc(Int32,Nil) { |num| p num }; that works, as well as creating an alias for Proc(Int32,Nil)...
<hightower2>
but still I am very puzzled by why it works with blocks and not with procs defined with ->(){}
<FromGitter>
<Blacksmoke16> because the former has an explicit return type while the latter is inferred
<hightower2>
Ok, will let what you said sink for a couple days, as right now I don't understand it
<FromGitter>
<Blacksmoke16> Another way to think of it be like two methods
<FromGitter>
<Blacksmoke16> One that has a return type of a specific type
<hightower2>
Where do you say is this specific return type? In the definition of the overload, or in the definition of the block/proc?
<FromGitter>
<Blacksmoke16> Like`def foo : Int32` vs `def foo`
<hightower2>
Right. In our case, the block type is: &handler : Int32 -> Nil, and Proc type is: Proc(Int32, Nil). Doesn't this make both of them have specific return type?
<FromGitter>
<Blacksmoke16> the latter proc type is just a restriction, while the block type restriction is more similar to a method return type like `foo : Nil`
<FromGitter>
<Blacksmoke16> proc type is just an argument type restriction*
<hightower2>
ah ok, ok all clear now... hence your comment that there's not much what can be done about it
<FromGitter>
<Blacksmoke16> could make a macro that defines the proc
<hightower2>
yes, yes, I do have Proc(Int32,Nil) option, and alias Handler = Proc(Int32,Nil), both of those work
<FromGitter>
<Blacksmoke16> š
<hightower2>
I was trying to get ->(){} to work without needing an explicit nil, but obviously no-go
<FromGitter>
<Blacksmoke16> yea
<FromGitter>
<Blacksmoke16> trying to figure out a bug i found
<FromGitter>
<lbarasti> Thanks @firejox, looking forward to 0.32!
alexherbo2 has joined #crystal-lang
DTZUZO has quit [Ping timeout: 250 seconds]
ur5us__ has joined #crystal-lang
DTZUZO has joined #crystal-lang
DTZUZO has quit [Ping timeout: 240 seconds]
snsei has joined #crystal-lang
ur5us__ has quit [Ping timeout: 245 seconds]
DTZUZO has joined #crystal-lang
<hightower2>
Can I detect whether a macro is called in the context of a class or at toplevel?
snsei has quit [Ping timeout: 240 seconds]
dwdv has joined #crystal-lang
<hightower2>
Can I create a method which keeps some variable outside of it in its scope? Kind of like a proc would do, but that it's created as a method with def, and not a proc
DTZUZO has quit [Ping timeout: 265 seconds]
DTZUZO has joined #crystal-lang
DTZUZO has quit [Ping timeout: 252 seconds]
DTZUZO has joined #crystal-lang
DTZUZO has quit [Ping timeout: 245 seconds]
<hightower2>
Hey Blacksmoke16 , going through your article on creating JSON API with Athena. I see that you used a convention of Blog::Models and Blog::Controllers, which is great. However, why did you keep the "Controller" at the end instead of removing it? (Blog::Controllers::UserController <-- )
snsei has joined #crystal-lang
DTZUZO has joined #crystal-lang
<raz>
oh come on... seriously. does the awesomeness ever stop? every time i go looking for a small utility shard (this time: to humanize numbers) i learn that crystal has it baked right in.
DTZUZO has quit [Ping timeout: 245 seconds]
<hightower2>
Regarding my question above about recognizing whether macro is executing at top level, I'll try seeing what does @type say
<hightower2>
Blacksmoke16 that Athena + JSON API article and article on annotations are great. When I get back to some web-related development I'll be interested in pairing Athena with GraphQL
snsei has quit [Ping timeout: 252 seconds]
DTZUZO has joined #crystal-lang
<hightower2>
Hey where is the list of 3rd party Crystal shards which the manas/crystal team has in mind and verifies after every release?
<FromGitter>
<j8r> Do you guys knows any health metric I can expose from a Crystal app? Maybe some related to the GC?
<raz>
GC.stats is quite informative
<FromGitter>
<Blacksmoke16> @phangs that should be fixed now
<FromGitter>
<Blacksmoke16> hightower2: iirc you can make a macro protected?
<FromGitter>
<Blacksmoke16> > *<hightower2>* Hey Blacksmoke16 , going through your article on creating JSON API with Athena. I see that you used a convention of Blog::Models and Blog::Controllers, which is great. However, why did you keep the "Controller" at the end instead of removing it? (Blog::Controllers::UserController <-- ) ā ā Probably just a habit, but yea it's unnecessary because of the namespace
<FromGitter>
<Blacksmoke16> > *<hightower2>* Blacksmoke16 that Athena + JSON API article and article on annotations are great. When I get back to some web-related development I'll be interested in pairing Athena with GraphQL ā ā š sounds like a plan
<FromGitter>
<Blacksmoke16> but ofc that would be a runtime error
<raz>
how ruby'esque
* raz
wiggles his monocle in disgust
<FromGitter>
<Blacksmoke16> yea, so if you want a compile error it has to be an enum, or a unique type
<FromGitter>
<tenebrousedge> you could use a constant?
<FromGitter>
<Blacksmoke16> granted symbols are casted into enum members so you could do `:bar` vs `Option::Bar`
<FromGitter>
<tenebrousedge> that's a thing too
<FromGitter>
<tenebrousedge> dang, constants don't work either <__< Crystal, you are harshing my mellow
HumanG33k has joined #crystal-lang
HumanG33k has quit [Remote host closed the connection]
HumanG33k has joined #crystal-lang
Human_G33k has joined #crystal-lang
HumanG33k has quit [Ping timeout: 240 seconds]
snsei has quit [Ping timeout: 252 seconds]
dannyAAM has quit [Quit: znc.saru.moe : ZNC 1.6.2 - http://znc.in]
dannyAAM has joined #crystal-lang
f1reflyylmao has quit [Remote host closed the connection]
f1refly has joined #crystal-lang
ua has quit [Ping timeout: 240 seconds]
ua has joined #crystal-lang
snsei has joined #crystal-lang
ur5us__ has joined #crystal-lang
ur5us__ has quit [Remote host closed the connection]
ur5us__ has joined #crystal-lang
ur5us__ has quit [Read error: Connection reset by peer]
ur5us has joined #crystal-lang
snsei has quit [Ping timeout: 246 seconds]
<FromGitter>
<watzon> @christopherzimmerman I didn't really get anywhere with ndarrays. I implemented Matrices and Vectors based on Ruby's standard library implementations, but I didn't really need ndarrays for what I was working on.
<hightower2>
Hey, I have class Event, and its subclass Subevent. Type Proc(Subevent,Nil) is not accepted into a method defined as accepting Proc(Event, Nil).
<hightower2>
Remind me please, did we already discuss this and was the conclusion that otherwise it would work, but within Procs it doesn't?
<FromGitter>
<Blacksmoke16> would have to have a wrapping proc
<FromGitter>
<Blacksmoke16> ah i think that would work, but not sure about if you try to do the call
<hightower2>
indeed, doesn't work if .call is attempted
snsei has quit [Ping timeout: 240 seconds]
<hightower2>
actually let me get this example in shape
<hightower2>
https://play.crystal-lang.org/#/r/82er <-- I thought I had this case, but on play it works. I need to look more into the code to figure out what's different than this example
<hightower2>
(note that in this case I don't need to .call() the proc, so that's why I didn't try .call in the example)
<hightower2>
fg
<FromGitter>
<christopherzimmerman> @watzon not sure if you looked into it, but it might be worth adding an option in the makefile to compile SOD against opencv, which would allow us to integrate. Also, thoughts on supporting video streams in library itself?
<FromGitter>
<watzon> I'd be all for supporting video streams, I could see that being extremely useful. Anything that allows us to compete with some Python libraries out there
<FromGitter>
<watzon> Do you have a reference to docs talking about compiling against opencv?