Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • 02:24
    caspiano labeled #11376
  • 02:24
    caspiano opened #11376
  • Oct 27 23:00
    darkstego synchronize #11370
  • Oct 27 20:36
    straight-shoota milestoned #11369
  • Oct 27 20:36
    straight-shoota milestoned #11349
  • Oct 27 20:35
    straight-shoota milestoned #11139
  • Oct 27 20:34
    straight-shoota milestoned #10590
  • Oct 27 20:33
    straight-shoota milestoned #11363
  • Oct 27 20:21
    darkstego reopened #11370
  • Oct 27 19:46
    oprypin synchronize #11352
  • Oct 27 19:43
    oprypin closed #11357
  • Oct 27 17:36
    straight-shoota closed #11364
  • Oct 27 17:30
    darkstego closed #11370
  • Oct 27 15:20
    darkstego synchronize #11370
  • Oct 27 14:30
    HertzDevil edited #11218
  • Oct 27 13:54
    darkstego synchronize #11370
  • Oct 27 13:19
    darkstego synchronize #11370
  • Oct 27 11:06
    straight-shoota synchronize #11366
  • Oct 27 11:04
    straight-shoota synchronize #11369
  • Oct 27 11:02
    straight-shoota closed #5005
mfiano
@mjfiano:matrix.org
[m]
Anyway, I have to try to erase my complicated Lisp macro memory to learn the basics of Crystal, else I'm going to be violating DRY a lot in this practice project.
George Dietrich
@Blacksmoke16
most of the time you dont need them either
mfiano
@mjfiano:matrix.org
[m]
(which I hope to evolve into more than a practice project as the basis for what I want to use Crystal for)
The alternative is I just DRY without care and figure out if a macro will make it more maintainable later when I'm more accustomed.
🤷‍♂️
From IRC (bridge bot)
@FromIRC
<riza> my honest advice is to avoid macros where possible (in both lisp and crystal). they're an amazing toolset when you need it but most problems can be solved elegantly without.
<riza> over-macro-ing makes code hard to maintain
mfiano
@mjfiano:matrix.org
[m]
I am torn. While I do agree, what has kept Lisp a viable language since the 50's is that new language features and are just a macro away. There's only so much you can do without creating new compiler extensions (macros).
From IRC (bridge bot)
@FromIRC
<riza> Can these fresh variable hashes be iterated, or do you have to keep the list of keys around
<riza> keep/pass
George Dietrich
@Blacksmoke16
hash was maybe the wrong work
its more of just a means of allowing the same fresh var name to hold multiple values based on another unique identifier
so you would need to keep the "keys" around in order to access the same value, which could just be the idx of something as that can't change
From IRC (bridge bot)
@FromIRC
<riza> yeah makes sense
<riza> it looks like it's probably just a substitution layer where %var{name} when name="test" just gets fresh'd to %var-test or something
George Dietrich
@Blacksmoke16
yea prob something along those lines
mfiano
@mjfiano:matrix.org
[m]
I am feeling dumb that I can't figure this out, but can someone show me an example of defining an == method that takes 2 Float64's at the module level? For some reason the compiler thinks I'm trying to define a setter method and yells about syntax...
From IRC (bridge bot)
@FromIRC
<riza> @mjfiano can you post what you've got?
mfiano
@mjfiano:matrix.org
[m]
module MyModule
  def ==(x : Float64, y : Float64) # setter method '==' cannot have more than one argument
    ...
  end
end
George Dietrich
@Blacksmoke16
i this module included into a custom type?
mfiano
@mjfiano:matrix.org
[m]
No
George Dietrich
@Blacksmoke16
oh, got an example of how this is to be used then?
From IRC (bridge bot)
@FromIRC
<riza> I don't know if the == operator can be overloaded that way
George Dietrich
@Blacksmoke16
it cant
normally it would be 1 argument that you compare with self
From IRC (bridge bot)
@FromIRC
<hightower4> Would anyone know offhand why a macro that works on 1.0.0 would report 'Exception: unterminated macro' on 1.1.0?
<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