Comments (2)
Cross-reference with the first point of #23
from rhombus-prototype.
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)
- Repetitions in method calls HOT 1
- The result of `#:improve-repetition-constraints` can lead to malformed patterns
- More general use of `who` in definitions HOT 1
- Surprising behavior of literal bindings when `case` expansion applies HOT 6
- Evaluation of subexpressions in `Any.of` HOT 2
- Weird interaction of namespace extension and import HOT 2
- Dark theme hides commented colons HOT 2
- Tracker for potential small additions
- Should multiple-value static infos live under a key? HOT 1
- Is `export` in `meta` supposed to work?
- `super` outside of a class uses wrong syntax object for error
- identifiers with dots in them HOT 4
- Module-path operators confuse Check Syntax
- `values` reducer incorerctly propagates initial-value static info HOT 3
- Improve static error for incorrect arities of subclass constructors HOT 1
- Some use of `Group` leads to “syntax class incompatible with this context”
- Alts after extra-indented blocks
- Not all macro options are allowed in pre-alts block position
- Scope pruning in Rhombus blocks
- arity error in annot.macro implementation HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from rhombus-prototype.