<FromGitter>
<tenebrousedge> @Blacksmoke16 it sounds like you're heading down a microservice path
<FromGitter>
<Blacksmoke16> not necessarily
<FromGitter>
<Blacksmoke16> basing how id like it to work on the php framework we use at work, but there each request has its own process i guess so its a bit easier versus having the main program run then requests get handled in fibers, so prob just have to take a diff approach?
snsei has quit [Ping timeout: 276 seconds]
<FromGitter>
<Blacksmoke16> coming from a non ruby background maybe there is a more ruby way to handle this
<FromGitter>
<Blacksmoke16> what im used to is having framework DI magic just inject the stuff for me, so like for each request i get a unique instance of the email client
<FromGitter>
<Blacksmoke16> main benefit ofc is it makes stuff rely on interfaces, makes it easier to test, and allows sharing state between types on a per request basis
<FromGitter>
<tenebrousedge> so why not just `def initialize(@ec = EmailClient.new)` ?
<FromGitter>
<Blacksmoke16> main reason the email client has dependencies of its own
<FromGitter>
<Blacksmoke16> which would have to be updated everywhere its being used
<FromGitter>
<tenebrousedge> and you can't do similarly with those dependencies?
<FromGitter>
<Blacksmoke16> i mean you could
<FromGitter>
<tenebrousedge> and I generally would, even if it meant a ten-line initialize method signature
<FromGitter>
<Blacksmoke16> duplicated everywhere you need it
<FromGitter>
<tenebrousedge> well but that's the point of the default value, right? and if it needs to be a singleton, you can have a global method for that
<FromGitter>
<Blacksmoke16> probably?
<FromGitter>
<Blacksmoke16> even just some factory `@ec = Factory.get_email_client`
<FromGitter>
<tenebrousedge> exactly
<FromGitter>
<Blacksmoke16> hmm
<FromGitter>
<Blacksmoke16> i duno, just doesnt feel the same
<FromGitter>
<Blacksmoke16> like if the factory is global how would you inject the same instance into two separate classes
<FromGitter>
<Blacksmoke16> where the instances should be based on the request, i.e. each request should have unique instances but each instance within each request should be the same
<FromGitter>
<tenebrousedge> the "factory" would use something equivalent to `@var ||= request.foo`
<FromGitter>
<tenebrousedge> a singleton by any other name
<FromGitter>
<Blacksmoke16> like i know some crystal frameworks store the current user on `HTTP::Server::Context`
<FromGitter>
<tenebrousedge> but when you talk about requests like that it makes me think of a closure over the request
sagax has joined #crystal-lang
<FromGitter>
<Blacksmoke16> but then there isnt a way to have access to that outside of like middleware or the controller
<FromGitter>
<tenebrousedge> uh, that's how Rails does things, at least with `current_user`
<FromGitter>
<Blacksmoke16> right but back to the say `EmailClient` how would you get access to the current user from in there?
<FromGitter>
<Blacksmoke16> would have to pass it in as an arg or something from where its used?
<FromGitter>
<Blacksmoke16> assuming its used in a controller or something?
<FromGitter>
<tenebrousedge> yes, the controller would pass any vars to the client
<FromGitter>
<Blacksmoke16> yea thats quite diff than how im used to things
<FromGitter>
<tenebrousedge> I mean, in Rails I think it would be more like `EmailClient.new.render('template', hash_of_vars)`
<FromGitter>
<tenebrousedge> I was looking at it two days ago but I forget the exact API
<FromGitter>
<Blacksmoke16> yea idk that just seems like a good way to do things imo
<FromGitter>
<Blacksmoke16> the factory approach is better but just newing up classes adhoc is bad imo
<FromGitter>
<Blacksmoke16> depending on what the class is ofc
<FromGitter>
<tenebrousedge> ah, well, to be honest I think it's actually more along the lines of `EmailClient.render('template', hash_of_vars).send`
<FromGitter>
<Blacksmoke16> is how i currently handle the current user stuff
<FromGitter>
<Blacksmoke16> now i just wish there was a nice mock shard out there, `user_storage.should_recieve('user').once`
<FromGitter>
<tenebrousedge> that would have to be a macro, wouldn't it?
<FromGitter>
<tenebrousedge> Rails tends to (not always, it's not actually part of the framework) define a `current_user` method, which is variously defined
<FromGitter>
<tenebrousedge> it's very often defined on `AppController`, which every other controller inherits from
<FromGitter>
<Blacksmoke16> i would assume yea, it would have to define a class that inherits from the mocked type
<FromGitter>
<Blacksmoke16> so it would be compatible with type restrictions of it
<FromGitter>
<tenebrousedge> hmm, I was thinking just to tell whether x was called
<FromGitter>
<tenebrousedge> and wouldn't you want to define that on `Object` ?
<FromGitter>
<tenebrousedge> thinking about mock implementations is too much for my brain this late at night
<FromGitter>
<Blacksmoke16> xD, ikr?
<FromGitter>
<Blacksmoke16> well you'd only want to know that on things you mock
<FromGitter>
<Blacksmoke16> also the mock macro should probably define some random string at the end so you can mock the same class more than one, which would represent diff "instances" of that mock
<FromGitter>
<Blacksmoke16> which im not sure how you would generate a random value in a macro
<FromGitter>
<Blacksmoke16> er at least a "unique" value
<FromGitter>
<tenebrousedge> do objects have an object id?
<FromGitter>
<Blacksmoke16> yea but idk if you have access to that in macro land?
ur5us__ has joined #crystal-lang
* FromGitter
* tenebrousedge yawns
<FromGitter>
<tenebrousedge> this is a tomorrow problem
<FromGitter>
<christopherzimmerman> Am I doing something wrong in this macro: ⏎ ⏎ ```code paste, see link``` ⏎ ⏎ It's complaining about the type of `aptr` and `bptr` when I pass them to the function, even though they should be cast at that point. [https://gitter.im/crystal-lang/crystal?at=5dd7f8f6afacdc4de455ed63]
<FromGitter>
<Blacksmoke16> where does `dtype` come from?
<FromGitter>
<Blacksmoke16> try like `dtype.id == Complex.id`
<FromGitter>
<Blacksmoke16> or maybe `dtype.resolve == Complex`
<FromGitter>
<christopherzimmerman> `.id` worked, is there a reason to use resolve instead?
<FromGitter>
<Blacksmoke16> comparisons in macros can be tricky as the underlying types may be diff in diff cases
<FromGitter>
<Blacksmoke16> i usually just do like `dtype.stringify == "Complex"` :P
andrzejku has quit [Ping timeout: 276 seconds]
devil_tux has joined #crystal-lang
<FromGitter>
<asterite> you can also do `puts dtype.class_name` and `puts Complex.class_name` in the macros, and you'll see that one is `Path` and the other is `TypeNode`. That's why they are not the same
return0__ has quit [Read error: Connection reset by peer]
return0e has joined #crystal-lang
duane has joined #crystal-lang
snsei has joined #crystal-lang
snsei has quit [Remote host closed the connection]
snsei has joined #crystal-lang
snsei has quit [Remote host closed the connection]
snsei has joined #crystal-lang
snsei has quit [Remote host closed the connection]
snsei has joined #crystal-lang
snsei has quit [Remote host closed the connection]
snsei has joined #crystal-lang
snsei has quit [Remote host closed the connection]
snsei has joined #crystal-lang
snsei has quit [Remote host closed the connection]
snsei has joined #crystal-lang
snsei has quit [Remote host closed the connection]
snsei has joined #crystal-lang
snsei has quit [Remote host closed the connection]
snsei has joined #crystal-lang
return0e has quit [Read error: Connection reset by peer]
snsei has quit [Remote host closed the connection]
snsei has joined #crystal-lang
return0e has joined #crystal-lang
snsei has quit [Remote host closed the connection]
snsei has joined #crystal-lang
snsei has quit [Remote host closed the connection]
snsei has joined #crystal-lang
snsei has quit [Remote host closed the connection]
snsei has joined #crystal-lang
snsei has quit [Remote host closed the connection]
OvermindDL1 has quit [Quit: Connection closed for inactivity]
<FromGitter>
<ImAHopelessDev_gitlab> what does B.qr do
<FromGitter>
<christopherzimmerman> QR Decomposition
<Yxhuvud>
qr factorizes the matrix into two triangular matrices, IIRC. (but it was roghly forever since I read the theory so I might misremember. Perhaps only one of them is triangular?
<Yxhuvud>
Yup, only one is triangular. The other is a orthonoral base.
<FromGitter>
<christopherzimmerman> Orthagonal and Upper
<FromGitter>
<christopherzimmerman> I don't implement the algorithm myself, I'm more concerned with why I am 5x faster than numpy until that size matrix, and hundreds of times slower afterwards :(
<FromGitter>
<christopherzimmerman> Pretty sure it's a caching issue.
<Yxhuvud>
or they use a different method to compute it?
<Yxhuvud>
weird. Doesn't look like the easiest code to grok.
teardown has quit [Ping timeout: 240 seconds]
<FromGitter>
<christopherzimmerman> So the answer is that I'm a moron. LaPACK lets you specify the worksize that you need, and I was giving it just random data: ⏎ ⏎ ```code paste, see link``` ⏎ ⏎ Now I'm waaay faster than numpy even for the large sizes. [https://gitter.im/crystal-lang/crystal?at=5dd82110c4fca14de3cf1670]
<FromGitter>
<tenebrousedge> which is what you're trying to do
<FromGitter>
<tenebrousedge> so I'll amend what I said, it's not that structs don't act like namespaces, but the short syntax implies that both of those things are modules or classes
<Yxhuvud>
manveru: you might want to file an issue though - it clearly tells you it is a bug after all.
<bougyman>
ugh that giter scroll
<FromGitter>
<tenebrousedge> it's not clearly a bug
<Yxhuvud>
His stacktrace clearly says it is a bug in the compiler. What the behaviour should be is a different question, but *that* is not it.
<FromGitter>
<tenebrousedge> the stacktrace often says that
<Yxhuvud>
Doesn't mean it is not a bug. Bleh, I wish I knew enough about the compiler internals to look into it.
<FromGitter>
<tenebrousedge> this behavior should be a bug. The code is not in any sense correct. The only reasonable behavior change would be a more informative error message
<Yxhuvud>
In a compiler, not giving a good and precise error message *is* a bug.
<FromGitter>
<Blacksmoke16> &
<FromGitter>
<Blacksmoke16> ^*
<FromGitter>
<tenebrousedge> if that's possible, sure
<FromGitter>
<watzon> It is. If the stack trace says there's a bug, there's a bug. The goal is to have it never say that.
<hightower2>
How can I call some ioctl from crystal?
<FromGitter>
<Blacksmoke16> normally errors like that means its falling to the default method that has it, versus being handled
<FromGitter>
<Blacksmoke16> at least thats how i noticed it worked with other errors
<FromGitter>
<christopherzimmerman> Has anyone here tried out the Github Actions for CI with crystal yet?
<FromGitter>
<tenebrousedge> IMO the short syntax is the problem
<FromGitter>
<Blacksmoke16> the deploy has a new version i need to migrate to i think
<FromGitter>
<tenebrousedge> the error is clear if you don't use that, and I suspect the source of other errors
<FromGitter>
<christopherzimmerman> I feel like I'm missing some obvious, but is there a way to override left side operators? So I can override `mytype + 1`, but is there a way I can have `1 + mytype` work too?
<FromGitter>
<tenebrousedge> you can override `Int32#+`
<FromGitter>
<kinxer> Yeah, that would work, and I think it would be reasonable for a data processing library to do stuff like that.
<FromGitter>
<asterite> So the problem with `Bytes` is that it's `Slice(UInt8)`, so doing `module Bytes::Foo` is like doing `module Slice(UInt8)::Foo`, so like trying to define a type inside a generic instantiation, which isn't possible, but I didn't expect it to be possible (hence the crash)
alexherbo2 has quit [Ping timeout: 240 seconds]
snsei has joined #crystal-lang
<FromGitter>
<Blacksmoke16> thoughts on my event dispatcher setup? ⏎ ⏎ Will be two initializers, one argless one that will auto register listeners at compile time based on annotated methods (useable by most applications). The other initializer will accept an array of `Listener` instances that will register based on a class method `get_subscribed_events` that returns an array of `Event.class` that that type should listen on;
<FromGitter>
... this style requires the listener methods to be `#call` that is overloaded to listen on multiple events
<FromGitter>
<Blacksmoke16> the latter initializer would be mainly used if you want to set it up manually or rely upon DI
snsei has quit [Ping timeout: 265 seconds]
<FromGitter>
<Blacksmoke16> maybe use `#call` for both on second thought, to simplify things
<FromGitter>
<Blacksmoke16> i also wish you could have reusable function in macro land