add sugar/debug/lang meta-language #5

Merged
AlexKnauth merged 1 commits from debug-meta-lang into master 10 years ago
AlexKnauth commented 10 years ago (Migrated from github.com)
Is this what you meant in the BTW2 of https://github.com/mbutterick/sugar/pull/4#issuecomment-118557611 ?
mbutterick commented 10 years ago (Migrated from github.com)

Looks promising, thanks. I’m going to merge it so that I can try it out and see if it was a good idea ;)

If so, I’ll probably add some more metacharacters before I put it into the documented public interface (suggestions welcome, I just came up with ^ off the top of my head)

Looks promising, thanks. I’m going to merge it so that I can try it out and see if it was a good idea ;) If so, I’ll probably add some more metacharacters before I put it into the documented public interface (suggestions welcome, I just came up with `^` off the top of my head)
mbutterick commented 10 years ago (Migrated from github.com)

Also, thanks for catching those missing provides

Also, thanks for catching those missing `provide`s
mbutterick commented 10 years ago (Migrated from github.com)

Q1. I take it that all syntactic reader extensions have to include #? I.e., #^^42 is mandatory, rather than ^^42?

Q2. Can / should #lang sugar/debug ... imply (require sugar/debug)?

Before:

#lang sugar/debug racket
(require sugar/debug)
#^^42

After:

#lang sugar/debug racket
#^^42
Q1. I take it that all syntactic reader extensions have to include `#`? I.e., `#^^42` is mandatory, rather than `^^42`? Q2. Can / should `#lang sugar/debug ...` imply `(require sugar/debug)`? Before: ``` racket #lang sugar/debug racket (require sugar/debug) #^^42 ``` After: ``` racket #lang sugar/debug racket #^^42 ```
AlexKnauth commented 10 years ago (Migrated from github.com)

Re: Q1: No, that's not it, but I thought it would be less "in the way" of code that could already have, for example ^ defined as expt, or as a suffix for signatures, or similar things.

Re: Q2: It could, but it would be more complicated, and it might require messing up outside references to submodules. My initial experiment on doing that kind of thing is here: docs, source, and that worked, but I had to have the reader.rkt put the main code into a submodule to do it, and that would mess up references to submodules in that main code from outside the module.

Re: Q1: No, that's not it, but I thought it would be less "in the way" of code that could already have, for example `^` defined as `expt`, or as a suffix for signatures, or similar things. Re: Q2: It could, but it would be more complicated, and it might require messing up outside references to submodules. My initial experiment on doing that kind of thing is here: [docs](http://pkg-build.racket-lang.org/doc/dotmethod/index.html#%28part.__lang_dotmethod%29), [source](https://github.com/AlexKnauth/dotmethod/blob/master/dotmethod/lang/reader.rkt), and that worked, but I had to have the `reader.rkt` put the main code into a submodule to do it, and that would mess up references to submodules in that main code from outside the module.
mbutterick commented 10 years ago (Migrated from github.com)

I haven’t forgotten about this. Just thinking about the optimal interface.

I haven’t forgotten about this. Just thinking about the optimal interface.
AlexKnauth commented 10 years ago (Migrated from github.com)

I've been thinking about this too, and since @lexi-lambda tried this (https://github.com/lexi-lambda/racket-curly-fn/blob/master/lang/reader.rkt#L60) for the curly-fn meta-language, I'm wondering if that can be applied to this.

I've been thinking about this too, and since @lexi-lambda tried this (https://github.com/lexi-lambda/racket-curly-fn/blob/master/lang/reader.rkt#L60) for the `curly-fn` meta-language, I'm wondering if that can be applied to this.
AlexKnauth commented 10 years ago (Migrated from github.com)

Re: Q1: Would you really want to change it to ^42 instead of #^42?

Re: Q1: Would you really want to change it to `^42` instead of `#^42`?
mbutterick commented 10 years ago (Migrated from github.com)

Yes. In fact I would endorse a shorthand like ^ for the basic report function, and then use extra chars to denote the other flavors, for instance ^# to add the line number and ^## to add line number and source path. (Maybe ^ isn’t the right char, but # is already used to denote special core Racket constructs within the reader).

Having said that, maybe it should just go ^ , ^^, ^^^.

It would be nice to use a character that’s rare in Racket so that these shorthand marks could be searched. (When debugging, I drop a lot of them so it’s good to have a quick way of cleaning them out.)

Yes. In fact I would endorse a shorthand like `^` for the basic `report` function, and then use extra chars to denote the other flavors, for instance `^#` to add the line number and `^##` to add line number and source path. (Maybe `^` isn’t the right char, but `#` is already used to denote special core Racket constructs within the reader). Having said that, maybe it should just go `^` , `^^`, `^^^`. It would be nice to use a character that’s rare in Racket so that these shorthand marks could be searched. (When debugging, I drop a lot of them so it’s good to have a quick way of cleaning them out.)
AlexKnauth commented 10 years ago (Migrated from github.com)

Re: Q1 and #:
The # character is used for dispatch to other characters, whether they are from the core racket reader or not.

But going back to just Q1, what would a better character be?

Re: Q1 and `#`: The `#` character is used for dispatch to other characters, whether they are from the core racket reader or not. But going back to just Q1, what would a better character be?
mbutterick commented 10 years ago (Migrated from github.com)

I’m coming around to feeling good about ^, because it’s in ASCII, and because Racket uses expt, thus it’s underemployed.

Let’s try that and see how it works. It doesn’t have to go into the public interface yet.

^= report
^^= report/line
^^^= report/file

?

I also find the report* variants quite useful, so I wonder if there’s a way to fold them into this pattern.

I’m coming around to feeling good about `^`, because it’s in ASCII, and because Racket uses `expt`, thus it’s underemployed. Let’s try that and see how it works. It doesn’t have to go into the public interface yet. `^`= `report` `^^`= `report/line` `^^^`= `report/file` ? I also find the `report*` variants quite useful, so I wonder if there’s a way to fold them into this pattern.
AlexKnauth commented 10 years ago (Migrated from github.com)

I often define ^ as expt for use as an infix operator, either through a macro such as (: a ^ b) or through infix expressions in the sweet-exp meta-language. Since sugar/debug/lang is a meta-language, it can be used with any base language, including other combinations of meta-languages, and that's a good thing. But because of that, it should try to play as nice as possible with other languages, not just standard racket.

If you really want to try it though, all you would have to do is replace 'dispatch-macro here with 'non-terminating-macro, I think.

I often define `^` as `expt` for use as an infix operator, either through a macro such as `(: a ^ b)` or through infix expressions in the `sweet-exp` meta-language. Since `sugar/debug/lang` is a meta-language, it can be used with any base language, including other combinations of meta-languages, and that's a good thing. But because of that, it should try to play as nice as possible with other languages, not just standard racket. If you really want to try it though, all you would have to do is replace `'dispatch-macro` [here](https://github.com/mbutterick/sugar/blob/master/sugar/debug/reader.rkt#L9) with `'non-terminating-macro`, I think.
mbutterick commented 10 years ago (Migrated from github.com)

Well, this is why some have observed that naming things is hard. In the case of escape characters, it’s the intractable compromise between ergonomics (= easy to type) and effectiveness (= doesn’t interfere with other syntaxes). In this case, because it’s a debugging tool, I give the edge to ergonomics.

I made a few adjustments and just pushed a commit (0ffe317387) with the revised syntax:

#lang sugar/debug racket
(void ^(list 1 2 3))
(void ^^(list 1 2 3))
(void ^^^(list 1 2 3))

> (list 1 2 3) = '(1 2 3)
> (list 1 2 3) = '(1 2 3) on line 4
> (list 1 2 3) = '(1 2 3) on line 5 in "unsaved-editor"

Thanks again for the heavy lifting.

Well, this is why some have observed that naming things is hard. In the case of escape characters, it’s the intractable compromise between ergonomics (= easy to type) and effectiveness (= doesn’t interfere with other syntaxes). In this case, because it’s a debugging tool, I give the edge to ergonomics. I made a few adjustments and just pushed a commit (https://github.com/mbutterick/sugar/commit/0ffe3173879cef51d29b4c91a336a4de6c3f8ef8) with the revised syntax: ``` racket #lang sugar/debug racket (void ^(list 1 2 3)) (void ^^(list 1 2 3)) (void ^^^(list 1 2 3)) > (list 1 2 3) = '(1 2 3) > (list 1 2 3) = '(1 2 3) on line 4 > (list 1 2 3) = '(1 2 3) on line 5 in "unsaved-editor" ``` Thanks again for the heavy lifting.
AlexKnauth commented 10 years ago (Migrated from github.com)

You might also want to change this:
0ffe317387 (diff-a0d2ec31fb84102294a2591a70121d8cR67)

You might also want to change this: https://github.com/mbutterick/sugar/commit/0ffe3173879cef51d29b4c91a336a4de6c3f8ef8#diff-a0d2ec31fb84102294a2591a70121d8cR67
mbutterick commented 10 years ago (Migrated from github.com)

Ah yes, thank you.

Ah yes, thank you.
mbutterick commented 10 years ago (Migrated from github.com)

So far, I like how this works. But I’m also seeing the issue you alluded to about ^. When you said it would be “in the way” I thought you meant in the sense of one symbol carrying yet another meaning within a source file. But I see now that the side effect of hacking the reader like this is that other ^ in a leading position — i.e., whether alone or attached to an identifier — simply can’t be read at all, so the file is busted. Which means your suggestion of #^ is wiser.

So far, I like how this works. But I’m also seeing the issue you alluded to about `^`. When you said it would be “in the way” I thought you meant in the sense of one symbol carrying yet another meaning within a source file. But I see now that the side effect of hacking the reader like this is that other `^` in a leading position — i.e., whether alone or attached to an identifier — simply can’t be read at all, so the file is busted. Which means your suggestion of `#^` is wiser.
mbutterick commented 10 years ago (Migrated from github.com)

Also, I’d be open to spinning off sugar/debug into a new package of debug utilities if you’re interested in these kind of things. Probably a lot of people have handy debug helpers that would be nice to consolidate in one place.

Also, I’d be open to spinning off `sugar/debug` into a new package of debug utilities if you’re interested in these kind of things. Probably a lot of people have handy debug helpers that would be nice to consolidate in one place.
AlexKnauth commented 10 years ago (Migrated from github.com)

On Jul 30, 2015, at 9:30 PM, Matthew Butterick notifications@github.com wrote:

So far, I like how this works. But I’m also seeing the issue you alluded to about ^. When you said it would be “in the way” I thought you meant in the sense of one symbol carrying yet another meaning within a source file. But I see now that the side effect of hacking the reader like this is that other ^ in a leading position — i.e., whether alone or attached to an identifier — simply can’t be read at all, so the file is busted. Which means your suggestion of #^ is wiser.


Reply to this email directly or view it on GitHub.

Yes, that's what I meant. Sorry, I did make it seem like it was only a problem for the one ^ identifier.
It means that you wouldn't have a seamless transition to using this, since you would have to wrap every identifier starting with ^ in || before using #lang sugar/debug on a file.

On Jul 30, 2015, at 9:30 PM, Matthew Butterick notifications@github.com wrote: > So far, I like how this works. But I’m also seeing the issue you alluded to about ^. When you said it would be “in the way” I thought you meant in the sense of one symbol carrying yet another meaning within a source file. But I see now that the side effect of hacking the reader like this is that other ^ in a leading position — i.e., whether alone or attached to an identifier — simply can’t be read at all, so the file is busted. Which means your suggestion of #^ is wiser. > > — > Reply to this email directly or view it on GitHub. > > Yes, that's what I meant. Sorry, I did make it seem like it was only a problem for the one ^ identifier. > It means that you wouldn't have a seamless transition to using this, since you would have to wrap every identifier starting with ^ in || before using #lang sugar/debug on a file.
mbutterick commented 10 years ago (Migrated from github.com)

The #^ syntax also has the unexpected (though not unwelcome) consequence of providing no-extra-cost highlighting for the debugged expression.

screen shot 2015-07-31 at 7 33 04 pm

The `#^` syntax also has the unexpected (though not unwelcome) consequence of providing no-extra-cost highlighting for the debugged expression. ![screen shot 2015-07-31 at 7 33 04 pm](https://cloud.githubusercontent.com/assets/1425051/9020339/1b079b18-37bb-11e5-9fce-6cf892b85870.gif)
mbutterick commented 10 years ago (Migrated from github.com)

#^ is a little awkward due to the distance between the keys. I’m trying #R instead because it’s quicker to type.

`#^` is a little awkward due to the distance between the keys. I’m trying `#R` instead because it’s quicker to type.
AlexKnauth commented 10 years ago (Migrated from github.com)

You could allow both, though.

You could allow both, though.
AlexKnauth commented 10 years ago (Migrated from github.com)

(For me #^ is more readable because it stands out more.)

(For me `#^` is more readable because it stands out more.)
AlexKnauth commented 10 years ago (Migrated from github.com)

If you are planning on splitting sugar/debug into a separate package, could you consider having it not depend on typed racket?
I wanted to use it to debug a file in the type-checker, but I got a cycle in loading path error.

If you are planning on splitting `sugar/debug` into a separate package, could you consider having it not depend on typed racket? I wanted to use it to debug a file in the type-checker, but I got a cycle in loading path error.
AlexKnauth commented 10 years ago (Migrated from github.com)

Plus the whole "include-without-lang-line" thing you did shouldn't be necessary for macros like report, because they only expand to base functions that are already in the typed racket type environment, so they should work fine in typed racket without that.

Plus the whole "include-without-lang-line" thing you did shouldn't be necessary for macros like `report`, because they only expand to base functions that are already in the typed racket type environment, so they should work fine in typed racket without that.
mbutterick commented 10 years ago (Migrated from github.com)

True, though the functions had to flow TR → R, so it was easiest to make macros go that way too.

A separate debug package could / should just be R.

True, though the functions had to flow TR → R, so it was easiest to make macros go that way too. A separate debug package could / should just be R.
The pull request has been merged as a7d58c4a69.
You can also view command line instructions.

Step 1:

From your project repository, check out a new branch and test the changes.
git checkout -b debug-meta-lang master
git pull origin debug-meta-lang

Step 2:

Merge the changes and update on Gitea.
git checkout master
git merge --no-ff debug-meta-lang
git push origin master
Sign in to join this conversation.
No reviewers
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: mbutterick/sugar#5
Loading…
There is no content yet.