Skip to content

Declare deprecated aliases#521

Open
jackfirth wants to merge 2 commits into
racket:masterfrom
jackfirth:deprecated-alias
Open

Declare deprecated aliases#521
jackfirth wants to merge 2 commits into
racket:masterfrom
jackfirth:deprecated-alias

Conversation

@jackfirth

@jackfirth jackfirth commented Jun 28, 2025

Copy link
Copy Markdown
Contributor

This will allow Resyntax to replace uses of these legacy forms with their modern names.

This wasn't actually used, and now it conflicts with the deprecated alias definition.

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Resyntax analyzed 4 files in this pull request and has added suggestions.

aux-elem
code-inset)
(provide/contract [filebox (((or/c core:element? string?)) () #:rest (listof pre-flow?) . ->* . block?)])

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

arrow-contract-with-rest-to-arrow-contract-with-ellipses: This ->* contract can be rewritten using -> with ellipses.

Suggested change
[filebox (-> (or/c core:element? string?) pre-flow? ... block?)]))
Debugging details
Textual replacement
(line-replacement
  #:new-lines
    '#("          [filebox (-> (or/c core:element? string?) pre-flow? ... block?)]))")
  #:original-lines
    '#("          [filebox (((or/c core:element? string?)) () #:rest (listof pre-flow?) . ->* . block?)]))")
  #:start-line 27)
Syntactic replacement
(syntax-replacement
  #:introduction-scope #<procedure:...and/syntax-local.rkt:148:2>
  #:new-syntax
    #<syntax:/home/runner/.local/share/racket/8.17.0.6/pkgs/resyntax/default-recommendations/contract-shortcuts.rkt:58:2 (-> (or/c core:element? string?) pre-flow? ... block?)>
  #:original-syntax
    #<syntax:scribble-lib/scribble/private/manual-style.rkt:27:19 (->* ((or/c core:element? string?)) () #:rest (listof pre-flow?) block?)>
  #:source
    (file-source
     #<path:/home/runner/work/scribble/scribble/scribble-lib/scribble/private/manual-style.rkt>))

@mflatt

mflatt commented Jun 30, 2025

Copy link
Copy Markdown
Member

I think this needs to be updated for a change to define-deprecated-alias, which now requires that racketblock is defined before schemeblock is defined as an alias, for example.

@jackfirth

Copy link
Copy Markdown
Contributor Author

Hmm. Is there a way for define-deprecated-alias to raise an error if the target is unbound in the surrounding module or definition context and not require the target be bound before the define-deprecated-alias form? That would be the friendliest API for users.

@mflatt

mflatt commented Jul 1, 2025

Copy link
Copy Markdown
Member

You could use syntax-local-lift-module-end-declaration when expanding within a module (i.e., when syntax-transforming-module-expression? returns true).

@jackfirth

Copy link
Copy Markdown
Contributor Author

Is there any way to achieve the same thing in an internal definition context?

@mflatt

mflatt commented Jul 2, 2025

Copy link
Copy Markdown
Member

Do you mean an internal definition context that's in a module? Using syntax-local-lift-module-end-declaration should do the right thing when lifting a reference that happens to be in a definition context, as long as that definition context is also in a module as illustrated below. But maybe I don't understand what you're after.

#lang racket

(define-syntax (check-later stx)
  (syntax-case stx ()
    [(_ id)
     (when (syntax-transforming-module-expression?)
       (syntax-local-lift-module-end-declaration #'(check-now id)))
     #'(void)]))

(define-syntax (check-now stx)
  (syntax-case stx ()
    [(_ id)
     (unless (identifier-binding #'id)
       (raise-syntax-error #f "not good" #'id))
     #'(void)]))

(let ([ok "ok"])
  (check-later ok))

(let ()
  (check-later ok)
  (define ok "ok")
  (void))

(let ()
  (define something-else 0)
  (check-later ok-too))

(define ok-too 10)

@jackfirth

Copy link
Copy Markdown
Contributor Author

I drafted racket/racket#5289 to clarify what I'd like to work. I think syntax-local-lift-module-end-declaration will work correctly for the test cases I wrote, but I haven't tried it yet.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants