add sugar/debug/lang meta-language
#5
Merged
AlexKnauth
merged 1 commits from debug-meta-lang
into master
10 years ago
Loading…
Reference in New Issue
There is no content yet.
Delete Branch 'debug-meta-lang'
Deleting a branch is permanent. It CANNOT be undone. Continue?
Is this what you meant in the BTW2 of https://github.com/mbutterick/sugar/pull/4#issuecomment-118557611 ?
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)Also, thanks for catching those missing
provide
sQ1. 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:
After:
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 asexpt
, 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.I haven’t forgotten about this. Just thinking about the optimal interface.
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.Re: Q1: Would you really want to change it to
^42
instead of#^42
?Yes. In fact I would endorse a shorthand like
^
for the basicreport
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.)
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?
I’m coming around to feeling good about
^
, because it’s in ASCII, and because Racket usesexpt
, 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 often define
^
asexpt
for use as an infix operator, either through a macro such as(: a ^ b)
or through infix expressions in thesweet-exp
meta-language. Sincesugar/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.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:Thanks again for the heavy lifting.
You might also want to change this:
0ffe317387 (diff-a0d2ec31fb84102294a2591a70121d8cR67)
Ah yes, thank you.
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.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.On Jul 30, 2015, at 9:30 PM, Matthew Butterick notifications@github.com wrote:
The
#^
syntax also has the unexpected (though not unwelcome) consequence of providing no-extra-cost highlighting for the debugged expression.#^
is a little awkward due to the distance between the keys. I’m trying#R
instead because it’s quicker to type.You could allow both, though.
(For me
#^
is more readable because it stands out more.)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.
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.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.
a7d58c4a69
.Step 1:
From your project repository, check out a new branch and test the changes.Step 2:
Merge the changes and update on Gitea.