-
-
Notifications
You must be signed in to change notification settings - Fork 648
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add match-λ[*][*]
.
#4989
The head ref may contain hidden characters: "\u03BB"
Add match-λ[*][*]
.
#4989
Conversation
match-define match-define-values | ||
match-letrec match-letrec-values | ||
match/values match/derived match*/derived match-define-values |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the original code, match-define-values
is provided twice.
@@ -200,6 +200,8 @@ | |||
(rename new-prop:procedure prop:procedure) | |||
(rename #%app #%plain-app) | |||
(rename lambda #%plain-lambda) | |||
(rename λ #%plain-λ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure if it should be (rename λ #%plain-λ)
or (rename lambda #%plain-λ)
.
@@ -200,6 +200,8 @@ | |||
(rename new-prop:procedure prop:procedure) | |||
(rename #%app #%plain-app) | |||
(rename lambda #%plain-lambda) | |||
(rename λ #%plain-λ) | |||
(rename case-lambda case-λ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure if case-λ
should be defined in '#%kernel
. I don't know how to add operators in '#%kernel
, so I rename case-lambda
to case-λ
in pre-base.rkt
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changes to match-λ[*][*]
is nice.
I really doubt that #%plain-λ
is a good idea. No one will use #%plain-lambda
anyway, since it's inferior than the regular lambda
. It's only used inside the Racket internals, and also when people want to pattern match against expanded code. But in those two cases, #%plain-λ
won't have much value.
My personal opinion is that this PR should be restricted to only changes in match
-related form.
@@ -331,8 +331,9 @@ | |||
(append | |||
(kernel-form-identifier-list) | |||
(list | |||
(quote-syntax #%app) ; racket/base app, as opposed to #%plain-app | |||
(quote-syntax #%app) ; racket/base #%app, as opposed to #%plain-app |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please revert all changes to this file. free-identifier=?
already takes renaming into account. There's no need to test against another renamed form.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This file already handles similar processes for λ
, as seen in: (or (free-identifier=? #'lam #'lambda) (free-identifier=? #'lam #'λ))
. I assumed the relationship between lambda
and λ
was similar to that between case-lambda
and case-λ
, which is why I treated #%plain-λ
and case-λ
in the same manner. If supporting case-λ
is considered, do we still need to revert all changes to this file?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If case-λ
is created via the renaming mechanism, then free-identifier=?
will work fine on it. So yes, you should still revert all changes to this file.
Apparently λ
is not created via the renaming mechanism from lambda
, so that's why only one free-identifier=?
would not suffice.
#lang racket
(module sub racket
(provide my-case-lambda
(rename-out [my-case-lambda my-case-λ]))
(define my-case-lambda 1))
(require syntax/parse/define
'sub)
(define-syntax-parse-rule (test a b)
#:do [(println (free-identifier=? #'a #'b))]
(void))
(test my-case-lambda my-case-λ) ;=> #t
(test lambda λ) ;=> #f
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I read the code, and if I understand correctly, lambda
and λ
in racket/base
are respectively new-lambda
and new-λ
in kw.rkt
:
(define-syntaxes (new-lambda new-λ)
(let ([new-lambda ...])
(values new-lambda new-lambda)))
Is it necessary to create a new PR and define new-λ
through the renaming mechanism?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For any big change like this (including this PR actually), I think it makes sense to get preliminary feedback from https://racket.discourse.group/ first. For example, it could be that people are somehow relying on lambda
and λ
not being free-identifier=?
for some reasons, and the change would break their code.
But I agree that ideally lambda
should be free-identifier=?
to λ
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems unlikely that changing how lambda
and λ
are bound is going to work but before a discussion, just checking to see if racket (and a bunch of packages, maybe starting with main-distribution) builds would be informative.
Initially, I added the λ forms based on search results for
|
This pull request has been mentioned on Racket Discourse. There might be relevant details there: https://racket.discourse.group/t/adding-more-unicode-forms-to-racket/2911/1 |
This pull request has been mentioned on Racket Discourse. There might be relevant details there: https://racket.discourse.group/t/renaming-mechanism-for-unicode-in-racket/2910/3 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this will be ready after adding history
notes to the documentation. You could also squash the commits, or I can squash when merging. Thanks!
Checklist
Description of change
This PR introduces Unicode variants of common lambda forms in Racket. A previous PR #1301 suggested similar changes but was closed. This PR revives that idea.