<FromGitter>
<bew> what crystal version do you have installed?
<FromGitter>
<bew> I think you don't have a recent enough compiler
<FromGitter>
<redcodefinal> I'm compiling 0.27.0 and my installed crystal is 0.24.0
<FromGitter>
<bew> you should get crystal 0.26.1 to be able to compiler 0.27.0
<FromGitter>
<redcodefinal> So I should just find the highest crystal that I can compile, then use that to do the next one? interesting. Thank you!
<FromGitter>
<bew> yep
<FromGitter>
<bew> or if you have to start from 0.24.2, compile the next (0.25.0 I guess), then with that compile the next, etc...
<FromGitter>
<girng> gn
foxxx0 has joined #crystal-lang
<foxxx0>
hey, I'm having a problem understanding why an element of a newly created Tuple(Int32,Int32,Int32) is at first correctly an "Int32" and a bit later typeof(my_tuple[0]) returns "(Int32 | Int32.class)"
<RX14>
@anamba crystal will be less vulnerable in the same way that ruby doesn't have any documented attacks: less, larger dependencies, making auditing trust an order of magnitude easier
<FromGitter>
<asterite> @KevinSjoberg Yeah, `slice_when` or `slice_before` would have been helpful for advent of code (and generally useful). I might add them in these days
rohitpaulk has quit [Ping timeout: 246 seconds]
<FromGitter>
<bararchy> I remember there being a method that takes two `Int` and tells you the distance between them or something like that
<FromGitter>
<bararchy> basiclly to check if a number is further then x from another one (+ or -)
<FromGitter>
<anamba> @RX14 of course, the dependency situation for most platforms won't be as extreme as js/npm, but the idea is trust shouldn't be our only line of defense
<RX14>
unfortumnately sandboxing depndencies isnt possible in crystal
<FromGitter>
<vladfaust> Makes sense. This 3 nanoseconds win absolutely costs 8 additional lines of code
rohitpaulk has joined #crystal-lang
<FromGitter>
<greenbigfrog> 😛
rohitpaulk has quit [Ping timeout: 268 seconds]
jemc has joined #crystal-lang
<FromGitter>
<kinxer> @greenbigfrog In addition to what @vladfaust said (which is true; it's really not that much of a gain), you're basically equivalently trading runtime for memory. Your faster version takes ~3.27 times as much memory (unless I'm wrong about what that <number>M stands for).
<FromGitter>
<vladfaust> @kinxer, nope, @greenbigfrog's solution as well as mine takes exactly `0 B/op`
<FromGitter>
<vladfaust> `M` stands for millions of operations per second :)
<FromGitter>
<kinxer> Ah... So it's just the frequency.
<FromGitter>
<kinxer> Good to know, @vladfaust. Thanks.
<FromGitter>
<vlazar> Yeah, npm again... But the issue is not unique to npm. How do you guys freeze your dependencies? For Crystal 1.0 it would be great to have something more sophisticated than installing packages directly from GitHub.
<FromGitter>
<j8r> there is a shard.lock
<FromGitter>
<vlazar> how do I verify the code was not changed on github?
<FromGitter>
<j8r> because of the commit hash
<FromGitter>
<j8r> but the problem, even the lock don't always the commit hash
<FromGitter>
<vlazar> locking to commit hashes is not common practice?
<FromGitter>
<j8r> It think it should too
<FromGitter>
<j8r> I you specify a version, it will put a version in the lock (no hash)
<FromGitter>
<j8r> I you specify HEAD, it will
<FromGitter>
<j8r> too bad, agree
<FromGitter>
<vlazar> no, this is just something to be aware of for the time being
<FromGitter>
<j8r> But we can't review all the code of our dependencies
<FromGitter>
<vlazar> true
<FromGitter>
<vlazar> I guess for me a better dependency management is on wishlist for 1.0
<FromGitter>
<j8r> I still think the commit hash should be always in the lock
<FromGitter>
<bew> What do you suggest @vlazar?
<FromGitter>
<greenbigfrog> @vladfaust shouldn't this (the index of max, or max with index) be part of the stdlib?
<FromGitter>
<vlazar> @j8r oh, great if it is, makes me less nervous :D
<FromGitter>
<vlazar> bew, a registry for packages we could trust would be great I guess
<FromGitter>
<j8r> I'll create an issue
<FromGitter>
<vladfaust> @greenbigfrog who am I to decide
<FromGitter>
<greenbigfrog> true, but do you think it should?
<FromGitter>
<j8r> @vlazar today you can use libs from people you trust
<FromGitter>
<vladfaust> @greenbigfrog nope, I don't think so. Because `a.index(a.max)` is enough
<FromGitter>
<vlazar> @j8r ❤️
<FromGitter>
<asterite> get_index_of_max doesn't return what you want, it returns the max
<FromGitter>
<asterite> Ah, nevermind. The benchmark is flawed, the array has the same value in each position
gangstacat has quit [Quit: Ĝis!]
<FromGitter>
<DRVTiny> Hello4all! ⏎ What about integer overflow control in Crystal? It's a pitty that static types not leads anyway to safety against such stupid thing as overflow on addition.
<FromGitter>
<kinxer> @DRVTiny ⏎ ⏎ > In this version a couple of arithmetic operators were added thanks to #6890: &+, &-, &*. They will perform additions, subtraction and multiplication with wrapping (as in, not overflowing). Some may notice that that is the exact same behaviour as +, -, *. In a future version the regular operators will raise on overflow. This will allow you to trust the result of the operations when reaching
<FromGitter>
<asterite> @KevinSjoberg sorry, I do it in small chunks whenever I have time, I don't think I can pair program these days (probably these years :-p)
<FromGitter>
<KevinSjoberg> @asterite I see, no worries. :)
<FromGitter>
<vladfaust> @ilanusse CircleCI whould work with nightly well
<FromGitter>
<vladfaust> @greenbigfrog I think the issue is that at the moment of the bench start, the max element is in its place and is not changed during the whole bench
<FromGitter>
<vladfaust> But even if it is, it should be enough for comparison of these two in my opinion
<FromGitter>
<asterite> Yes, it's slower because index max needs to traverse the array twice
<FromGitter>
<greenbigfrog> Yeah
<FromGitter>
<greenbigfrog> I think would be nice to have sth like this in the stdlib
<FromGitter>
<asterite> It's too specific and the time difference isn't that big
<FromGitter>
<asterite> And you can still write specific code if you need it
<FromGitter>
<greenbigfrog> hm, ok
jemc has joined #crystal-lang
Renich has joined #crystal-lang
rohitpaulk has joined #crystal-lang
<FromGitter>
<wontruefree> is there a way to use compiler flags to cross compile to x86 from a 64 bit machine ?
junland has quit [Quit: Disconnected.]
rohitpaulk has quit [Ping timeout: 246 seconds]
junland has joined #crystal-lang
JuanMiguel has joined #crystal-lang
<FromGitter>
<j8r> You can, there is an option in `crystal build`
<FromGitter>
<ilanusse> Hey guys
<FromGitter>
<j8r> Don't remind exactly
<FromGitter>
<ilanusse> What features would you like in a Devise-like authentication shard?
<FromGitter>
<ilanusse> I was thinking confirmation emails, lockable accounts, recovery emails, session timeouts
<FromGitter>
<ilanusse> The plan is to eventually support both Amber and Lucky
<FromGitter>
<ilanusse> I'll have to make wildly different template generators but the core functionality would be the same
<FromGitter>
<DRVTiny> Does anybody knows some shard where i can get code snippets for event loop integration? ⏎ I know that stdlib IO integrated with ev, but it's code is too complex for me and i dont understand where IO pushes some procs or filehandles to be executed/checked by event loop on each iteration.
<FromGitter>
<diegogub_gitlab> Hi guys, I'm havinga issue. While executing shards build, libs are being fetched everytime, how could I solve it?
<FromGitter>
<Blacksmoke16> building locally or using docker or something?
<FromGitter>
<diegogub_gitlab> locally
<FromGitter>
<Blacksmoke16> hmm
non-aristotelian has joined #crystal-lang
<FromGitter>
<diegogub_gitlab> only happening with one project..tried to re-init shards, and keeps happening
<FromGitter>
<wontruefree> @j8r I see `--target` and `--cross-compile` but I dont see how to use them.
<FromGitter>
<asterite> @DRVTiny you are not supposed to interact with the event loop, that class (and all related code) should (will) be private
rohitpaulk has joined #crystal-lang
<FromGitter>
<jwoertink> I think I found a bug but I'm not totally sure. Wondering if someone could verify, or maybe explain this to me so I understand better.
<FromGitter>
<jwoertink> In this example if I iterate over my array with `each` it works fine; however, if I break it down with `in_groups_of`, then it seems to lose the type
<FromGitter>
<jwoertink> Maybe because `in_groups_of` could return a group with a `nil` in it?
<FromGitter>
<bew> @DRVTiny what's your use case? (for interacting with eventloop directly)
<FromGitter>
<jwoertink> actually, now that I type that out it's making a little more sense to me lol
<FromGitter>
<jwoertink> It's not returning my array, it's returning a new one with a new type
<FromGitter>
<jwoertink> 😅
<FromGitter>
<jwoertink> turns out there's a second `in_groups_of` that takes an additional argument
rohitpaulk has quit [Ping timeout: 268 seconds]
<FromGitter>
<asterite> you need to use `each_slice`
<FromGitter>
<jwoertink> Oh? Interesting. Good call
<FromGitter>
<elorest> What @asterite said! ☝️
<FromGitter>
<j8r> @RX14 I love your goblin-themed logo :D
<FromGitter>
<jwoertink> I wonder if there's a performance difference
<FromGitter>
<asterite> The docs should probably mention the other variant in each method :-)
<FromGitter>
<jwoertink> That could be a good idea
<FromGitter>
<girng> just curious why is `url: group[0].as(String)` needed when `url: String` sets `url` to a String already?
<FromGitter>
<Blacksmoke16> more so to tell that the first value in `group` array should be a `String`
<FromGitter>
<Blacksmoke16> assuming its a union
<FromGitter>
<DRVTiny> POSIX Semaphores has some /dev/shm file-based interface but i dont know whether this files can be used to create file handles for non-blocking I/O. And this is too indirect way to integrate with event loop because there is simple try_wait interface, so ev loop can simply call my proc/closure (which will do try_wait internally) and check its exit status.
<FromGitter>
<girng> interesting. what i do is just tryu to match the types up first and not rely on `as`. but if using an union i guess it makes since
<FromGitter>
<Blacksmoke16> got a playground link example?
<FromGitter>
<DRVTiny> @asterite Is it possible to pass some ->() from the current running myFiber to the event loop and yield (pass control to the evloop). Than EV Loop will check for the passed ->() return status on every iteration and when it will be true - myFiber will be added to some queue of Fibers which is "ready-to-continue-its-execution" .
<FromGitter>
<bew> @DRVTiny there not really a concept of iteration in the evloop, the only thing it does is wait for some fd, or some time.. One thing you could do without touching the eventloop directly would be to have Fiber thar waits in a loop, and check the semaphore each time (and do sth or not)
<FromGitter>
<greenbigfrog> How would I check if an object is a type that includes Enumerable?
<FromGitter>
<bew> `some_var.is_a?(Enumerable)`
<FromGitter>
<DRVTiny> I dont think that evloop must internally implement all possible variants of (potentially infinite) unblocking conditions for its Fibers. I can extend Crystal::EventLoop class itself (like any core class) , but i think this is too brutal/destrutive to achieve so simple and obvoius goal. ⏎ @bew Yes, i can iterate in a loop and do myFiber.yield if no success after sem.try_wait... Hmm. Some stupid way, but it
<FromGitter>
... works right now... OK, thank you, it there is not other ways to interact with evloop simple micro-loop inside a Fiber will be better than nothing :)
<FromGitter>
<bew> @asterite would probably know better^^ you cab also checkout the ConditionVariable implem', but I'm pretty sure it locks the whole thread, not just the current fiber
<FromGitter>
<asterite> I don't think it's a good idea to add stuff that relates to concurrency of any sort. It's better to wait for the core devs to work on that
<FromGitter>
<asterite> Also semaphore in Go is in an x package, probably it's not very useful so it won't exist in Crystal
<FromGitter>
<greenbigfrog> @bew thanks... Didn't realize it worked for included types (or whatever it's called)