-
Notifications
You must be signed in to change notification settings - Fork 4
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
don't attempt to typeset code if the syntax object is not original #10
base: master
Are you sure you want to change the base?
Conversation
I don't think this is the right change. Just dropping the form like this doesn't seem right to me. It also depends on how most languages operate with what they output in the reader:
I don't know how many My idea for this would be to either modify |
Re: 1 and 3, I agree. Re: 2, I would say there is no need to try to support such a language. It's possible (and maybe even likely) that I'm missing something here, but I don't think 1 and 3 are solvable in the general case. You have to either make assumptions about the #lang in question, or else you need way more input from the caller. Consider a stack-based arithmetic language (idea borrowed from Beautiful Racket). Say the original source code is
(No expansion is required, this will run directly out of the reader.) The desired output of
Or is it? Maybe the desired output is
Let's just assume that the first output is what we want. We are still in trouble if the lang does not help us out with the syntax-original property. How do we know that And a final problem, say this lang does use the syntax-original property but the property is set on |
That makes me think of a worse possible example: (module stacker-mod racket
(define args '())
(define (handle x)
(if (procedure? x)
(let ([result (x (car args)
(cadr args))])
(set! args (cons result (cddr args)))
result)
(set! args (cons x args))))
(custom-begin
(handle 1)
(handle 2)
(handle +)
(handle 100)
(handle *))) How would it distinguish the By the way, one of the reasons I'm thinking about custom begin forms like this is that some of the languages I want to be able to use this with, such as |
Thinking more about this, one possibility is to require the language to have REPL support. Then require the caller to pass each REPL interaction individually. For example
Would set up the REPL for the language and then each string of code would get read, evaluated, and typeset individually. This removes all ambiguity (I think), but obviously puts more burden on the caller. (Edit: or if the language doesn't have a REPL, allow the caller to provide a REPL-like function that takes a string and produces a syntax object.) |
No description provided.