Git Product home page Git Product logo

Comments (7)

PaulBoersma avatar PaulBoersma commented on September 23, 2024

Inline comments do not exist. The ";" trick works only in formulas. It designates "end of expression". Now with the "new" syntax, which requires quotes around all strings, we could introduce inline comments starting with "#".

from praat.

jjatria avatar jjatria commented on September 23, 2024

So far it has been easy enough to separate hashes used in comments from those as array sigils, because the first one should have nothing but optional whitespace before. If this is no longer the case, this could get tricky for eg. syntax highlighters. And perhaps more importantly: could this also become harder to read for us humans, who also need to parse code? I actually thought this was the idea behind semicolons as "inline comment" markers.

How set is the hash as the array sigil? Particularly since they are not documented or in extended use, I suppose this should be ok to change. Perl, for example, uses @.

If the hash was only used for comments, then I think this would be totally fine. I'm not so sure further overloading the character is a good idea, usability-wise.

What do you think?

from praat.

PaulBoersma avatar PaulBoersma commented on September 23, 2024

We are still dreaming of using @ for complex numbers. Beside that, # really looks iconically like a matrix. I agree with the overload of the #, though. I guess the easiest would be to allow ! also after commands without arguments. We would have to disallow the use of ! in menu commands. Do you think that would break anything? The ? is used, after all, in existing commands.

from praat.

jjatria avatar jjatria commented on September 23, 2024

You know where I stand on ... special characters in command names, so no: I'm totally for disallowing ! (and ; and many other characters) from command names. Disallow away!

But wait: why !? Did you mean ;? Would there be any problem with using ;? I don't think there are any command names that currently use ; either, so if anything other than # I'd rather go with that because it already has the "end-of-statement" meaning and has been used that way in other languages as well.

And actually the documentation already implies this sort of use (which is what caused my confusion) with a formula like

800; sqrt(2) * sin(2 * pi * 103 * 0.5) + 10 ^ (-40 / 20) * randomGauss(0, 1)

which the documentation says evaluates to 800. Are there any cases in which the statement at the right of a ; is evaluated (other than when Praat thinks that it is part of a command name)?

On a side note, I think inline comments would actually be really helpful, particularly for those commands that take a large number of indexed parameters, such as To Pitch (ac).... Currently, if one wants to use it in a script with some semblance of self-documentation (ie. without having to point people to the documentation) you need to use carefully named variables, even if you never use them again, such as:

# Default values
max_candidates = 15
silence_threshold = 0.03
voicing_threshold = 0.45
octave_cost = 0.01
jump_cost = 0.35
vuv_cost = 0.14

silence_threshold
To Pitch (ac): time_step, pitch_floor, max_candidates, 
  ... "no", silence_threshold, voicing_threshold, octave_cost, 
  ... jump_cost, vuv_cost, pitch_ceiling

This could be replaced with something like (with whatever character is eventually used):

To Pitch (ac): time_step, pitch_floor, max_candidates, 
  ... ; Default values
  ... "no", ; Use a faster and less precise Hanning window
  ... 0.03, ; silence threshold
  ... 0.45, ; voicing threshold
  ... 0.01, ; octave cost
  ... 0.35, ; octave jump cost
  ... 0.14, ; voiced-unvoiced cost
  ... pitch_ceiling

The example is a bit contrived, but I think it shows one possible scenario where true inline comments would be useful.

from praat.

PaulBoersma avatar PaulBoersma commented on September 23, 2024

Yes, I meant the semicolon; I confused it for a moment with the exclamation mark that can be used in text data files. Your last example is also good; at the moment it fails because line concatenation precedes argument evaluation (as it should), but we could order semicolon comment removal before line concatenation. (argument evaluation comes after that, and would still involve another round of end-of-formula semicolon removal, considering that the semicolon can be used in numeric dialog fields)

from praat.

PaulBoersma avatar PaulBoersma commented on September 23, 2024

It's tricky, though. At the moment, line concatenation comes so early that you can break text strings across lines. It's a bit hard to see how we could order semicolon removal before it. Consider:

Text: 0.5, "centre", 0.5, "half",
... "This is my strange text including
... 0.03, ; silence threshold
... where the semicolon should not signify a comment;
... can this be solved?"

from praat.

jjatria avatar jjatria commented on September 23, 2024

Hmmm... that's true. I don't think that can be fixed, at least not on broken lines.

It would still be useful in other contexts, though, but less so, I guess.

from praat.

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.