<straight-shoota>
sure, if you want to use it, just make `def xit; pending { yield }; end`
<raz>
ha, i might actually do that :D
<hightower3>
:)
<FromGitter>
<asterite> oprypin: nice. Elm docs also work like that I wouldn't mind making the doc tool work like that, to be honest, in contrast to having a separate tool. I did it that way because I didn't know Elm by then (nor how Python did it either).
woodruffw has quit [Ping timeout: 272 seconds]
woodruffw has joined #crystal-lang
sagax has quit [Read error: Connection reset by peer]
<FromGitter>
<viraptor1:matrix.org> I'm a bit confused about openssl/hmac. It looks like it doesn't take Bytes as the key because it runs `key_slice = key.to_slice` and I get undefined to_slice for Array(UInt8). But in that case... How do you even pass a binary blob to it?
<FromGitter>
<viraptor1:matrix.org> Grrr... Keep forgetting String.bytes doesn't return Bytes. I just need to encode / to_slice my data.
_whitelogger has joined #crystal-lang
<FromGitter>
<cuteghost> Hi everyone. Does anyone know is there any way to connect to the SMTP server to read received emails via Crystal lang?
<FromGitter>
<cuteghost> I found only one link related to that and the only answer was "no"
_whitelogger has joined #crystal-lang
<FromGitter>
<viraptor1:matrix.org> No, but not because of the language. SMTP is only for sending emails. For receiving you want IMAP / Exchange / POP3 / JMAP
_ht has joined #crystal-lang
hightower4 has joined #crystal-lang
<hightower4>
Hm if inside `lib` I have `union X; i : Int32, p : UInt8*; end `, and then a function which accepts argument of X[10], how do I actually create that argument?
<hightower4>
Hm I got it with one = X.new; ten = StaticArray(X, 10).new(one).. then call function with 'ten' as argument in that place
<hightower4>
Here's what I have so far, with question marked with TODO: https://carc.in/#/r/a555
<hightower4>
got it, needed to assign value.. ten[i] = X::Var.new; ten[i].i = some_int, or ten[i].p = some_string
<hightower4>
thanks for the discussion ;-)
_whitelogger has joined #crystal-lang
<FromGitter>
<bew:matrix.org> Can't you do X::Var.new i: some_int ?
<FromGitter>
<bew:matrix.org> hightower4
<hightower4>
bew: yes, yes, but the Vars are already initialized, so I just need to set their .i= or .p=
<FromGitter>
<bew:matrix.org> Ah yes, you're doing the static vars for terminfo run I'm guessing?
<hightower4>
Yes, got it working :) (Based on your code which already had the lib/fun definition, I just made the format/run be exported to crystal code)
<FromGitter>
<bew:matrix.org> Cool (;
<raz>
athena + clear = ♥️
<raz>
it all clicks together
<hightower4>
crystal + any = ♥️
<raz>
+1
<straight-shoota>
today is funny hash failure finding day =)
<straight-shoota>
this is fun: `raise "non-matching hash #{actual_value.class} #{@expected_value.class}" if actual_value.hash != @expected_value.hash` in EqualExpectation
MasterdonX has quit [Remote host closed the connection]
<yxhuvud>
I got some nice progress on my nested scheduler, and is now getting a passed test for io_uring context 1/5 times, and a BUG the other times.,
<FromGitter>
<jrei:matrix.org> hum not merge, concat
<FromGitter>
<jrei:matrix.org> sure oprypin it is similar for this simple use case. ⏎ If we have to concat, say 5 slices, it won't be the same story :/
<FromGitter>
<jrei:matrix.org> Hopefully, the case of hightower4 is simple, so I agree that's similar
ua_ has quit [Ping timeout: 260 seconds]
<FromGitter>
<tenebrousedge> how do I make `Foo{arg1, arg2}` give me a new `Foo` object?
<FromGitter>
<Blacksmoke16> > This literal can be used with any type as long as it has an argless constructor and responds to []=.
<FromGitter>
<tenebrousedge> where the meow is that documented?
<FromGitter>
<tenebrousedge> I mean I'm not one to overestimate the compiler's inference abilities. Does it work to initialize the var in like a `getter` block ?
<FromGitter>
<naqvis> nope, its same
<FromGitter>
<naqvis> i changed to `ivar` instead of `getter` to avoid cluttered message
<FromGitter>
<asterite> Ali: not a bug. When you pass self in initialize the object isn't yet initialized. What if that method where you pass self accessed bar? Boom!
<FromGitter>
<Daniel-Worrall> Is there a stdlib way to merge an Array of Ranges as much as possible?
<FromGitter>
<asterite> what is merging a range? (that's the answer :-))
<FromGitter>
<Daniel-Worrall> the minimal amount of ranges that cover the same values
<FromGitter>
<Daniel-Worrall> 1) .5, 3..6 => 1..6
<FromGitter>
<Daniel-Worrall> is what I meant
<FromGitter>
<Daniel-Worrall> I'll just attempt a coding of such thing
<FromGitter>
<Daniel-Worrall> but I fear it'll be recursive
<oprypin>
Daniel-Worrall, there is no such functionality. it is actually a challenging algorithmic problem
<FromGitter>
<Daniel-Worrall> Interesting
<Andriamanitra>
i've seen it on leetcode or similar sites at least 3 times
<oprypin>
oh i remember now. i must have solved it myself at least once
<oprypin>
u just sort all start and end points
<FromGitter>
<Daniel-Worrall> I was just gonna sort the start and iterate on it
<oprypin>
you need `[{1,:start},{5,:stop},{3,:start},{6,:stop}].sort!`
_ht has quit [Remote host closed the connection]
<oprypin>
iterate over them, doing +1 or -1 on a counter each time. every time it changes from 0 to non0 you start a range, and when it changes from non0 to 0 you end it
<FromGitter>
<Blacksmoke16> i still dont see what thats checking tho
<FromGitter>
<Blacksmoke16> like its never going to be false so always would print that no?
<FromGitter>
<erdnaxeli:cervoi.se> @Daniel-Worrall: ahah it works but I prefer as well do a simple if
<FromGitter>
<erdnaxeli:cervoi.se> @Blacksmoke16: the check was with a flag enum and another condition: `case var when .enumvar.value? && somethingelseistrue`
<FromGitter>
<Daniel-Worrall> Yeah, I didn't know what exact methods you wanted so I just put the nonesense of the example
<FromGitter>
<Blacksmoke16> can you make an example with that setup?
<FromGitter>
<erdnaxeli:cervoi.se> I was just using the case as a sortcut to write an if / elsif, that's not a big deal
<FromGitter>
<Blacksmoke16> ok, because using `&&` in it is deff not going to work
<FromGitter>
<erdnaxeli:cervoi.se> yeah I realized
straight-shoota has quit [Ping timeout: 272 seconds]
asterite has quit [Ping timeout: 260 seconds]
jhass has quit [Ping timeout: 272 seconds]
<FromGitter>
<christopherzimmerman> Is there a way to get a generic type's generic type? So something like the following: ⏎ ⏎ ```code paste, see link``` ⏎ ⏎ If anyone is familiar with Nim I'm looking for the equivalent of `T` and then `TT` [https://gitter.im/crystal-lang/crystal?at=5fdfd4a8dbb17f28c58e0258]
<FromGitter>
<HertzDevil> `{{ T.type_vars }}`, assuming they are public
<FromGitter>
<HertzDevil> in this specific case you can also do `typeof(c.first.first)` or
<FromGitter>
<christopherzimmerman> Yea the second would be nice if I knew what the inner type was, but it could be any generic in my case, not just array, and can't do `T(V)` for example. Might have to do some macro magic.
<FromGitter>
<HertzDevil> at the minimum you have to ensure the inner type isn't a union
straight-shoota has joined #crystal-lang
<FromGitter>
<christopherzimmerman> Luckily that will never happen, the inner type should only be a single numeric type, but that makes me wonder if there is a way to enforce that at compile time, is there a way to make sure a generic isn't a union?
<FromGitter>
<christopherzimmerman> Right now I just check explicitly against all numeric types
<FromGitter>
<HertzDevil> you can't *overload* based on the number of union types but that's probably immaterial to this example
<FromGitter>
<HertzDevil> i'd argue returning a type in a def and not immediately doing anything with it is not very helpful
<FromGitter>
<christopherzimmerman> The actual use case is being able to create scalar values based on the type of a generic's inner type. So if I pass a `Num::Grad::Context(Tensor(Float32))`, I need to be able to create Float32's to pass around to C libraries. But unfortunately, it can be a context of Tensors, ClTensors, or CudaTensors so I can't nest the generics as far as I want.
<FromGitter>
<christopherzimmerman> Might be worth a PR to the lang itself, it's a super convenient feature in Nim, I use it all the time.
<FromGitter>
<HertzDevil> why would you want to match an unrestricted generic here
straight-shoota has left #crystal-lang ["Leaving"]
<FromGitter>
<HertzDevil> i don't see what prevents you from just doing `def generic_child(c : Num::Grad::Context(Tensor(T))) forall T` and `def generic_child(c : Num::Grad::Context(CudaTensors(T))) forall T` and so on
<FromGitter>
<HertzDevil> and again, it's unlikely you want the type alone, and when there's more context `typeof` can also extract inner types without the private type issue
<FromGitter>
<christopherzimmerman> Nothing stopping me from doing it, but when I have hundreds of functions that would be `N` identical copies for each storage backend, with the only difference being the signature, trying to find a way to avoid it.
<oprypin>
christopherzimmerman, note that if i have `arr = Array(Int32).new`, i can use `typeof(arr.first) == Int32`
<FromGitter>
<HertzDevil> if you have hundreds of functions, instantiatng the same def with hundreds of free vars isn't much different from creating hundreds of defs
<FromGitter>
<HertzDevil> is there a reason you can't use typeof
<FromGitter>
<asterite> erdnaxeli: it's a bug, please report it. Thank you!
<FromGitter>
<erdnaxeli:cervoi.se> oh ok, will do!