Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
    pintobeansnjelly
    @pintobeansnjelly:matrix.org
    [m]
    What do you guys use to check if you made any leaks? valgrind tools? Havent done anything like that in a long time
    Veit Heller
    @hellerve
    clang has a flag for address sanitization these days
    -fsanitize=address, which offers part of the functionality of valgrind
    on macos i also use the xcode profiler, which works really well
    Scott Olsen
    @scolsen
    +1 to address sanitizer and xcode, on macos you can also use leaks -atExit -- ./a.out or whatever your program name is
    Erik Svedäng
    @eriksvedang:matrix.org
    [m]
    pintobeansnjelly: Yay!!!
    Tim Dévé
    @timdeve:matrix.org
    [m]
    Currently looking around adding varargs variant for common operations (and, or, so on...), with is also quite useful but I feel that it's functionality should be folded into with proper rather than having both with and `with`, what do people think?
    Tim Dévé
    @timdeve:matrix.org
    [m]
    :point_up: Edit: Currently looking around adding varargs variant for common operations (and, or, so on...), with* is also quite useful but I feel that it's functionality should be folded into with proper rather than having both with and with*, what do people think?
    Erik Svedäng
    @eriksvedang:matrix.org
    [m]
    It should probably be with-do
    Tim Dévé
    @timdeve:matrix.org
    [m]

    Not this:

    (with-do Array
      (side-effect)
      (side-effect))

    this:

    (with* Array Int
      (single-form))
    Concrete example:
    (defmacro and* [:rest forms]
      (build-vararg 'and forms))
    
    (defmacro with* [:rest forms]
      (build-vararg 'with forms))
    
    (defn player-colliding? [env-item player delta]
      (with* Rectangle Player EnvItem Vector2
        (let [ppos (pos player)]
          (and* (<= (x (rect env-item)) (x ppos))
                (>= (+ @(x (rect env-item)) @(width (rect env-item))) @(x ppos))
                (>= (y (rect env-item)) (y ppos))
                (<  @(y (rect env-item)) (+ @(y ppos) (* @(speed player) delta)))))))
    I feel given that with is already a command is there much point at having a * variant if we could just make the command behave like that by default?
    Erik Svedäng
    @eriksvedang:matrix.org
    [m]
    Ah, I see what you mean now.
    The thing is that with is a special form, so in that case you'd need to modify it – a macro isn't enough.
    Erik Svedäng
    @eriksvedang:matrix.org
    [m]
    I'm not against the idea though, seems useful.
    Erik Svedäng
    @eriksvedang:matrix.org
    [m]
    And the * syntax seems unnecessary in this case, I think that only makes sense for making proper (static) functions variadic.
    Tim Dévé
    @timdeve:matrix.org
    [m]
    Yeah that's what I thought, I'll make a PR for the others and feature request for with as I don't think I can make the compiler change myself.
    Erik Svedäng
    @eriksvedang:matrix.org
    [m]
    Sounds good!
    rgkirch
    @rgkirch
    @eriksvedang:matrix.org Sorry, did you comment on carp-lang/Carp#1342 I got an email about it including your comment but I don't see where you actually left the comment. I'm confused.
    Erik Svedäng
    @eriksvedang:matrix.org
    [m]
    I realized I read your issue poorly so I deleted my answer, sorry.
    Tim Dévé
    @timdeve:matrix.org
    [m]
    The error is certainly unhelpful here, the compiler seems to be confused about having received a module/type, tried to use it as a init function for the associated type but there is not init for Int.
    width expect a value of type (Ptr a)
    But you gave it a symbol that's not a value
    Erik Svedäng
    @eriksvedang:matrix.org
    [m]
    Yeah the module name expands to the init method
    Tim Dévé
    @timdeve:matrix.org
    [m]
    This would be valid:
    (IO.println &(str (width (address &1))))
    The compiler is trying to be too smart and so the error end up being inferred too far from the actual problem.
    Erik Svedäng: Btw I've not been able to actually use that inferred init feature:
    鲤 (load "Vector.carp")
    鲤 (Vector2 1 1)
    I did not understand the form `(Vector2 1 1)` at REPL:3:2.
    
    Traceback:
      (Vector2 1 1) at REPL:3:1.
    rgkirch
    @rgkirch
    Ok, haha. I felt gaslit. Well, I replied to the ghost comment in a vague enough way so that it didn't seem like I was just talking to myself. lol
    Tim Dévé
    @timdeve:matrix.org
    [m]
    It's kinda tricky in that case because you might actually want to take the width of the init function pointer ^^
    Erik Svedäng
    @eriksvedang:matrix.org
    [m]
    @timdeve does it help if you use Vector2?
    Tim Dévé
    @timdeve:matrix.org
    [m]
    But maybe that init inference could only happen in call position?
    Erik Svedäng: Nope same
    Erik Svedäng
    @eriksvedang:matrix.org
    [m]
    Yeah
    Tim Dévé
    @timdeve:matrix.org
    [m]
    It hasn't worked with any of the type I tried
    Erik Svedäng
    @eriksvedang:matrix.org
    [m]
    Strange, the feature is in the test suite iirc
    Weird, I know I used it just the other day
    Will try again when I’m at the computer
    Tim Dévé
    @timdeve:matrix.org
    [m]
    It definitely seems to work when I run the test ^^
    Think it might be a static vs dynamic confusion
    鲤 (deftype Wow [i Int])
    鲤 (IO.println &(str &(Wow 1)))
    (Wow 1)
    鲤 (Wow 1)
    I did not understand the form `(Wow 1)` at REPL:12:2.
    
    Traceback:
      (Wow 1) at REPL:12:1.
    Erik Svedäng
    @eriksvedang:matrix.org
    [m]
    Aha!
    I’m working on some ideas for making that whole thing more reliable btw. Seems like we get bit by it a little too often...
    Tim Dévé
    @timdeve:matrix.org
    [m]
    This is also doesn't work but only for Rectangle:
               env-items $[(EnvItem (Rectangle 0f   0f   1000f 400f) light-gray)
                           (EnvItem (Rectangle 0f   400f 1000f 200f) gray)
                           (EnvItem (Rectangle 300f 200f 400f  10f)  gray)
                           (EnvItem (Rectangle 250f 300f 100f  10f)  gray)
                           (EnvItem (Rectangle 650f 300f 100f  10f)  gray)]
    Erik Svedäng
    @eriksvedang:matrix.org
    [m]
    Dang it!
    Scott Olsen
    @scolsen
    the evaluator/repl is still missing some cases that it should definitely have. It's pattern matches don't include everything (that's what throws the "I didn't understand" error).
    pintobeansnjelly
    @pintobeansnjelly:matrix.org
    [m]
    Does Carp support keyword parameters?
    Erik Svedäng
    @eriksvedang:matrix.org
    [m]
    No
    Erik Svedäng
    @eriksvedang:matrix.org
    [m]
    It's hard to support with static types. I'd recommend a Map or a custom struct.
    pintobeansnjelly
    @pintobeansnjelly:matrix.org
    [m]
    I made an example of working with FFTW and finding the dominant frequency of a sine wave. https://github.com/jrciii/carp-fftw/blob/main/FFTW.carp
    Erik Svedäng
    @eriksvedang:matrix.org
    [m]
    Fantastic!