Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • 05:25
    HertzDevil synchronize #10711
  • 04:50
    HertzDevil labeled #11377
  • 04:50
    HertzDevil labeled #11377
  • 04:50
    HertzDevil opened #11377
  • 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
From IRC (bridge bot)
@FromIRC
<riza> hm, I'm not instantly sure how that would be useful, but it's neat to see regardless
George Dietrich
@Blacksmoke16
main use case afaik is if you want to create them in a loop
otherwise if you just did %key, it would be overridden on each iteration
mfiano
@mjfiano:matrix.org
[m]
I see. Also I really like Crystal and I don't mean to sound like a Lisp snob, because there are plenty of them. Lisp is nice, but it's too dynamic for some tasks...which is one thing that makes its macro system powerful. Every phase of the compiler can be invoked by any other phase by the user, which means macros can be expanded at runtime and all that. It's a mind!@#$, really.
From IRC (bridge bot)
@FromIRC
<riza> Yeah I suppose that could be a useful way to replace https://github.com/mosquito-cr/mosquito/blob/master/src/mosquito/base.cr#L10-L12
<riza> or several places where the finished macro is used
George Dietrich
@Blacksmoke16
use an annotation and iterate over types that have it
then could build a hash literal at build time or whatever you need
or what's that method doing actually?
cant just build a hash of Mosquito::Job.class => Mosquito::Job?
From IRC (bridge bot)
@FromIRC
<riza> Mosquito::Job.class.to_s => Mosquito::Job.class
George Dietrich
@Blacksmoke16
it's been a while since i been in the code, what's this do again?
From IRC (bridge bot)
@FromIRC
<riza> when a job is popped out of redis, it allows the runner to do a lookup in that hash to convert the job name in redis to a reference to the job class
George Dietrich
@Blacksmoke16
can you just use the FQN of the job class as the key?
oh wait
this is so that you can go from a string from redis to an actual type
should feature request Foo::Bar.class.from_json %("Foo::Bar") :P
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