Closed eihli closed 2 years ago
There are reasons to not make any changes related to this.
If you're commenting stuff out as part of development and debugging then this problem is solved by other tools. Just make two commits in version control and jump back and forth. Or use your editor to undo/redo.
Within srcweave, instead of commenting out a block you can create an empty block and use that as the include.
I'm strongly leaning towards thinking this should not change.
Thanks for writing this in detail. I would prefer to keep the relationship between the particular programming language and the srcweave tool as separated as possible. Ultimately it's a text manipulation system. Keeping it focused on text makes it's behavior predictable and easier to integrate with other unix tools. For this reason, I am not a big fan of introducing a way to define what the language's comment syntax is.
With that said, here are two options I can think of:
Ensure that including an unknown block only produces a warning instead of an error. Then you could just add a character to the front of the identifier, and it would create a bogus include with no effect on the source code. This is similar to your idea of including an empty block, but you don't have to make an empty block.
Create a special form representing our own comments in the literate system. For example, perhaps ?{64 bit test loop}
could be ignored by the system.
As you mentioned, only whitespace is prefixed. You use the example of someArray.@{filter and map chain}
. Now I am questioning whether that's actually very useful. What if we included the prefix regardless of what characters it contained? I think a lisp example might show me it is useful, let me see what we have.
I am leaning towards something like option 1. What are your thoughts?
- Ensure that including an unknown block only produces a warning instead of an error.
Yeah this sounds good and reasonable. Not erroring is closer to the behavior of at least one existing tool, Org-mode, which isn't even warning me when I export with a non-existent block.
#+begin_src shell :noweb yes
echo "hello"
<<goodbye>>
<<world>>
#+end_src
#+NAME: world
#+begin_src shell
echo "world"
#+end_src
I've got some code like below and I'd like to comment out all of the
64 bit test loop
with a single//
line. But right now it only prefixes the first line of the inclusion.I see how this behavior is useful because it lets you do things like:
Where
filter and map chain
is something like:You don't want
someArray
to be prefixed to each line there, andsrcweave
doesn't know there's a difference between//
andsomeArray
. It doesn't know that one's a comment prefix and one's not.So... I'm happy to work on the implementation. But what's the best way to go about this?
Maybe something like a "comment directive"? Something scoped project-wide? Or scoped per file? Or scoped per code-block?
Maybe something like