Skip to content
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

Is there any way to get the head syntax object? #317

Closed
Syntacticlosure opened this issue Jun 9, 2023 · 2 comments
Closed

Is there any way to get the head syntax object? #317

Syntacticlosure opened this issue Jun 9, 2023 · 2 comments

Comments

@Syntacticlosure
Copy link
Contributor

The head syntax object is useful when writing unhygienic macros, otherwise, I can only find outside scopes from anywhere else.
It seems impossible to get the head syntax object now.

@mflatt
Copy link
Member

mflatt commented Jun 9, 2023

You can declare ~op_stx to get the head term:

#lang rhombus/and_meta

namespace ns:
  export hello
  expr.macro 'hello':
    ~op_stx self
    println("called as " +& self)
    '#void'

import .ns.hello as howdy

howdy

prints "called as howdy"

@Syntacticlosure
Copy link
Contributor Author

thank u.

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

No branches or pull requests

2 participants