Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Feb 08 18:26
    beta-ziliani milestoned #13043
  • Feb 08 18:26
    beta-ziliani milestoned #13043
  • Feb 08 18:00
    Blacksmoke16 labeled #13053
  • Feb 08 17:59
    straight-shoota labeled #13053
  • Feb 08 17:59
    straight-shoota labeled #13053
  • Feb 08 17:59
    straight-shoota assigned #13053
  • Feb 08 17:59
    straight-shoota opened #13053
  • Feb 08 12:19
    straight-shoota closed #13010
  • Feb 08 12:19
    straight-shoota closed #13050
  • Feb 08 12:18
    straight-shoota closed #13048
  • Feb 07 18:12
    HertzDevil labeled #13052
  • Feb 07 18:12
    HertzDevil labeled #13052
  • Feb 07 18:12
    HertzDevil labeled #13052
  • Feb 07 18:12
    HertzDevil opened #13052
  • Feb 07 17:49
    straight-shoota closed #13051
  • Feb 07 17:46
    beta-ziliani milestoned #13051
  • Feb 07 17:46
    beta-ziliani milestoned #13051
  • Feb 07 14:03
    beta-ziliani review_requested #13050
  • Feb 07 13:59
    straight-shoota labeled #13051
  • Feb 07 13:59
    straight-shoota assigned #13051
mfiano
@mjfiano:matrix.org
[m]
I think mayhbe my code is wrong and it is calling the wrong overload
No it is calling the same method in both cases.
mfiano
@mjfiano:matrix.org
[m]
I think everything is fine actually. If anyone has any suggestions for improvements on this snippet, I'd appreciate it: https://play.crystal-lang.org/#/r/bky9
George Dietrich
@Blacksmoke16
you can just do property x : Float64, y : Float64
save you 2 lines :p
mfiano
@mjfiano:matrix.org
[m]
Oh thanks
I just found what I think is a very minor compiler bug
George Dietrich
@Blacksmoke16
oh?
mfiano
@mjfiano:matrix.org
[m]
I tried to see if I could overload == instead of =~, and the error message says I'm trying to define a setter with more than 1 parameter. I know why this is the case, but maybe a special-cased error for arity-overloading == should exist
George Dietrich
@Blacksmoke16
pretty sure thats moreso an accepted limitation
mfiano
@mjfiano:matrix.org
[m]
Odd
I would expect <, > to be symmetrical with <=, <=.
err <=, >=
George Dietrich
@Blacksmoke16
right, hence the bug :p
which would be more likely to make the others only 1 arg as well
mfiano
@mjfiano:matrix.org
[m]
Has a stropping feature been shut down yet, like Nim?
George Dietrich
@Blacksmoke16
hm?
mfiano
@mjfiano:matrix.org
[m]
Stropping lets the user re-use reserved keywords in a different context, usually by escaping the symbol in some way. In Nim for example, you can define an == function by wrapping it in backticks
George Dietrich
@Blacksmoke16
ah no, the Crystal way would use a diff word
mfiano
@mjfiano:matrix.org
[m]
Ah k
mfiano
@mjfiano:matrix.org
[m]
I suppose I would have to manually define my property methods if I were to use a static array as storage and I wanted to map those x, y names to indices?
George Dietrich
@Blacksmoke16
im pretty sure that offers no benefit over a struct with getters
mfiano
@mjfiano:matrix.org
[m]
I'm using a class, and for different vector lengths, and especially matrices, it'd allow me to write iteration macros to define a lot of routines for all shapes simultaneously
George Dietrich
@Blacksmoke16
you meant to use a static array as a property within the class?
mean*
mfiano
@mjfiano:matrix.org
[m]
Yep
George Dietrich
@Blacksmoke16
cant you also just store a struct in the class?
be easier than knowing what index is what
mfiano
@mjfiano:matrix.org
[m]
Are you familiar with GLSL?
George Dietrich
@Blacksmoke16
nope
oprypin
@oprypin:matrix.org
[m]
mfiano: what's your question
mfiano
@mjfiano:matrix.org
[m]
I want to implement "swizzling", with a macro. That means, for a 2-dimensional vector that has an X and Y property, a macro would generate permutations of the accessors: x, y, xx, yy, yx
I have done such in Nim before. Just trying to figure out the best way with Crystal
oprypin
@oprypin:matrix.org
[m]
mfiano: well if your question can be more generally rephrased as "generate GLSL at compile time", here you go: https://gist.github.com/ba18db84e5e55ddc6d07a661062ae186
mfiano
@mjfiano:matrix.org
[m]
No no
oprypin
@oprypin:matrix.org
[m]
but like... why doesnt it solve your problem
mfiano
@mjfiano:matrix.org
[m]
This is not for generating GLSL in any way. It is for CPU computations. I was just pointing at the feature in GLSL
oprypin
@oprypin:matrix.org
[m]
mfiano: ok nevermind. then you can just use macros, yeah
i would suggest to still use a struct as storage, not a static array
mfiano
@mjfiano:matrix.org
[m]
I would like to use classes, containing an array, in order to support chained methods (mutations that return self)
pass by value would prevent that
George Dietrich
@Blacksmoke16
static arrays are also pass by value
mfiano
@mjfiano:matrix.org
[m]
Right, but I wouldn't be returning them
George Dietrich
@Blacksmoke16
so then just use a struct within the class and return self as you would?
oprypin
@oprypin:matrix.org
[m]
you can use classes but they're too heavy if you want to store many vectors
methods on structs can be chained but they're always by-copy, that is true
mfiano
@mjfiano:matrix.org
[m]
Yeah, I want the user-facing type to be a class for this reason. The storage is up for debate
internal storage*
mfiano
@mjfiano:matrix.org
[m]
oprypin: Are you a game developer? Your github looks interesting