Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • 00:07
    Blacksmoke16 labeled #12783
  • 00:07
    Blacksmoke16 labeled #12783
  • Nov 26 23:55
    carlhoerberg opened #12783
  • Nov 26 11:21
    straight-shoota milestoned #12781
  • Nov 26 11:21
    straight-shoota milestoned #12781
  • Nov 26 02:15
    straight-shoota assigned #11331
  • Nov 25 23:24
    straight-shoota labeled #12782
  • Nov 25 23:24
    straight-shoota labeled #12782
  • Nov 25 23:24
    straight-shoota opened #12782
  • Nov 25 23:17
    straight-shoota labeled #12781
  • Nov 25 23:17
    straight-shoota labeled #12781
  • Nov 25 23:17
    straight-shoota opened #12781
  • Nov 25 23:01
    straight-shoota synchronize #11635
  • Nov 25 22:56
    straight-shoota synchronize #11840
  • Nov 25 22:49
    straight-shoota labeled #12636
  • Nov 25 19:21
    straight-shoota labeled #12780
  • Nov 25 19:21
    straight-shoota labeled #12780
  • Nov 25 19:21
    straight-shoota labeled #12780
  • Nov 25 19:21
    straight-shoota opened #12780
  • Nov 25 19:11
    straight-shoota labeled #12779
George Dietrich
@Blacksmoke16
good to hear
didactic-drunk
@didactic-drunk
Is there a built in Range expection in Spec? Something like a.should_be within range? Or an approximate expectation for floats?
Taupiqueur
@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?
Quinton Miller
@HertzDevil
doesnWalk.new(...).each.select { |entry| Dir.exists?(entry.path) }
*doesn't that work
that should still give you an iterator
Taupiqueur
@alexherbo2
For that case yep, but I need to step-in to prevent next going further down
Quinton Miller
@HertzDevil
what do you mean
take_while?
Taupiqueur
@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
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
Quinton Miller
@HertzDevil
i still don't understand
isn't that exactly Iterator#select
Taupiqueur
@alexherbo2
I don't think, walker.select will select on all entries
Quinton Miller
@HertzDevil
i still don't understand where "namespacing" comes into this
Taupiqueur
@alexherbo2
@HertzDevil I will have to move my Walk class into a module like Walk::Base to not collide with a Walk::Filter iterator?
Quinton Miller
@HertzDevil
why
Taupiqueur
@alexherbo2
I don't understand how to implement my filter method to the Walk iterator class
Quinton Miller
@HertzDevil
that's a distinct issue from deciding how to namespace that iterator class
stdlib simply puts all those iterator wrappers as private classes/structs namespaced under Iterator
Taupiqueur
@alexherbo2
I can put a class in a class, like Walk.Filter?
Quinton Miller
@HertzDevil
class Walk
  private class Filter
  end

  def filter
    Filter.new(...)
  end
end
if it isn't private you refer to it from outside with Walk::Filter
Taupiqueur
@alexherbo2
I never seen a class in a class, so I’m not sure what is the convention
Instinctively I would have go to a Walk module, putting the two iterators in it
@HertzDevil the naming convention for iterators would be Walker or Walk?
usually class are nouns
Quinton Miller
@HertzDevil
Dragonbox   9.39  (106.50ms) (± 3.31%)  84.1MB/op        fastest
   Grisu3   6.73  (148.67ms) (± 4.11%)  68.7MB/op   1.40× slower
soon
Benjamin Wade
@RespiteSage
Does stdlib have its own logic for type promotion when adding different numeric types, or does it rely on LLVM for that?
In particular I'm thinking about the case of a + b, where b is a wider type than a.
So like Int8#+(UInt64), as an extreme example.
Daniel Worrall
@Daniel-Worrall
Int#+(otherInt) returns self class, so no
Benjamin Wade
@RespiteSage
No, that's not what I mean.
Daniel Worrall
@Daniel-Worrall
It'll raise overflow, not promote
Benjamin Wade
@RespiteSage
This is what I mean: https://carc.in/#/r/bid3
Maybe "type promotion" was the wrong wording.
Unless I'm sorely mistaken, the hardware doesn't do arithmetic on numbers of mismatched length, so either Crystal or LLVM has to turn those numbers into the same type under the covers.
Presumably it's the larger type, and then they try to convert it to the left-hand type, which could raise overflow.
I'm asking this because I'm trying to handle arithmetic with mismatched numeric types in saline.
Benjamin Wade
@RespiteSage
Okay, found it
Daniel Worrall
@Daniel-Worrall
yikes, my playground docker container was using 1.2GB of memory
From IRC (bridge bot)
@FromIRC
<Guest15> hello all. i am wondering if variadic functions are supported for crystal functions and procs. ive tried playing around with VaList and viewing the specs around it, but i cant seem to make sense of it. does anyone happen to have an example of passing multiple arguments via variadic functions with crystal?
maybe you could use valist exactly like c i don't know
Lance Dillon
@riffraff169
just a question: c varargs no, but is it possible to link to a c function that accepts varargs, but you dont pass varargs...so you would create a crystal function for each variant you want...