Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Nov 26 22:55
    straight-shoota closed #11493
  • Nov 26 22:32
    straight-shoota synchronize #11500
  • Nov 26 22:20
    straight-shoota synchronize #11500
  • Nov 26 21:59
    straight-shoota labeled #11500
  • Nov 26 21:59
    straight-shoota opened #11500
  • Nov 26 21:51
    straight-shoota synchronize #11475
  • Nov 26 21:51
    straight-shoota synchronize #11475
  • Nov 26 21:42
    oprypin review_requested #11395
  • Nov 26 20:59
    oprypin review_requested #11485
  • Nov 26 20:57
    beta-ziliani synchronize #11485
  • Nov 26 19:38
    hugopl synchronize #11395
  • Nov 26 19:29
    beta-ziliani milestoned #11469
  • Nov 26 17:57
    straight-shoota synchronize #11475
  • Nov 26 17:50
    straight-shoota edited #11299
  • Nov 26 17:49
    straight-shoota milestoned #11397
  • Nov 26 17:48
    straight-shoota milestoned #11457
  • Nov 26 17:47
    straight-shoota milestoned #11375
  • Nov 26 17:46
    straight-shoota milestoned #11473
  • Nov 26 17:46
    straight-shoota milestoned #11454
  • Nov 26 17:46
    straight-shoota milestoned #11494
From IRC (bridge bot)
@FromIRC
<hightower4> The macro in question is:
mfiano
@mjfiano:matrix.org
[m]
I would like to define a "safe" comparator for near floating point values, taking a relative and absolute tolerance
<riza> @mjfiano that error message is misleading for sure, but I think you'll need to go about it some other way
<riza> for example, you can subclass Float and overload ==
George Dietrich
@Blacksmoke16
@mjfiano:matrix.org is the default == for Float64 not sufficient
mfiano
@mjfiano:matrix.org
[m]
It is not. It does not allow supplying neither a relative nor absolute tolerance.
I am trying to implement a method that accomplishes the above
From IRC (bridge bot)
@FromIRC
<riza> I guess you can't subclass Float
George Dietrich
@Blacksmoke16
id checkout that thread
From IRC (bridge bot)
@FromIRC
<riza> the code sample at the end is basically what I was driving at
<riza> using =~ is a good idea
mfiano
@mjfiano:matrix.org
[m]
nearly_equals? seems to be the desired behavior. I'll have to inspect it to see if it is semantically equivalent with what I need.
Thanks
George Dietrich
@Blacksmoke16
:thumbsup:
hightower4: that's quite the macro you got there
From IRC (bridge bot)
@FromIRC
<hightower4> yeah, probably {% debug %} would be the next thing
George Dietrich
@Blacksmoke16
would that help? idt it's even going to run because it doesnt even expland
expand
From IRC (bridge bot)
@FromIRC
<hightower4> Wouldn't it print if it was placed above the place of error?
George Dietrich
@Blacksmoke16
the error is the macro itself so no
mjfiano
@mjfiano:matrix.org
[m]
About the code in the above thread...they seem to overload =~ for the language's Float type. I was hoping to not monkey patch the whole language, if that is what this is doing, and only introduce this overload when used in my specific module.
George Dietrich
@Blacksmoke16
there are no specific scope overloads
other option would be to use a decorator
mfiano
@mjfiano:matrix.org
[m]
Perhaps my concerns are nothing, but I am hesitant to do such a thing, if the library I am writing is to be used with third party code expecting different behavior for =~ of 2 floats.
I don't know how the language behaves in this regard
George Dietrich
@Blacksmoke16
would be better off defining a new method in such case
mfiano
@mjfiano:matrix.org
[m]
Fair enough. Should I subclass the builtin float type and use that everywhere in my domain, or is there a more idiomatic approach?
George Dietrich
@Blacksmoke16
a decorator type is usually the better way to go afaik
mfiano
@mjfiano:matrix.org
[m]
I'll look that up
Thanks
Do you mean defining an annotation?
George Dietrich
@Blacksmoke16
more like something like
struct FloatWrapper
  @value : Float64

  forward_missing_to @value

  def initialize(@value : Float64); end

  def special_method
  end
end
mfiano
@mjfiano:matrix.org
[m]
Hmm, I don't really understand how that is delegating, but I'll study that code some. Thanks
mfiano
@mjfiano:matrix.org
[m]
Yeah that was my first stop. Just trying to figure out how this is different than inheritance. The docstring/example could be better imo
Taupiqueur
@alexherbo2
@Blacksmoke16 what is the % in the macro?
George Dietrich
@Blacksmoke16
hm?
Taupiqueur
@alexherbo2
%v1
Taupiqueur
@alexherbo2
it looks to work without the %
Rishav Sharan
@rishavs
How would one go about converting a hex string to normal string?
George Dietrich
@Blacksmoke16
what do you mean by "normal string"?
a hex string is just a string of hex characters
Taupiqueur
@alexherbo2
so I should replace my value with %value to avoid side effects?
George Dietrich
@Blacksmoke16
@alexherbo2 idt it would matter