AlexKnauth / afl

a racket lang-extension for rackjure-like anonymous function literals
MIT License
6 stars 2 forks source link

Unhygienic variant? #2

Open SuzanneSoy opened 7 years ago

SuzanneSoy commented 7 years ago

Hello!

I'm using afl with typed/racket and my type-expander library.

The type-expander library works by overriding define, lambda and so on. Due to afl's hygiene, #λ(…) expands to a use or lambda from racket/base, not the intended lambda from the type-expander library. Fortunately, since there are no argument or return types to expand within #λ(…), the difference does not matter, but I suppose that in other cases it could matter.

Would it make sense to also have an unhygienic version of afl directly within this package?


I needed a unhygienic version, to circumvent an incompatibility between afl and a modified version of scribble/lp2 that I use, the incompatibility is most likely on my side, but on the short term dropping hygiene seemed to do the trick, and I'll get back to my issue later. I have therefore already created the aful package, which provides #lang aful (exactly the same as afl) and #lang aful/unhygienic (unhygienic version).

If you think it's best to merge these changes in here, then I can open a PR, otherwise I can leave aful as a separate package. You can see the changes here https://github.com/AlexKnauth/afl/compare/master...jsmaniac:unhygienic if you want (this diff also includes some changes to render correctly when it appears in scribble documents, using a patched version of scribble).

Regards, Georges Dupéron

AlexKnauth commented 7 years ago

I don't think you really want an unhygienic version. Would it be better if you could specify which lambda identifier it used?

SuzanneSoy commented 7 years ago

In most cases, this would be sufficient.

However, there can be submodules with different languages (as an example, the scribble/lp2 program below). If the lambda identifier to use can be specified via a for-syntax parameter or something like that, which takes effect only within the module, then it should be fine. There would still be issues if it is specified for the whole file, e.g. with #lang afl #:lambda-from racket/base mylang.

#lang afl scribble/lp2

@; => lambda from racket/base, as we are executing scribble code:
@(apply itemlist (map #λ(item "Hello" % "!") (range 5)))

@chunk[<*>
       (module main type-expander/lang
         ;; => lambda from type-expander
         (#λ(cons 0 %) '(1 2 3)))]
AlexKnauth commented 7 years ago

Okay. Now I see an unhygienic version does make sense as an opt-in.