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
alexherbo2 has quit [Ping timeout: 276 seconds]
ur5us has joined #crystal-lang
snsei has joined #crystal-lang
ur5us_ has joined #crystal-lang
ur5us has quit [Ping timeout: 250 seconds]
<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> like
<FromGitter> <Blacksmoke16> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5dd74a844517d002b2ce8441]
<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> <tenebrousedge> something something composition inheritance
<FromGitter> <Blacksmoke16> just seems sucky to have like ⏎ ⏎ ```some_dep = SomeDep.new 123 ⏎ other_dep = OtherDep.new some_dep, "foo", false``` [https://gitter.im/crystal-lang/crystal?at=5dd74f7cf3ea522f26463823]
<FromGitter> <Blacksmoke16> just seems sucky to have like ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5dd74f8bb010e6227649c7c8]
<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> fair
<FromGitter> <Blacksmoke16> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5dd75450afacdc4de4519acd]
<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> <Blacksmoke16> like ⏎ ⏎ `````` [https://gitter.im/crystal-lang/crystal?at=5dd755e289fce12f25a450ae]
<FromGitter> <Blacksmoke16> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5dd7560e55bbed7ade21a532]
<FromGitter> <Blacksmoke16> :shrug:
<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> <Blacksmoke16> hehe, o/
ur5us_ has quit [Ping timeout: 240 seconds]
<FromGitter> <Blacksmoke16> https://play.crystal-lang.org/#/r/820u i feel like this should work tho?
<FromGitter> <Blacksmoke16> er no its a macro so its doing `t = class ...`
<FromGitter> <Blacksmoke16> https://play.crystal-lang.org/#/r/820w there we go
f1reflyylmao has joined #crystal-lang
<FromGitter> <Blacksmoke16> https://play.crystal-lang.org/#/r/820y better
<FromGitter> <Blacksmoke16> anyway im off to bed o/
f1refly has quit [Ping timeout: 276 seconds]
ur5us_ has joined #crystal-lang
ur5us__ has quit [Ping timeout: 250 seconds]
ur5us__ has joined #crystal-lang
ur5us_ has quit [Ping timeout: 276 seconds]
snsei has joined #crystal-lang
ur5us__ has quit [Ping timeout: 245 seconds]
snsei has quit [Ping timeout: 240 seconds]
<FromGitter> <phangs> @Blacksmoke16 hello, checked it out last night, got a different error, still figuring it out
<FromGitter> <phangs> also did shards update
ht_ has joined #crystal-lang
<FromGitter> <phangs> problem is related to this https://github.com/crystal-lang/crystal/issues/7698
ht_ has quit [Quit: ht_]
andrzejku has joined #crystal-lang
<andrzejku> hello
sagax has quit [Ping timeout: 240 seconds]
<FromGitter> <lbarasti> Is Crystal Forum down? The connection times out for me
<andrzejku> Hey guys
hightower4 has quit [Ping timeout: 240 seconds]
sagax has joined #crystal-lang
hightower3 has joined #crystal-lang
<FromGitter> <vlazar> kind of down for me, Safari fails to load, Firefox seems to handle situation better
Flipez9 is now known as Flipez
return0__ has joined #crystal-lang
return0e has quit [Ping timeout: 240 seconds]
alexherbo2 has joined #crystal-lang
alexherbo2 has quit [Quit: The Lounge - https://thelounge.chat]
hightower2 has joined #crystal-lang
<hightower2> Hey just to confirm, Procs can't take splat arguments, right?
<FromGitter> <Blacksmoke16> @phangs whats the actual error in your latest comment?
dingenskirchen has joined #crystal-lang
<FromGitter> <christopherzimmerman> http://www.netlib.org/lapack/explore-html/d7/d76/zgemm_8f.html does anyone else get a 403 from this?
<FromGitter> <tenebrousedge> yes
duane has joined #crystal-lang
alexherbo2 has joined #crystal-lang
duane has quit [Ping timeout: 252 seconds]
<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> <christopherzimmerman> `macro linalg(dtype, prefix)`
<FromGitter> <Blacksmoke16> and how are you calling it?
<FromGitter> <christopherzimmerman> `linalg(Complex, z)`
<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]
ht_ has joined #crystal-lang
devil_tux has quit [Ping timeout: 240 seconds]
snsei has joined #crystal-lang
<FromGitter> <christopherzimmerman> So this is the lovely behavior I have to figure out today: ⏎ ⏎ ```code paste, see link``` ⏎ ⏎ Pretty sure thats the crossover for what the cache can hold. [https://gitter.im/crystal-lang/crystal?at=5dd815d5d2c92c2275d932a0]
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?
snsei has quit [Ping timeout: 276 seconds]
<FromGitter> <christopherzimmerman> I pretty much copied by implemention from theirs (https://github.com/numpy/numpy/blob/v1.17.0/numpy/linalg/linalg.py#L912). They use lapack's `*geqrf` into `*orgqr`.
<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> 👀
Human_G33k has joined #crystal-lang
<FromGitter> <christopherzimmerman> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5dd821324517d002b2d45ecf]
Human_G33k has quit [Remote host closed the connection]
Human_G33k has joined #crystal-lang
HumanG33k has quit [Ping timeout: 240 seconds]
jua_ has joined #crystal-lang
snsei has joined #crystal-lang
dannyAAM has quit [Quit: znc.saru.moe : ZNC 1.6.2 - http://znc.in]
dannyAAM has joined #crystal-lang
<FromGitter> <manveru> soo.. can anyone explain https://play.crystal-lang.org/#/r/8240 ?
manveru has left #crystal-lang [#crystal-lang]
<FromGitter> <tenebrousedge> `Bytes` is an existing struct
<FromGitter> <tenebrousedge> not a module
<FromGitter> <tenebrousedge> maybe you mean `Lucky::Bytes` ?
<FromGitter> <manveru> well, i'm trying to specify a module called `Lucky` on the `Bytes` type
snsei has quit [Ping timeout: 240 seconds]
<FromGitter> <tenebrousedge> structs don't act like namespaces
<FromGitter> <manveru> ok
<FromGitter> <manveru> but i can do this: https://play.crystal-lang.org/#/r/824o
<FromGitter> <tenebrousedge> but not this https://play.crystal-lang.org/#/r/824n
<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
<FromGitter> <Blacksmoke16> bytes is an alias tho
<FromGitter> <tenebrousedge> yes, an alias to `Slice(UInt8)`
<FromGitter> <tenebrousedge> which is a struct
<FromGitter> <Blacksmoke16> so essentially that should just be making an alias of an alias which should work
<FromGitter> <tenebrousedge> it does work, that's not the problem
<FromGitter> <Blacksmoke16> like ⏎ ⏎ ```alias Foo = String ⏎ alias Bar = Foo``` [https://gitter.im/crystal-lang/crystal?at=5dd82d349d72cd02b32788f2]
<FromGitter> <tenebrousedge> it's the short syntax that's the issue
<FromGitter> <tenebrousedge> `module Foo::Bar` doesn't work when `Foo` is a struct
<FromGitter> <Blacksmoke16> ahhh ok
<FromGitter> <tenebrousedge> it apparently expands to `module Foo; module Bar`, and `Foo` is not a module
<FromGitter> <tenebrousedge> (note the word "expands" is being used loosely)
<FromGitter> <manveru> so that's different from ruby :)
<hightower2> Here's another standalone shard created as part of Crysterm: https://github.com/crystallabs/tput
<FromGitter> <tenebrousedge> well, in Ruby a Struct is a class
<FromGitter> <tenebrousedge> in Crystal structs are values
OvermindDL1 has joined #crystal-lang
alexherbo2 has quit [Quit: The Lounge - https://thelounge.chat]
alexherbo2 has joined #crystal-lang
alexherbo2 is now known as alex```
duane has quit [Ping timeout: 265 seconds]
snsei has joined #crystal-lang
alex``` has quit [Quit: The Lounge - https://thelounge.chat]
ht_ has quit [Remote host closed the connection]
snsei has quit [Ping timeout: 250 seconds]
<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> @christopherzimmerman yes
<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.
<hightower2> Isn't this fabulous -- https://github.com/crystal-lang/crystal_lib
ur5us__ has joined #crystal-lang
<FromGitter> <christopherzimmerman> This macro look okay for override lots of dtypes? ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5dd85d7555bbed7ade2923cf]
<FromGitter> <christopherzimmerman> Seems to work for everything I've tested it with so far.
<FromGitter> <tenebrousedge> that looks like it works. Did you check out how `Int#+` is implemented, though?
<FromGitter> <tenebrousedge> because it doesn't seem like `dtypes` or `operators` are really necessary as arguments
<FromGitter> <watzon> Why not?
duane has joined #crystal-lang
<FromGitter> <watzon> Ahh yeah. You're right, those shouldn't be necessary
<FromGitter> <watzon> Unless he only wants to overload specific ones
alexherbo2 has joined #crystal-lang
<FromGitter> <kinxer> Yeah, I think it would actually work to define it on `::Number`.
ur5us__ has quit [Ping timeout: 246 seconds]
<raz> bruaha... went looking for an oauth2 shard... only to learn that crystal has baked it right in.
<FromGitter> <asterite> There you go: https://github.com/crystal-lang/crystal/issues/8512
<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