Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • 19:46
    wolfgang371 labeled #11342
  • 19:46
    wolfgang371 opened #11342
  • 14:02
    straight-shoota milestoned #11326
  • 13:58
    straight-shoota closed #11338
  • 13:58
    straight-shoota closed #11323
  • 13:18
    asterite closed #11341
  • 13:01
    beta-ziliani milestoned #11302
  • 10:53
    straight-shoota labeled #11335
  • 10:53
    straight-shoota labeled #11335
  • 10:53
    straight-shoota labeled #11335
  • 10:53
    straight-shoota labeled #11335
  • 10:53
    straight-shoota unlabeled #11335
  • 09:16
    straight-shoota labeled #11341
  • 09:16
    straight-shoota unlabeled #11341
  • 09:16
    straight-shoota labeled #11341
  • 09:16
    straight-shoota labeled #11341
  • 09:16
    straight-shoota unlabeled #11341
  • 07:26
    syalon labeled #11341
  • 07:26
    syalon opened #11341
  • Oct 19 18:53
    straight-shoota closed #11334
Emilia
@rymiel:rymiel.space
[m]
have an else which throws an exception?
speaking of, is there no way to view the --error-trace on carc.in?
George Dietrich
@Blacksmoke16
prob raise if index isnt 0 or 1 then just do like idx.zero? ? @x : @y
mfiano
@mjfiano:matrix.org
[m]
Yeah for this type. Also have 3d (x y z), and 4d (x y z w) types
George Dietrich
@Blacksmoke16
case + else with exception prob be the way to go then
From IRC (bridge bot)
@FromIRC
<riza> how does log.context get "inherited" when a fiber is spawned? I had assumed there was something in spawn/Fiber that called a .dup or .clone on the ivars on Fiber at .new time but I don't see it
George Dietrich
@Blacksmoke16
does it inherit context?
mfiano
@mjfiano:matrix.org
[m]
Spent a while trying to figure out why Number#negative? was erroring out. Looks like I am still on 1.0.0. Also looks like I need a break :/
George Dietrich
@Blacksmoke16
hey that was my feature :P
From IRC (bridge bot)
@FromIRC
<riza> @blacksmoke16 as far as I can tell, when a fiber is created, nothing is passed in from the current fiber: https://github.com/crystal-lang/crystal/blob/6a3f6b1e89be89dbe32a66a11da92d35e7790977/src/concurrent.cr#L61
<riza> but maybe that's implicit somewhere else
George Dietrich
@Blacksmoke16
right, so what makes you think it does get inherited?
From IRC (bridge bot)
@FromIRC
<riza> hhhhhhhhhhhhhhhhhhmmmm I don't know where I saw that
<riza> the log context metadata does have the ability to inherit
From IRC (bridge bot)
@FromIRC
<riza> this test seems to point that you're right and things aren't getting inherited though https://github.com/crystal-lang/crystal/blob/dd40a2442fa186add8a82b74edb14a90aa1dae05/spec/std/log/context_spec.cr#L62-L78
<riza> if they were being inherited I'd expect there to be an assertion in here which proves that a == 1 too
George Dietrich
@Blacksmoke16
yea, makes sense
pretty sure there's a way to set the context on a fiber tho
From IRC (bridge bot)
@FromIRC
<riza> there is, for sure
<riza> Fiber#current_context= is available
<riza> sorry #logging_context=, not #current_context= https://github.com/crystal-lang/crystal/blob/master/src/log/metadata.cr#L222-L230
<riza> that's fine. I was hoping there was some magic which let log inherit instances of itself from the parent fiber
<riza> thanks :⁠)
From IRC (bridge bot)
@FromIRC
<riza> man, now my head is spinning. this looks right to me: https://carc.in/#/r/blh6
<riza> same result here: https://carc.in/#/r/blh8
<riza> man how is carc.in so fast when crystal play is so slow
George Dietrich
@Blacksmoke16
i think only metadata is serializable, not context
From IRC (bridge bot)
@FromIRC
* riza derp
<riza> this api is kind of confusing, because you call #set on the context but if you want to render all the things you've set you have to call context.metadata
George Dietrich
@Blacksmoke16
context represents global fiber data, while metadata represents data on a specific log message
mfiano
@mjfiano:matrix.org
[m]
    def unsafe_fetch(index : Int)
      raise "foo" if index != 0 && index != 1
      index.zero? ? x : y
    end

    def unsafe_fetch(index : Int)
      raise "foo" if index != 0 && index != 1
      case index
      when 0 then x
      when 1 then y
      end
    end
@Blacksmoke16 Curious if this is a bug, but the latter version results in a compiler error when using some Indexable methods: Error: no overload matches 'Array(Float64)#<<' with type (Float64 | Nil)
George Dietrich
@Blacksmoke16
unsafe_fetch can return nil
mfiano
@mjfiano:matrix.org
[m]
I mean it is still exhaustive i would think
George Dietrich
@Blacksmoke16
because thats the default return value of a case w/o an else
mfiano
@mjfiano:matrix.org
[m]
I would think it could either return x, y, or NoReturn
George Dietrich
@Blacksmoke16
which is why you need to put it in the else if you're using case
mfiano
@mjfiano:matrix.org
[m]
the raise catches not a 0 or 1, doesn't it?
George Dietrich
@Blacksmoke16
:shrug: guess it's not that smart?
mfiano
@mjfiano:matrix.org
[m]
Which has the special NoReturn type
mfiano
@mjfiano:matrix.org
[m]
What class does #[]= come from?
I would like to include the 5 overloads for #[]= of Array into my Indexable struct type. Any ideas?
mfiano
@mjfiano:matrix.org
[m]
Is there a better way to perform an element-wise operation on my Indexable struct?
    def round
      v = dup
      v.each_with_index { |elt, i| v[i] = elt.round }
      v
    end
From IRC (bridge bot)
@FromIRC
<riza> #map
mfiano
@mjfiano:matrix.org
[m]
But the point is to mutate while traversing
I don't see how to do that with map
From IRC (bridge bot)
@FromIRC
<riza> from your code there, I don't see what you're trying to achieve that map doesn't
mfiano
@mjfiano:matrix.org
[m]
map returns an iterator which can be converted to an array