Web lists-archives.com

Re: [PATCH] doc/gitattributes: add Octave




On Sat, May 11, 2019 at 7:26 AM Ævar Arnfjörð Bjarmason
<avarab@xxxxxxxxx> wrote:
>
>
> On Fri, May 10 2019, Boxuan Li wrote:
>
> > `matlab` pattern is also suitable for source code
> > in the GNU Octave language.
> >
> > Signed-off-by: Boxuan Li <liboxuan@xxxxxxxxxxxxxx>
> > ---
> >  Documentation/gitattributes.txt | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/Documentation/gitattributes.txt b/Documentation/gitattributes.txt
> > index 4fb20cd0e9..1b28381bda 100644
> > --- a/Documentation/gitattributes.txt
> > +++ b/Documentation/gitattributes.txt
> > @@ -819,7 +819,7 @@ patterns are available:
> >
> >  - `java` suitable for source code in the Java language.
> >
> > -- `matlab` suitable for source code in the MATLAB language.
> > +- `matlab` suitable for source code in the MATLAB/Octave language.
> >
> >  - `objc` suitable for source code in the Objective-C language.
>
> I've never used either, but browsing our patterns I see:
>
>          "^[[:space:]]*((classdef|function)[[:space:]].*)$|^%%[[:space:]].*$",
>
> I.e. that last bit matches ^%%, and then here:
> https://en.wikibooks.org/wiki/MATLAB_Programming/Differences_between_Octave_and_MATLAB
>
>     MATLAB uses the percent sign '%' to begin a comment. Octave uses
>     both the hash symbol # and the percent sign % interchangeably.
>
> So here we have the "function" pattern matching a comment, right? (this
> doesn't have any tests) and we'd want to add "#" to Octave, but not
> MATLAB.

Thanks, that's a great catch! Actually, '%%' is used to start a code
section in Matlab
(https://www.mathworks.com/help/matlab/matlab_prog/run-sections-of-programs.html),
while Octave uses both '%%' and '##'
(https://octave.org/doc/interpreter/Sections.html).

>
> I see both tend to use the ".m" extension. Anyway, isn't it better to
> add an "octave" pattern, and document that they're mostly the same

I agree. I'll send an updated patch soon.

> (although it looks like we can add #-comments, to future-proof
> ourselves?