Giter Club home page Giter Club logo

Comments (2)

AlexKnauth avatar AlexKnauth commented on May 25, 2024

Cross-reference with the first point of #23

from rhombus-prototype.

rocketnia avatar rocketnia commented on May 25, 2024

I think the exact wording of the wiki entry was "Change match to recognize clauses based on bindings instead of symbols, and make it treat else like cond." Am I right to understand this to mean using free-identifier=? rather than symbol=? for built-in pattern operators?

I think making match "properly hygienic" is a more ambitious goal than that -- a goal that would make sense for Racket 2, which is why I'm bothering to split these hairs. :)

It's true that changing match to use free-identifier=? would make match more hygienic in a way, just because it would mean people could opt not to import any of the special-cased identifiers.

But I think checking things with free-identifier=? is still rather unhygienic. From free-identifier=? we can be tempted to conclude that two identifiers have the same meaning -- e.g. refer to the same module binding. But since several Racket DSLs do free-identifier=? or symbol=? checks to interpret identifiers in DSL-specific ways, an identifier might be intended to be interpreted in one of those other ways, thus making its intended meaning different from that of another identifier that's free-identifier=? to it.

At a conceptual level, I'd say the act of recognizing an identifier and interpreting it in another way is an act of binding. In this sense several Racket DSLs, including match, effectively use free-identifier=? or symbol=? checks to do a kind of anaphoric binding. One could imagine redesigning some of them so they take additional user-supplied identifiers and check things against them with bound-identifier=? so that the bindings are explicit and hygienic. This would tend to make things like match very inconvenient to use, since they'd have so many explicit bindings to write out, so it's mostly a thought experiment.

I think there's a much better way to embrace hygiene of the same caliber, which is to make it so the bindings are already in scope. Instead of having DSLs check for things using free-identifier=? or symbol=?, they'd check for them using syntax-local-value.

In the case of match, that could be achieved if all the basic match operations were defined as match expanders in the first place. When a user followed a documentation hyperlink to and, expecting to see its match expander meaning, they'd actually find it.

But the meaning of and as a match expander and the meaning of and as a syntax transformer are wildly different. If match were a highly experimental DSL that wasn't part of the main distribution, its authors might not even want the main and documentation to be cluttered up with a paragraph for their obscure DSL.

An approach I think Racket could take here is to become sort of a Lisp-(N*M).

It's already a Lisp-N. An identifier can be shifted to different phase levels (syntax-shift-phase-level) to refer to different bindings.

Imagine if in addition to phase levels, there were multiple DSL-spaces per phase level. Then a DSL like match could shift its special expressions into that phase to make use of bindings that didn't interfere with the main expression language. Users could import several completely unrelated meanings of and for different DSLs, just like they can already import several unrelated bindings for-meta at different phase levels.

Getting off topic a little, perhaps multiple entire module languages could be used in combination with each other by importing them carefully into different DSL-spaces and using explicit transitions between them. :)

from rhombus-prototype.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.