Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • 01:09
    straight-shoota closed #11747
  • 01:09
    straight-shoota closed #11745
  • Jan 17 19:16
    straight-shoota synchronize #11716
  • Jan 17 19:11
    straight-shoota synchronize #11715
  • Jan 17 18:34
    straight-shoota milestoned #11747
  • Jan 17 14:31
    straight-shoota synchronize #10416
  • Jan 17 14:27
    straight-shoota synchronize #11715
  • Jan 17 14:04
    straight-shoota milestoned #11750
  • Jan 17 13:57
    straight-shoota labeled #11750
  • Jan 17 13:57
    straight-shoota labeled #11750
  • Jan 17 12:53
    mamantoha edited #11750
  • Jan 17 12:52
    mamantoha edited #11750
  • Jan 17 12:51
    mamantoha synchronize #11750
  • Jan 17 11:26
    mamantoha synchronize #11750
  • Jan 17 11:01
    mamantoha synchronize #11750
  • Jan 17 10:54
    mamantoha synchronize #11750
  • Jan 17 10:48
    mamantoha edited #11750
  • Jan 17 10:48
    mamantoha edited #11750
  • Jan 17 10:48
    mamantoha opened #11750
  • Jan 16 23:10
    skurhse closed #11739
mfiano
@mjfiano:matrix.org
[m]
I see. Main difference I see is SA is a homogeneous container, which might be more contiguous/better for cache
From IRC (bridge bot)
@FromIRC
<straight-shoota> @mjfiano What exactly do you want to do?
mfiano
@mjfiano:matrix.org
[m]
straight-shoota: I'm pretty new, just experimenting mostly. But right now I have Vector (math) types in 2-4 dimensions, and currently using separate float ivars. Would like to back their storage in some container, so the method logic can map over them and reduce code by being generic for all 3 types.
mfiano
@mjfiano:matrix.org
[m]
Most operations are element-wise, so could reduce quite a bit of code by iterating over a generic container of some size to produce results for a given operation/vector type.
THat is the idea anyway. Not sure where to start yet :)
George Dietrich
@Blacksmoke16
fwiw its fairly easy to make a struct that is iterable
mfiano
@mjfiano:matrix.org
[m]
Interesting
George Dietrich
@Blacksmoke16
that you could use with .each or .mapetc
mfiano
@mjfiano:matrix.org
[m]
I need to learn that too then
So how does that work? Is it an abstract type where I have to implement some methods?
George Dietrich
@Blacksmoke16
its a module that you include in your type, an implement a method
2 methods*
1 that returns the size of your container, and another that gets the value at the given index
mfiano
@mjfiano:matrix.org
[m]
Oh does that page say which 2 methods?
George Dietrich
@Blacksmoke16
search for abstract
mfiano
@mjfiano:matrix.org
[m]
Oh that's very nice.
Thank you
George Dietrich
@Blacksmoke16
makes it super easy to do like arry.sort!
mfiano
@mjfiano:matrix.org
[m]
I am beginning to see how Crystal is very extensible with these mixin modules
mfiano
@mjfiano:matrix.org
[m]
It seems I have to study generic type parameters more because the compiler can't infer the type parameter and I'm not sure what to specify.
mfiano
@mjfiano:matrix.org
[m]
Heh, you're right. That is easy. I do have one complaint about the compiler here though.
George Dietrich
@Blacksmoke16
oh?
mfiano
@mjfiano:matrix.org
[m]
When i include Indexable(T), the compiler was smart enough to tell me I didn't implement unsafe_fetch. After I implemented that and tried using it, the compiler ended up overflowing the stack due to recursing infinitely. It wasn't until I implemented size that it worked. It makes me wonder why it just blew the stack instead of complaining that I didn't implement size.
George Dietrich
@Blacksmoke16
hm
got a small example of that behavior? I have a theory
From IRC (bridge bot)
@FromIRC
<straight-shoota> The problem is that Indexable#size is actually implemented by it's ancestor Enumerable#size
mfiano
@mjfiano:matrix.org
[m]
I will make one on play
George Dietrich
@Blacksmoke16
yea that was my guess ^ which its implementation just iterates the whole thing to figure out
From IRC (bridge bot)
@FromIRC
<straight-shoota> Relevant issues are crystal-lang/crystal#10014
<straight-shoota> and crystal-lang/crystal#9998
mfiano
@mjfiano:matrix.org
[m]
George Dietrich
@Blacksmoke16
yea, reason is what @straight-shoota said
mfiano
@mjfiano:matrix.org
[m]
Ah I see
This ability to make anything indexable/iterable/whatever-able is fantastic.
Thank you for opening my blind eyes after reading the docs/api multiple times
mfiano
@mjfiano:matrix.org
[m]
It appears more has to be implemented, or what is the error here? https://play.crystal-lang.org/#/r/blfw
Emilia
@rymiel:rymiel.space
[m]
wouldn't your unsafe_fetch here return a nilable value
because there's no else in the case
mfiano
@mjfiano:matrix.org
[m]
Hmm how do I fix it?
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