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

[question][3.1]having difficult time understanding define-syntax? #36

Open
jsomedon opened this issue Mar 24, 2020 · 0 comments
Open

[question][3.1]having difficult time understanding define-syntax? #36

jsomedon opened this issue Mar 24, 2020 · 0 comments

Comments

@jsomedon
Copy link

jsomedon commented Mar 24, 2020

First of all, thanks for making this! :-)

So on 3.1 where it talks about define-syntax with example:

(define-syntax foo
    (lambda (stx)
        (syntax "I am foo")))

it explains that:

When we use define-syntax, we’re making a transformer binding. This tells the Racket compiler, "Whenever you encounter a chunk of syntax starting with foo, please give it to my transformer function, and replace it with the syntax I give back to you." So Racket will give anything that looks like (foo ...) to our function, and we can return new syntax to use instead. Much like a search-and-replace.

My questions:

What does it mean that "a syntax starting with foo"? What is a syntax? Do you mean the syntax object that is introduced on section 3.2, that's something with lexical environment and code location and s-expression etc? Or is that some other conceptual thing or is that a specific language construct? If the syntax mentioned here here is the syntax object that's mentioned in 3.2, then what could a chunk of syntax mean here? It reads more like a piece of textual code then a set of language constructs(which is syntax object).. So I am not really sure what exactly the syntax mean here.

I am not sure what makes define-syntax different here either? But I guess once I get what syntax mean here then define-syntax makes some sense too?

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

1 participant