Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • 02:34
    Blacksmoke16 labeled #13023
  • 02:19
    cyangle labeled #13023
  • 02:19
    cyangle opened #13023
  • 00:41
    devnote-dev labeled #13022
  • 00:41
    devnote-dev opened #13022
  • Jan 27 23:05
    straight-shoota labeled #13021
  • Jan 27 23:05
    straight-shoota labeled #13021
  • Jan 27 23:05
    straight-shoota labeled #13021
  • Jan 27 23:05
    straight-shoota labeled #13021
  • Jan 27 23:05
    straight-shoota opened #13021
  • Jan 27 22:40
    straight-shoota labeled #13020
  • Jan 27 22:40
    straight-shoota labeled #13020
  • Jan 27 22:40
    straight-shoota labeled #13020
  • Jan 27 22:40
    straight-shoota opened #13020
  • Jan 27 21:18
    stefandd edited #13018
  • Jan 27 20:46
    etra0 review_requested #13006
  • Jan 27 18:30
    Blacksmoke16 closed #13007
  • Jan 27 18:30
    Blacksmoke16 closed #13019
  • Jan 27 18:21
    wyhaines closed #13019
  • Jan 27 16:56
    wyhaines labeled #13019
George Dietrich
@Blacksmoke16
why not v1 =~ v2
or is that how it was?
mfiano
@mjfiano:matrix.org
[m]
You just said you didn't like that, and neither do I tbh
Or did I misunderstand?
George Dietrich
@Blacksmoke16
it looked like it was used as Origin::Scalar.=~ v1, v2
due to the extend self
mfiano
@mjfiano:matrix.org
[m]
It is internally, because you cannot use the method call notation without a module prefix
The extend self was needed too
George Dietrich
@Blacksmoke16
id still use nearly_equal? but have def =~ instance method use that internally
id also look into def ===
which is used for case equality, which could forward to =~
mfiano
@mjfiano:matrix.org
[m]
This topic is both complicated and subjective. I left something out.
You pretty much never want to use == on two floats, let alone 2 aggregates of floats, so == calls out to =~ incase the user didn't use the more explicit approximation method, which would clearly be an error. The problem is, == must take exactly 1 receiver and 1 argument, so the defaults for rel_tol and abs_tol must be used in that case.
Which is also an error, albeit a lesser one
So there is no good solution that I know of
mfiano
@mjfiano:matrix.org
[m]
The reason for using the =~ symbol over == to begin with is because of this...the parser treats all = suffixed method names as setters, and errors on arity overloading away from that.
I think we discussed this already though :)
George Dietrich
@Blacksmoke16
yea, i figured it was because =~ represents matches
mfiano
@mjfiano:matrix.org
[m]
I personally don't think an operator should be used for a variadic function, and also because =~ doesn't mean the usual to Crystal programmers.
So I will more than likely move to nearly_equals?
George Dietrich
@Blacksmoke16
:thumbsup:
mfiano
@mjfiano:matrix.org
[m]
I might even go as far as to def ==; {{ raise ... }; end for vector types.
err with an other in there somewhere :)
mfiano
@mjfiano:matrix.org
[m]
Hmm, so with inheritance those pesky class methods are giving me issues again
George Dietrich
@Blacksmoke16
Oh?
mfiano
@mjfiano:matrix.org
[m]
It's saying that a .new method with 2 arguments doesn't exist when calling .rand...but i can call .new manually with 2 args...i haven't quite figured it out yet...
George Dietrich
@Blacksmoke16
Can you push up an example
mfiano
@mjfiano:matrix.org
[m]
done
Shoved everything in 1 file for now, sorry if it's hard to read like that
mfiano
@mjfiano:matrix.org
[m]
I bet those constants are eagerly evaluated before inheritance
I dunno though
George Dietrich
@Blacksmoke16
is the idea that they're a singleton?
mfiano
@mjfiano:matrix.org
[m]
what is they?
George Dietrich
@Blacksmoke16
i mean if those constants are just meant to an easy way to get that type in a specific state just do like
  def self.zero : self
    new 0.0
  end

  def self.one : self
    new 1.0
  end
but if they're expected to be a singleton. I.e. each call to V2::ZERO returns the same instance then you could use a lazily initialized class getter
mfiano
@mjfiano:matrix.org
[m]
They are constants to prevent allocation during tight loops when comparing instances against common values, etc
George Dietrich
@Blacksmoke16
so they're expected to return the same instance everytime
mfiano
@mjfiano:matrix.org
[m]
Yes, their values are expected to be inlined into the machine code.
They exist purely for having stable values that cannot change or needing to be allocated
George Dietrich
@Blacksmoke16
moreso mean is this correct: V2::ZERO.object_id == V2::ZERO.object_id
nvm, these are structs
mfiano
@mjfiano:matrix.org
[m]
assuming object ID is an address in memory, then definitely, yes
George Dietrich
@Blacksmoke16
I'd just do this then
  macro inherited
   ZERO = new 0.0
   ONE  = new 1.0
  end
so they get defined on each child
mfiano
@mjfiano:matrix.org
[m]
That was my guess, but didn't want to run into similar issues as before
George Dietrich
@Blacksmoke16
or could just duplicate the constants :shrug:
mfiano
@mjfiano:matrix.org
[m]
Next issue (pushed)