Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • 19:05
    lbguilherme synchronize #11947
  • 17:29
    straight-shoota milestoned #11971
  • 17:15
    straight-shoota closed #12038
  • 17:15
    straight-shoota closed #12036
  • 17:14
    straight-shoota edited #12038
  • 13:47
    straight-shoota closed #12051
  • 13:47
    straight-shoota closed #12050
  • 12:17
    beta-ziliani edited #7318
  • May 15 08:43
    r00ster91 closed #7318
  • May 15 08:17
    r00ster91 closed #7690
  • May 14 17:01
    Blacksmoke16 labeled #11995
  • May 14 13:03
    webhive closed #12055
  • May 14 10:19
    straight-shoota milestoned #12051
  • May 14 10:00
    I3oris edited #12051
  • May 14 08:45
    oprypin review_requested #11977
  • May 13 23:29
    Blacksmoke16 unlabeled #12061
  • May 13 22:56
    Blacksmoke16 edited #12061
  • May 13 22:56
    Blacksmoke16 edited #12061
  • May 13 22:54
    Blacksmoke16 labeled #12061
  • May 13 22:54
    Blacksmoke16 labeled #12061
mfiano
@mjfiano:matrix.org
[m]
Hmm, I guess I could do this, but it seems macro writing in Crystal is a lot of DRY violations, unless I'm not experienced.
  private macro make_accessors(*names)
    {% for name, i in names %}
      def {{name}}
        @data[{{i}}]
      end
      def {{name}}=(value : Float64)
        @data[{{i}}] = value
      end
    {% end %}
  end

  private macro make_constructors(*names)
    def initialize({% for name in names %} {{name}} : Float64, {% end %})
      {% for name, i in names %}
        @data[{{i}}] = {{name}}
      {% end %}
    end
    def initialize(value : Float64 = 0.0)
      initialize({% for name in names %} value, {% end %})
    end
  end

  make_accessors x, y, z
  make_constructors x, y, z
mfiano
@mjfiano:matrix.org
[m]
Just seems odd that I have to bind a variable to iterate N times, and I can't even use an underscore
(line 19 above)
mfiano
@mjfiano:matrix.org
[m]
My first library is finished, code-wise, and I'm pretty happy with it. I still have to do docs and specs which will take a long time given the number of defs, but yay
George Dietrich
@Blacksmoke16
nice one!
mfiano
@mjfiano:matrix.org
[m]
I saved a considerable amount of complexity and duplicated code by wrapping a staticarray and forwarding missing, instead of all the nonsense i had to do before
i think srasu suggested that, or whoever it was, thanks
oh i guess it's suskeyhose over on gitter
Is there a recommended style guide apart from the rather short one on the web site? I was looking to see what magic number this language recommends for max columns :)
George Dietrich
@Blacksmoke16
i dont think there is one
i usually just make it so i dont have to scroll :p
mfiano
@mjfiano:matrix.org
[m]
Well, I hope the macro writing DSL grammar is on the list of things to improve. This is definitely not as powerful as Lisp.
George Dietrich
@Blacksmoke16
only related things that i know of are like crystal-lang/crystal#8835 and crystal-lang/crystal#9802
From IRC (bridge bot)
@FromIRC
<riza> @mjfiano - what are you looking for that you aren't finding?
mfiano
@mjfiano:matrix.org
[m]
I mentioned one thing just below the code snippet above
methods in macro land is the issue discussing most of my concerns though
George Dietrich
@Blacksmoke16
yea it uses a subset of the stdlib methods
From IRC (bridge bot)
@FromIRC
<riza> ah yeah, for sure.
George Dietrich
@Blacksmoke16
fwiw i think you can improve this a bit
From IRC (bridge bot)
@FromIRC
<riza> the inability to repeatedly inject a macro has suffered me many times
mfiano
@mjfiano:matrix.org
[m]
I get that nothing can possibly be as powerful as Lisp, without actually being Lisp, because once you add homoiconicity to a language that enables powerful macros taking advantage of the full language instead of a DSL, you can practically call it a Lisp
But a little more will go a long way
However, despite being a huge Lisp fan, I stay away from macros unless I have to, unlike a lot of people that grow old trying to bend the language to do cool new things. However, when I actually do need to write a macro for some syntactic abstraction or boilerplate reduction, I need access to the language at compile time, not some tiny subset of it.
George Dietrich
@Blacksmoke16
fwiw you could do like {% for i in 0..4 %}
mfiano
@mjfiano:matrix.org
[m]
I am by no means trying to bash Crystal though. Its balance of simplicity and power is what drove me to try it, and I am very pleased with that. Lisp is pretty much 1000% power.
Yes, the "loop n times" instead of "loop over some collection/range" can be simulated like that, though I would have liked to use _ in place of i to convey meaning to the reader.
George Dietrich
@Blacksmoke16
_idx :shrug:
mfiano
@mjfiano:matrix.org
[m]
Bringing over the times method would almost be enough, except need some concise DSL to account for when the count is the length of a sequence, but still don't want to bind any e or i vars
</nitpick> The real issue is DRY violation as that issue discusses. I think a lot of people would be happy with work done in that area
George Dietrich
@Blacksmoke16
hm 0..collection.size
you also have .each and .map available
kinda
mfiano
@mjfiano:matrix.org
[m]
How would you use them in macroland?
George Dietrich
@Blacksmoke16
you have macro level variables that you could use it to set, but you'd have to use for in if you wanted to iterate over them and generate code
mfiano
@mjfiano:matrix.org
[m]
Oh sure, that'll just return a sequence for you to do whatever with, like {% for ... %} :)
George Dietrich
@Blacksmoke16
mjfiano
@mjfiano:matrix.org
[m]
That latest snippet answered an unrelated question I was going to ask.
I assumed right, that you can bind compile-time variables like that
George Dietrich
@Blacksmoke16
https://github.com/athena-framework/dependency-injection/blob/master/src/service_container.cr#L135 also quite a bit of complex logic using this feature if you wanted to poke around
mfiano
@mjfiano:matrix.org
[m]
Oh athena suite is your pet? I see that all over 😆
Never made the connection
George Dietrich
@Blacksmoke16
code is super gross because you cant reuse anything, but it would look much better with crystal-lang/crystal#8835
haha yea it is
mfiano
@mjfiano:matrix.org
[m]
It seems to be one of the most solid projects for sure
Sadly, I don't do any webdev these days anymore, so might use the logger or one of the decoupled things if anything.
George Dietrich
@Blacksmoke16
logger is built into the stdlib
mfiano
@mjfiano:matrix.org
[m]
Fair enough. Well there was one athena project i was thinking of using, but I forget what it was
George Dietrich
@Blacksmoke16
there is a CLI/console framework component that is currently in a working state, I just need to finish the docs on it tho
other than that, can deff use them independently. E.g. like the validator or serializer etc