News for hackers. Stuff that matters.
Re:Racket 7.3 by nerdponx on Thursday May 16, 2019 @01:57AM (#19926522)
And yet I'm still too stupid to understand the macro system. Oh well.

I also didn't know there was a Chez version. Racket already has a native AOT compiler, right? What would the advantage be to run on Chez, faster or smaller compiled code?

Re:Racket 7.3 by jim-jim-jim on Thursday May 16, 2019 @02:31AM (#19926681)
Is it the general Scheme syntax-rules macros that you're struggling with? Or something unique to Racket? (which I haven't used)

If it's the former, I found this little article helpful when I was new to Scheme:

http://www.willdonnelly.net/blog/scheme-syntax-rules/

Re:Racket 7.3 by tgbugs on Thursday May 16, 2019 @03:41AM (#19926952)
For Racket specific macro tooling syntax-parse [0] in combination with syntax classes is usually the suggested starting point. Hygenic with pattern matching and a bunch of other features for parsing s-expression grammars. As mentioned down-thread Greg Hendershott's Fear of Macros [1] is a good starting point for a number of folks. The curriculum for Racket School 2018 [2] also has exercises that help introduce the syntax-parse tooling.

0. https://docs.racket-lang.org/syntax/Parsing_Syntax.html 1. https://www.greghendershott.com/fear-of-macros/ 2. https://summer-school.racket-lang.org/2018/plan/

Re:Racket 7.3 by xabush on Thursday May 16, 2019 @03:52AM (#19926993)
This is great tutorial. I used to be confused by the macros in scheme
Re:Racket 7.3 by gus_massa on Thursday May 16, 2019 @09:40AM (#19928925)
For the macros, I prefer to recommend to start with very straightforward macros that use `define-syntax-rule`. For example

  #lang racket
  
  (define-syntax-rule (run3times code ...)
    (begin
      (begin code ...)
      (begin code ...)
      (begin code ...)))
  
  (define x 0)
  
  (run3times
    (set! x (add1 x))
    (display x))      ; shows ==> 123
As other comment said, you have to find some good opportunity to use a simple macro.

(In this case, it is better to use the build-in `for`. Actually, `for` is defined in a macro, it is not part of the internal "secret" low level language.)

Once you are confident and you grok the difference between a macro and a function, you can try the other ways to define macros. These other ways are more flexible and can make weirder macros, and have better support when the macro is used wrongly. There are good links in the sibling comments.

Re:Racket 7.3 by swdunlop on Thursday May 16, 2019 @02:13AM (#19926587)
See http://blog.racket-lang.org/2019/01/racket-on-chez-status.ht... and scroll down to “Performance of Compiled Code.” That was back in January, so things may be even better now.
Re:Racket 7.3 by darkpuma on Thursday May 16, 2019 @03:11AM (#19926831)
Re:Racket 7.3 by Bogdanp on Thursday May 16, 2019 @06:04AM (#19927597)
> And yet I'm still too stupid to understand the macro system. Oh well.

This talk[0] by Robby Findler helped me a ton when I was first learning about macros in Racket. I've found that the best way to learn, though, is by doing: when you find a use case for a macro, figure out how to do that particular thing and, slowly but surely, things will start to click.

[0]: https://www.youtube.com/watch?v=hFlIl0Zo234

Re:Racket 7.3 by pjmlp on Thursday May 16, 2019 @02:34AM (#19926690)
Getting rid of C dependency and bootstrap Racket in Scheme.
Re:Racket 7.3 by GeoffKnauth on Thursday May 16, 2019 @11:39AM (#19929990)
Another way to learn about all this stuff from the experts themselves is Racket School: https://school.racket-lang.org/
Re:Racket 7.3 by pyb on Thursday May 16, 2019 @04:01AM (#19927037)
A few people exist who are genuinely able to use Racket macros, but they all have a PhD in CS.

As opposed to the larger group who think they understand them. I was once in that group, but now I've just given up.

Re:Racket 7.3 by NikkiA on Thursday May 16, 2019 @11:49AM (#19930078)
Racket's macro transformers are about as easy as hygenic macros[0] get unfortunately, I can occasionally manage to make a er-macro-transformer based macro in chicken work how I want.

defmacro was a lot easier, but I understand the aversion to it, even if it was rare that it was/is a problem.

[0] syntax-rules based macros are cake, naturally, but they're also incredibly limited, although I have seen people implement massive complex OO systems using a sort of ad-hoc state machine built in pages upon pages of syntax-rules rules.