[HN Gopher] Unhygienic and referentially opaque macros with Sche...
       ___________________________________________________________________
        
       Unhygienic and referentially opaque macros with Scheme syntax-rules
       [pdf] (2013)
        
       Author : fanf2
       Score  : 23 points
       Date   : 2024-08-16 22:59 UTC (5 days ago)
        
 (HTM) web link (okmij.org)
 (TXT) w3m dump (okmij.org)
        
       | bjoli wrote:
       | One might think this is just pointless, but I have actually seen
       | (and written) macros using techniques by Oleg. Alex Shinn (of
       | Chibi scheme fame) has mastered them all I think.
        
         | zelphirkalt wrote:
         | I used his CK macro intro/explanation to write a function
         | contracts library. Really great how it manages a stack on the
         | macro level to change the order of expansion and making macros
         | more composable. Surely I would not have gone looking at the
         | papers it is based on, so his page acted as a gateway for me.
        
       | neilv wrote:
       | When I got into Scheme, Oleg Kiselyov would occasionally post to
       | Usenet comp.lang.scheme with some new discovery or insight, or
       | neat software library that showed Scheme as a serious language
       | rather than purely academic (e.g., SSAX).
       | 
       | If you're reading this paper, but haven't used Scheme much yet,
       | three things to be aware of:
       | 
       | 1. `syntax-rules` is nice, but there's much more powerful and
       | easier to use constructs now, like `syntax-case` and Racket's
       | `syntax-parse`.
       | 
       | 2. When you see Oleg doing something like breaking `syntax-
       | rules`, I think it's usually _not_ like a pitfall of C or C++
       | that anyone could make inadvertently, and more like you probably
       | have to be as knowledgeable and clever as Oleg to break it this
       | way. It 's more something to come back to, after you've already
       | learned to use these very nice and powerful tools, so you can
       | appreciate it, and not just get confused or scared.
       | 
       | 3. Some of Oleg's Scheme software has been repackaged to make it
       | easier to use. For example: https://docs.racket-lang.org/sxml/
       | (Also, Oleg's SXML became a de facto standard for representing
       | XML and HTML in Scheme, and some of us have tried to make other
       | tools compatible: https://docs.racket-lang.org/sxml-
       | intro/#%28part._.Tools%29 )
        
         | ashton314 wrote:
         | > `syntax-rules` is nice, but there's much more powerful and
         | easier to use constructs now, like `syntax-case` and Racket's
         | `syntax-parse`.
         | 
         | `syntax-parse` is the best! I wrote up some notes [1] while
         | trying to figure out the differences between `syntax-case` and
         | `syntax-parse` a year ago. Not the best notes, but there are
         | some examples.
         | 
         | Racket solves the hygiene problem well with _scope sets_ : each
         | identifier gets tagged with the _set_ of scopes it appears in.
         | There 's a blog post [2] by Matthew Flatt of Racket fame
         | describing how Racket's scope system works. Thanks to scope
         | sets, I'm not sure this inadvertent variable capture would be a
         | problem.
         | 
         | [1]: https://lambdaland.org/posts/2023-05-19_racket_macros/
         | [2]: https://users.cs.utah.edu/plt/scope-sets/
        
           | DonaldPShimoda wrote:
           | > There's a blog post by Matthew Flatt of Racket fame
           | describing how Racket's scope system works.
           | 
           | For clarity, I would specify that Matthew is the lone
           | conceiver and implementer of the original sets-of-scopes
           | system, as evidenced by him being the only author on the
           | corresponding paper "Binding as Sets of Scopes" (POPL '16,
           | DOI: https://doi.org/10.1145/2914770.2837620). So the blog
           | post isn't just "some well-known Racket guy explaining a
           | Racket thing", but rather "the guy who invented the thing
           | explaining the thing".
           | 
           | The paper has a corresponding talk as well:
           | https://youtu.be/rs27lkgq3Og. (And, in fact, Matthew has
           | given the talk on more than a few occasions at various
           | venues, so there are other recordings available as well.)
        
         | zelphirkalt wrote:
         | Some things I learned from his website took me weeks to
         | annotate and understand partially, some things, that are a
         | short demo he probably had a crack on for an afternoon still
         | can take days to actually properly understand. This guy's
         | output is so impressive!
        
       | JadeNB wrote:
       | "Seemingly" in the title of the article seems important (since
       | the point seems to be to debunk, in the terminology of the
       | abstract, "folklore notions of hygiene and referential
       | transparency"); why was it stripped?
        
         | mepian wrote:
         | Maybe it didn't fit HN's title character limit?
        
       ___________________________________________________________________
       (page generated 2024-08-21 23:00 UTC)