ChanServ changed the topic of #crystal-lang to: The Crystal programming language | https://crystal-lang.org | Fund Crystal's development: https://crystal-lang.org/sponsors | GH: https://github.com/crystal-lang/crystal | Docs: https://crystal-lang.org/docs | Gitter: https://gitter.im/crystal-lang/crystal
ur5us has quit [Ping timeout: 252 seconds]
ur5us has joined #crystal-lang
Vexatos_ has joined #crystal-lang
Stephie- has joined #crystal-lang
Vexatos has quit [Quit: Client Quit]
Stephie has quit [Quit: Fuck this shit, I'm out!]
<FromGitter> <mixflame> if anyone is into amber, can you please review pull request #1265 on amberframework/amber and tell me if you can spot any weaknesses? it's a multichannel redis adapter for websockets
<FromGitter> <Blacksmoke16> your link broke ^
<FromGitter> <didactic-drunk> I monkey patched `GC.malloc*` and it segfaults only with -Dpreview_mt when calling an empty function. https://github.com/didactic-drunk/fiber_stats.cr/pull/1#discussion_r665800802
notzmv has joined #crystal-lang
aquijoule__ has joined #crystal-lang
aquijoule_ has quit [Ping timeout: 246 seconds]
notzmv has quit [Ping timeout: 252 seconds]
postmodern has joined #crystal-lang
<postmodern> so what is the difference between .as(Int32) and .to_i32 ?
<FromGitter> <Blacksmoke16> the former just tells the compiler to treat the values as an int32 without actually doing the conversion
<FromGitter> <Blacksmoke16> i.e. pretty sure `.as` wouldn't handle over/underflows, so id deff use `.to_i32`, or really just `.to_i`
<FromGitter> <Blacksmoke16> *BUT*, `.as(Int32` can be useful if the type of your value is like `Int32 | Bool` and you want to tell the compiler "i know it'll be an Int32 in the case"
<postmodern> ah ha, i figured that might be the case for things like `UInt8 | Int32`
ur5us has quit [Ping timeout: 246 seconds]
notzmv has joined #crystal-lang
notzmv has quit [Ping timeout: 258 seconds]
lucf117 has quit [Remote host closed the connection]
sagax has quit [Excess Flood]
postmodern has quit [Quit: Leaving]
<yxhuvud> it can also be used for upcasting, like `x = [1.as(Int32|String)]`
<FromGitter> <rishavs> @lodenos , for a bigger aim, try gettiing #1 at https://www.techempower.com/benchmarks/#section=test&runid=76b9993b-3c68-4d6d-884c-fd01112e7b7a&hw=ph&test=composite&a=2 ⏎ The composite score is a much better representation of normal web load
<FromGitter> <lodenos> @rishavs Thx It’s a really good challenge
<straight-shoota> Crystal 1.0 Conference is now live =) Late birds can still join at https://www.eventbrite.com.ar/e/crystal-conference-10-launch-tickets-149153252393
<FromGitter> <rishavs> @lodenos do keep in mind that all the tests around db queries are also test of the quality of the db drivers. And the drivers of languages like go, rust etc are far ahead of us due to their larger community size. ⏎ One way to work around this can be to wrap existing db clients in crystal instead of using our own drivers but it has its own set of cons
<FromGitter> <lodenos> It’s always a balance btw Productivie, ez coding n Performance in run time
<FromGitter> <Blacksmoke16> > We should forget about small efficiencies, say about 97% of the time: premature optimization is the root of all evil. Yet we should not pass up our opportunities in that critical 3%.
<FromGitter> <lodenos> @Blacksmoke16 100% true
ur5us has joined #crystal-lang
deavmi has quit [Ping timeout: 246 seconds]
deavmi has joined #crystal-lang
terminalpusher has joined #crystal-lang
<terminalpusher> where is the livestream?
<terminalpusher> where can I see the livestream of the 1.0 conference? Doesn't it start right now? I can't find it anywhere at all
<FromGitter> <Blacksmoke16> did you buy a ticket?
<terminalpusher> no
<FromGitter> <Blacksmoke16> then there is no livestream :)
<terminalpusher> I thought it was going to be a YouTube livestream
<FromGitter> <Blacksmoke16> will have to wait for them to be released afterwards
<terminalpusher> or whatever video platform
<terminalpusher> alright
<terminalpusher> I'm really looking forward to watching it
<terminalpusher> have been following Crystal for years
<terminalpusher> it means a lot to me
deavmi has quit [Ping timeout: 255 seconds]
<FromGitter> <Blacksmoke16> good to hear
notzmv has joined #crystal-lang
deavmi has joined #crystal-lang
<FromGitter> <didactic-drunk> Is there a built in `Range` expection in `Spec`? Something like `a.should_be within range`? Or an approximate expectation for floats?
<FromGitter> <Blacksmoke16> https://crystal-lang.org/api/master/Spec/Expectations.html#be_close(expected,delta)-instance-method
postmodern has joined #crystal-lang
ur5us has quit [Ping timeout: 246 seconds]
<FromGitter> <alexherbo2> What is the convention to namespace multiple iterators? I initially have a `Walk.new("path/to/foo").each ...` class iterator to unconditionally traverse file entries. Now I want to have a `filter` method to control `next` generator if predicate passes, like this `Walk.new("path/to/foo").filter { |entry| Dir.exists?(entry.path) }.each ...`. I guess I need a subclass for that iterator, no?
<FromGitter> <HertzDevil> doesn`Walk.new(...).each.select { |entry| Dir.exists?(entry.path) }`
<FromGitter> <HertzDevil> *doesn't that work
<FromGitter> <HertzDevil> that should still give you an iterator
<FromGitter> <alexherbo2> For that case yep, but I need to step-in to prevent `next` going further down
<FromGitter> <HertzDevil> what do you mean
<FromGitter> <HertzDevil> `take_while`?
<FromGitter> <alexherbo2> My class is implemented with a `root`, `current` and `stack`. When I do `next` I pop the stack to change the current entry, and push to the stack when directory entries. So it’s already too late to skip the entry going down
<FromGitter> <alexherbo2> To filter entries, I have a `filter` method returning an iterator, taking the `entry` and a `predicate`. Its `next` does `predicate(walker.entry)` and if passing `walker.next`
<FromGitter> <HertzDevil> i still don't understand
<FromGitter> <HertzDevil> isn't that exactly `Iterator#select`
<FromGitter> <alexherbo2> I don't think, `walker.select` will select on all entries
terminalpusher has quit [Remote host closed the connection]
<FromGitter> <alexherbo2> @HertzDevil https://docs.rs/crate/walker/1.0.1/source/src/lib.rs
<FromGitter> <HertzDevil> i still don't understand where "namespacing" comes into this
<FromGitter> <alexherbo2> @HertzDevil I will have to move my `Walk` class into a module like `Walk::Base` to not collide with a `Walk::Filter` iterator?
<FromGitter> <HertzDevil> why
<FromGitter> <alexherbo2> I don't understand how to implement my `filter` method to the `Walk` iterator class
<FromGitter> <HertzDevil> that's a distinct issue from deciding how to namespace that iterator class
<FromGitter> <HertzDevil> stdlib simply puts all those iterator wrappers as private classes/structs namespaced under `Iterator`
<FromGitter> <alexherbo2> I can put a class in a class, like `Walk.Filter`?
<FromGitter> <HertzDevil> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=60e75fc482dd9050f5de349e]
<FromGitter> <HertzDevil> if it isn't private you refer to it from outside with `Walk::Filter`
<FromGitter> <alexherbo2> I never seen a class in a class, so I’m not sure what is the convention
<FromGitter> <alexherbo2> Instinctively I would have go to a `Walk` module, putting the two iterators in it
<FromGitter> <alexherbo2> @HertzDevil the naming convention for iterators would be `Walker` or `Walk`?
<FromGitter> <alexherbo2> usually class are nouns
ur5us has joined #crystal-lang