Confusing behavior when a binding form is also an expression
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 2/5
- Tiempo estimado
- 1-3 horas
- Aptitud para principiantes
- 45/100
- Tipo de issue
- Documentación
- Claridad
- Bien especificado
- Estado de actividad
- Estancado
- Área
- documentation
Línea de trabajo
Comienza con el ejemplo de lc-bind+patterns de la documentación y compara su uso de list y listp con el ejemplo de LCP reportado. Añade una explicación concisa de que Redex distingue sintácticamente entre vinculaciones y usos, y considera completa la documentación cuando este comportamiento y el motivo de las formas distintas estén claros para los lectores.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
I was confused by some behavior when working on a test case for the issue I opened yesterday. I formulated a simple lambda-calculus language with pattern-matching on tuples (shown below). It is essentially the same as the lc-bind+patterns example in the docs, except I used tuple where lc-bind+patterns uses list and listp not understanding the importance of that distinction.
What I've inferred is that having a binding form (that is, something with a #:exports clause) that also looks like an expression is trouble. Identifiers that look like uses will be interpreted as bindings.
I don't think this behavior is itself an issue, but I could see it tripping up another person like me that tries to use the same syntax for both pattens and expressions. Pointing the behavior out in the documentation would have helped me; maybe a sentence like
"Variable uses and bindings must always be distinguished syntactically, which is why we use list and listp instead of just list."
or
"Redex determines whether an identifier is a binding or a use syntactically; as a consequence, if a form may contain both types of variables some form of distinguishing syntax must be used. Here, we use list and listp to mark that when an identifier appears in an expression (signified by list) it is a reference, while when it appears in a pattern (listp) it is a binding."
would do the trick?
#lang racket
(require redex)
(define-language LCP
(M (M M) X (λ P M) (tuple M ...) b)
(b number)
(V (λ P M) b (tuple V ...))
(X variable-not-otherwise-mentioned)
(P X b (tuple P ...))
(E hole (E M) (V E) (tuple V ... E M ...))
(ρ ([X V] ...))
(⊥ bot)
#:binding-forms
(tuple P ...) #:exports (shadow P ...)
(λ P M #:refers-to P))
(define ->
(reduction-relation
LCP
(==> ((λ P M) V)
(subst-all ρ M)
(where ρ (match P V)))
with
[(--> (in-hole E x) (in-hole E y))
(==> x y)]))
(define-metafunction LCP
match : P V -> ρ or ⊥
[(match b b) ()]
[(match X V) ([X V])]
[(match (tuple P ..._1) (tuple V ..._1))
([X_bind V_bind] ... ...)
(where (([X_bind V_bind] ...) ...) ((match P V) ...))]
[(match P V) bot])
(define-metafunction LCP
subst-all : ρ M -> M
[(subst-all () M) M]
[(subst-all ([X_0 V_0] [X_1 V_1] ...) M)
(subst-all ([X_1 V_1] ...) (substitute M X_0 V_0))])
(define-term t
(λ (tuple x 2)
(tuple x x)))
(term (substitute t x hello) #:lang LCP)
;; => '(λ (tuple x«0» 2) (tuple x«1» x«2»))
- Lenguaje dominante
- Racket
- Estrellas
- 114
- Forks
- 42
- Métricas de merge de PR
- Sin PR fusionados en 30 d
Preparar el entorno
Este proyecto no incluye contenedor de desarrollo, Dockerfile ni guía de contribución, así que la configuración corre por tu cuenta: empieza por su README y consulta nuestra guía para la primera contribución para los pasos generales.
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de racket/redex
-
Dificultad 3/5 1-2 días Aptitud para principiantes 55/100
-
Dificultad 4/5 3-5 días Aptitud para principiantes 35/100
-
Dificultad 4/5 3-5 días Aptitud para principiantes 38/100
-
Dificultad 4/5 3-5 días Aptitud para principiantes 32/100
-
Dificultad 4/5 3-5 días Aptitud para principiantes 35/100
Todos los issues de racket/redex
Issues similares
-
agent-research agent-review-finding chore
Dificultad 2/5 1-3 horas Aptitud para principiantes 66/100
jordansmall/spindrift#4922 ·
Los mantenedores suelen responder en 1 día
-
docs(types): update the collection binding note now that typed collections shipped in pycubrid 1.9.0Abiertodocumentation priority: low size: S
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
cubrid-lab/sqlalchemy-cubrid#768 ·
Los mantenedores suelen responder en 1 día
-
Broken link in index.rstAbiertodocumentation
Dificultad 1/5 Menos de una hora Aptitud para principiantes 65/100
ansys/pydpf-core#3547 ·
Los mantenedores suelen responder en 1 día
-
documentation good first issue
Dificultad 2/5 1-3 horas Aptitud para principiantes 70/100
OktoLabsAI/okto-pulse#113 ·
Los mantenedores suelen responder en 1 día
-
Messenger
Dificultad 2/5 1-3 horas Aptitud para principiantes 62/100
symfony/symfony-docs#23237 ·
Los mantenedores suelen responder en 3 días