Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Sep 28 18:26
    straight-shoota labeled #11254
  • Sep 28 18:26
    straight-shoota labeled #11254
  • Sep 28 18:26
    straight-shoota opened #11254
  • Sep 28 18:19
    straight-shoota closed #11245
  • Sep 28 18:11
    straight-shoota labeled #11253
  • Sep 28 18:11
    straight-shoota labeled #11253
  • Sep 28 18:11
    straight-shoota opened #11253
  • Sep 28 17:52
    straight-shoota unlabeled #11252
  • Sep 28 17:45
    straight-shoota labeled #11252
  • Sep 28 14:59
    syeopite edited #11252
  • Sep 28 14:59
    syeopite edited #11252
  • Sep 28 14:54
    syeopite labeled #11252
  • Sep 28 14:54
    syeopite opened #11252
  • Sep 28 14:45
    beta-ziliani demilestoned #11195
  • Sep 28 14:34
    straight-shoota closed #8384
  • Sep 28 14:24
    beta-ziliani demilestoned #10889
  • Sep 28 14:24
    beta-ziliani milestoned #10889
  • Sep 28 14:23
    beta-ziliani demilestoned #10952
  • Sep 28 14:22
    beta-ziliani milestoned #10952
  • Sep 28 14:21
    beta-ziliani milestoned #11101
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
mfiano
@mjfiano:matrix.org
[m]
Oh I see now.
That clears up more than I care to admit
George Dietrich
@Blacksmoke16
:P
mfiano
@mjfiano:matrix.org
[m]
Hmm, if I mixin a module with a new method by using extend, I get "... is not expected to be invoked with a block, but a block was given". Works fine copy/pasting this new into every final type though. Ideas?
George Dietrich
@Blacksmoke16
Yes
mfiano
@mjfiano:matrix.org
[m]
Where can I find the list of available macro variables like @type, @def, and @top_level?
George Dietrich
@Blacksmoke16
by virtue of you adding another constructor the others are no longer invocable i think
mfiano
@mjfiano:matrix.org
[m]
Oh
George Dietrich
@Blacksmoke16
i think that's true, but don't quote me
mfiano
@mjfiano:matrix.org
[m]
Ok, about the macro variable list, does one exist? I tried searching and only see those 3 mentioned in passing in the reference docs
George Dietrich
@Blacksmoke16
those are the only 3
mfiano
@mjfiano:matrix.org
[m]
Nothing in the api docs from what i see either
Aha!
Thank you. I'm trying to figure out how I can get at the inner right-most type string name of a module path gotten with @type.
Oh that was a mouthful. It's getting late
George Dietrich
@Blacksmoke16
@type.name.split("::").last
mfiano
@mjfiano:matrix.org
[m]
Ok so string manip it is
George Dietrich
@Blacksmoke16
ye
i always wondered what the .identify method is for on StringLiteral
Foo::Bar.name.stringify.identify # => "Foo__Bar" :thinking:
mfiano
@mjfiano:matrix.org
[m]
wonder if I can rely on the order of #instance_vars being how they are defined...
George Dietrich
@Blacksmoke16
crystal-lang/crystal#147 wew, apparently this is why :P
probably
dunno if it'll help your use case but you can pass numbers as generic args
mfiano
@mjfiano:matrix.org
[m]
Ok last question before I pass out? How do I newline split up long io << foo << bar << baz << ... chains so the parser is happy? :)
George Dietrich
@Blacksmoke16
io << foo << bar << baz
io << one << two << three
...
really could have each << on its own line as well
:shrug: