Code Monkey home page Code Monkey logo

Comments (1)

McJones avatar McJones commented on June 10, 2024

I am going to close this issue as something we don't intend on adding to the language, but I'd like to give you our reasoning as this is something that we've discussed a fair bit before internally way back in the pre v1 release days of Yarn Spinner.

So the first and major issue is adding multi-line comments actually adds a surprisingly large amount of complexity to the parsing of yarn (or any language tbh).
In that correctly handling all the nesting of comments and mixing elements that aren't comments but look the same is particularly brutal to the parser grammar.
As an example of this:

/*
Calculator: hello, I am a calculator
Player: What can you do?
Calculator: I can perform the following +-*/
*/

Sure this example is one I made up on the spot but how should this be handled?
And this is true with also just nesting the multi-line comments in general.
So take the following example:

/*
Here is some regular text
/*
Here is some more text inside a nested comment
*/
Here is some text outside the nested comment
*/

In this current form should the parser have seen two comment blocks or one?
And where should the top level comment end?
If we delete the top comment opening terminal is there now an error?

So the options are to:

  • not allow multi-line comments
  • not allow multi-line comment elements nested inside multi-line comments
  • force users to escape multi-line comment elements
  • implement nested comment ranges and handle every edge case that presents

Secondly in our recommended editor of VSCode if you select a block of text and press Ctrl (or Command on macOS) and / it will automatically append the // comment terminal to the front of the line.
Pressing Ctrl + / again will remove the //, giving an easy way to comment and uncomment lines in bulk.

Overall we decided that the quick line comment feature of VSCode gives enough of the benefits of multi-line comments, without any of the edge cases, so we haven't implemented them.
I hope this clears up why we don't see any real benefit to multi-line comments.

from yarnspinner.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.