Another option, which probably has a lot of terrible consequences, is to
transform "a.b" into "3-d syntax" (a struct embedded in syntax) that can
now be interpreted differently by forms that are interested. For instance a
custom "define" could grab the 3d-syntax in the name and use it to make a
decision on what to actually define (or raise an error). In an expression
context, #%datum could see this syntax and transform it into some sort of
binding looking or other syntax (e.g. (#%dot a b)), which could then be
resolved in the typical way.
This approach probably wouldn't work very well because a lot of syntax
transformers don't expect to see 3-d syntax. In fact sometimes 3-d syntax
is rejected before being made into a syntax object. If you can get this to
work I will be pretty impressed.
On Tuesday, December 11, 2018 at 11:15:10 PM UTC-8, Ryan Kramer wrote:
>
> Thanks for your response Alexis. You are right: once I figured out the
> correct way to customize the reader, the rest fell into place much more
> easily. Now, when my reader sees a dot it asks the base reader to read
> another piece of syntax, which must be an identifier.
>
> So (define a.b 3) becomes (define a .b 3) and the default error message is
> good enough for now, especially since Racket prints out the 2nd version
> with the error message.
>
> Also, I realized what a bad idea rewriting "a+b" to (+ a b) is. Because
> then I should do the same for subtraction. And then, for example,
> "struct-info" becomes (- struct info) which is a death sentence for a
> language based on Racket. So now infix notation requires whitespace around
> the operator.
>
> For those curious "what are you really trying to do anyway?" I really like
> how at-exp can attach a convenient syntax onto racket without interfering
> with your ability to write standard racket. I am trying to do something
> similar. In my language, curly braces will get treated differently than the
> other paren-shapes. For example {if 10 .add1 {.equal? 11} 'yep 'nope} will
> get rewritten to (if (equal? (add1 10) 11) 'yep 'nope). My hope is that
> experienced Racketeers will find it convenient when they want to use it,
> and unintrusive when they don't. And that beginners who would be scared off
> by raw s-expressions will find it familiar enough to be pleasant.
>
--
You received this message because you are subscribed to the Google Groups
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.