Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • 08:14
    straight-shoota labeled #11054
  • 02:23
    HertzDevil closed #11055
  • 02:21
    HertzDevil converted_to_draft #11055
  • 02:07
    HertzDevil labeled #11055
  • 02:07
    HertzDevil labeled #11055
  • 02:07
    HertzDevil opened #11055
  • 00:22
    lbguilherme labeled #11054
  • 00:22
    lbguilherme opened #11054
  • Aug 02 23:48
    lbguilherme synchronize #10870
  • Aug 02 20:55
    asterite synchronize #10910
  • Aug 02 20:45
    asterite synchronize #10910
  • Aug 02 20:15
    straight-shoota synchronize #11030
  • Aug 02 20:12
    straight-shoota labeled #11053
  • Aug 02 20:12
    straight-shoota opened #11053
  • Aug 02 19:54
    straight-shoota synchronize #11030
  • Aug 02 19:39
    straight-shoota milestoned #11030
  • Aug 02 18:20
    straight-shoota closed #10621
  • Aug 02 18:20
    straight-shoota closed #10625
  • Aug 02 17:18
    straight-shoota closed #10624
  • Aug 02 17:13
    straight-shoota labeled #11052
From IRC (bridge bot)
@FromIRC
<straight-shoota> So on send(1), the receiving fiber is enqueued, on send(2), there's no waiting receiver and no queue, so the channel triggers a reschedule.
George Dietrich
@Blacksmoke16
when the thing that changed it was MT, which maybe its a byproduct of supporting MT versus a regression
From IRC (bridge bot)
@FromIRC
<straight-shoota> No, I think it's a fix really. The previous behaviour was not correct. At least not what you would expect from the specifics of a channel.
George Dietrich
@Blacksmoke16
hmm fair enough
mfiano
@mjfiano:matrix.org
[m]
Do I have to create 2 different partial types if the intended behavior is to mixin a set of instance methods and a set of class methods?
George Dietrich
@Blacksmoke16
i usually define a ClassMethods module within the one partial type, then add a like macro inherited; extend ClassMethods; end;
mfiano
@mjfiano:matrix.org
[m]
I can't seem to get that to work. Maybe I'm doing it wrong...
George Dietrich
@Blacksmoke16
module Foo
  module ClassMethods
    def class_method
      2
    end
  end

  macro inherited
    extend ClassMethods
  end

  def instance_method
    1
  end
end

class Bar
  include Foo
end

Bar.new.instance_method # => 1
B.class_method # => 2
sorry
macro included :see_no_evil:
mfiano
@mjfiano:matrix.org
[m]
Still trying unsuccessfully. My project is too spread out and unfinalized to publish it yet. I may have to try to isolate the problem on carc.in or smth :/
George Dietrich
@Blacksmoke16
gl
mfiano
@mjfiano:matrix.org
[m]
works fine as separate modules tho
where is included documented?
mfiano
@mjfiano:matrix.org
[m]
Ah...I was doing it correctly, but I believe I ran into a compiler bug I should file, due to my own mistake though. I have a A::B module that does include A (don't ask why), and this works until you add an included hook. Probably gives up fully resolving due to cyclic graph
mfiano
@mjfiano:matrix.org
[m]
Ah the issue is not as bad as that actually, but still unsure how to solve it.
One class method in ClassMethods has a default argument value specified to be a constant. This constant id is guaranteed to exist in all types that include Foo, but with a different value for each type.
and the ultimate problem when getting rid of red herrings, is that this constant cannot be resolved at parse time, since it depends on the type that includes it
Interesting problem
mfiano
@mjfiano:matrix.org
[m]
On another note, I'm curious if any other languages have something like the namespaces/partial type duality, as it is new to me and I think it is pretty clever. Does Ruby do this, was this feature inspired by other similar concepts, or is this unique to Crystal?
George Dietrich
@Blacksmoke16
it's basically copied from ruby
mfiano
@mjfiano:matrix.org
[m]
I see. It is a nice idea.
mfiano
@mjfiano:matrix.org
[m]

"Note that most search and filter methods traverse an Enumerable eagerly,
producing an Array as the result. For a lazy alternative refer to
the Iterator and Iterable modules."

Does this apply to #all?, and if so, what is an efficient way to do it if I have Iterable?

George Dietrich
@Blacksmoke16
all? returns a bool
meaning it'll iterate the entire collection as is
  def all?
    each { |e| return false unless yield e }
    true
  end
is all it is
mfiano
@mjfiano:matrix.org
[m]
Great, yeah dumb question
George Dietrich
@Blacksmoke16
@straight-shoota one more time regarding that buffered channel bug

if you add

  puts "Before send 4"
  channel.send(4)

then update it to 4.times do, why does it output

Before send 1
Before send 2
Before send 3
Before send 4
1
2
3
4
with a buffer size of 4, the first value takes care of the initial receive, 2 and 3 should fill that buffer, but it doesnt switch on the 4th value?
buffer size of 2 rather*
oh wait, it does, but then there isn't anything to get it to execute that fiber again which is why it doesnt print the after message
nvm
mfiano
@mjfiano:matrix.org
[m]
How would I do the equivalent of Enumerable#all?(&), except get access to the index as an argument (along with the existing object)?
George Dietrich
@Blacksmoke16
do you just want to find the first element that is true?
or?
mfiano
@mjfiano:matrix.org
[m]
  def =~(other : self, rel_tol : Float64 = DEFAULT_TOLERANCE, abs_tol : Float64 = rel_tol)
    all? { |obj| Origin.=~(obj, other[idx], rel_tol, abs_tol) }
  end
I want to do something like this, with idx bound of course
George Dietrich
@Blacksmoke16
id prob just copy the .all? method into your code and use each_with_index instead
or if you want define an all_with_index if you dont want to override the actual all method
mfiano
@mjfiano:matrix.org
[m]
Ok thanks.
George Dietrich
@Blacksmoke16

oh wait, it does, but then there isn't anything to get it to execute that fiber again which is why it doesnt print the after message

and no, im still confused. Is the buffer actually 1 more than what you specify. Otherwise why else would it print 2, 3, and 4 versus just 2 and 3

and if you add 5 it outputs

Before send 1
Before send 2
Before send 3
Before send 4
1
2
3
4
After send
5

which makes sense expect it printed 3 values with a buffer of 2?

except*
or maybe it's not really like a hard cutoff like im thinking and more like a way to tell the channel to trigger a reschedule when its buffer is full, which in this case value 4 "overflows" the buffer resulting in that reschedule
as opposed to the next opportunity
mfiano
@mjfiano:matrix.org
[m]
  private def all_with_index?
    each_with_index { |e, i| return false unless yield e, i }
    true
  end

  def =~(other : self, rel_tol : Float64 = DEFAULT_TOLERANCE, abs_tol : Float64 = rel_tol)
    all_with_index? { |e, i| Origin.=~(e, other[i], rel_tol, abs_tol) }
  end
I'm still a little confused when working with blocks. This works, but how would this be rewritten to inline the functionality of all_with_index?, as this is the only usage of it and it doesn't deserve its own method?
George Dietrich
@Blacksmoke16
prob like
  def =~(other : self, rel_tol : Float64 = DEFAULT_TOLERANCE, abs_tol : Float64 = rel_tol)
    each_with_index { |e, i| return false unless Origin.=~(e, other[i], rel_tol, abs_tol) }
    true
  end