Quantcast

Multi-line comments in Erlang

classic Classic list List threaded Threaded
52 messages Options
123
Zvi
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Multi-line comments in Erlang

Zvi
Hi,

Matlab/Octave has single line comments, like Erlang (i.e. starting
with '%' sign). But it also have multi-line comments, like for
example:

%{
this is example
of multi-line
comments in Matlab
%}

which is equivalent to:

%this is example
%of multi-line
%comments in Matlab

How difficult is to add comments like this to Erlang?

Thanks,
Zvi

________________________________________________________________
erlang-questions (at) erlang.org mailing list.
See http://www.erlang.org/faq.html
To unsubscribe; mailto:[hidden email]

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Multi-line comments in Erlang

James Churchman
not posible in erlang, but many editors (eg i use textmate) will comment and uncomment multiple lines with % on each line..
On 7 Dec 2010, at 15:32, Zvi wrote:

> Hi,
>
> Matlab/Octave has single line comments, like Erlang (i.e. starting
> with '%' sign). But it also have multi-line comments, like for
> example:
>
> %{
> this is example
> of multi-line
> comments in Matlab
> %}
>
> which is equivalent to:
>
> %this is example
> %of multi-line
> %comments in Matlab
>
> How difficult is to add comments like this to Erlang?
>
> Thanks,
> Zvi
>
> ________________________________________________________________
> erlang-questions (at) erlang.org mailing list.
> See http://www.erlang.org/faq.html
> To unsubscribe; mailto:[hidden email]
>


________________________________________________________________
erlang-questions (at) erlang.org mailing list.
See http://www.erlang.org/faq.html
To unsubscribe; mailto:[hidden email]

Zvi
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Multi-line comments in Erlang

Zvi
Why do you think it's not possible?
It's just simple change to Erlang source code parser.
Probably this should be submitted as EEP, so OTP team will consider it.

On Tue, Dec 7, 2010 at 6:25 PM, James Churchman <[hidden email]>wrote:

> not posible in erlang, but many editors (eg i use textmate) will comment
> and uncomment multiple lines with % on each line..
> On 7 Dec 2010, at 15:32, Zvi wrote:
>
> > Hi,
> >
> > Matlab/Octave has single line comments, like Erlang (i.e. starting
> > with '%' sign). But it also have multi-line comments, like for
> > example:
> >
> > %{
> > this is example
> > of multi-line
> > comments in Matlab
> > %}
> >
> > which is equivalent to:
> >
> > %this is example
> > %of multi-line
> > %comments in Matlab
> >
> > How difficult is to add comments like this to Erlang?
> >
> > Thanks,
> > Zvi
> >
> > ________________________________________________________________
> > erlang-questions (at) erlang.org mailing list.
> > See http://www.erlang.org/faq.html
> > To unsubscribe; mailto:[hidden email]
> >
>
>
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Multi-line comments in Erlang

Rapsey
Is it that important? Any proper programming editor can comment/uncomment
multiple lines.


Sergej

On Tue, Dec 7, 2010 at 5:49 PM, Zvi . <[hidden email]> wrote:

> Why do you think it's not possible?
> It's just simple change to Erlang source code parser.
> Probably this should be submitted as EEP, so OTP team will consider it.
>
> On Tue, Dec 7, 2010 at 6:25 PM, James Churchman <[hidden email]
> >wrote:
>
> > not posible in erlang, but many editors (eg i use textmate) will comment
> > and uncomment multiple lines with % on each line..
> > On 7 Dec 2010, at 15:32, Zvi wrote:
> >
> > > Hi,
> > >
> > > Matlab/Octave has single line comments, like Erlang (i.e. starting
> > > with '%' sign). But it also have multi-line comments, like for
> > > example:
> > >
> > > %{
> > > this is example
> > > of multi-line
> > > comments in Matlab
> > > %}
> > >
> > > which is equivalent to:
> > >
> > > %this is example
> > > %of multi-line
> > > %comments in Matlab
> > >
> > > How difficult is to add comments like this to Erlang?
> > >
> > > Thanks,
> > > Zvi
> > >
> > > ________________________________________________________________
> > > erlang-questions (at) erlang.org mailing list.
> > > See http://www.erlang.org/faq.html
> > > To unsubscribe; mailto:[hidden email]
> > >
> >
> >
>
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Multi-line comments in Erlang

James Churchman
oh ok, i get what you mean. Well it can not be done with a Parse Transform (something i have played with a lot) unless the syntax you use is still valid erlang, as it wont initially parse. i imagine that the erlang parser itself could be very easily modified with only a few lines & writing your own pre-parser thing would be even easier ( <5 LOC ? ) . Im sure this must have been mentioned a million times b4 & i guess it's left out as erlang is deliberately small & lean, any editor can handle doing multiple lines in one go & using ifdef(macro) or ifndef(macro) are a better way to deactivate code if thats what your looking for. maybe things like this inspired the language to stay lean. python : http://www.flickr.com/photos/nicksieger/281055485/ java : http://www.flickr.com/photos/nicksieger/280662707/in/photostream/ :-)



On 7 Dec 2010, at 18:20, Rapsey wrote:

> Is it that important? Any proper programming editor can comment/uncomment
> multiple lines.
>
>
> Sergej
>
> On Tue, Dec 7, 2010 at 5:49 PM, Zvi . <[hidden email]> wrote:
>
>> Why do you think it's not possible?
>> It's just simple change to Erlang source code parser.
>> Probably this should be submitted as EEP, so OTP team will consider it.
>>
>> On Tue, Dec 7, 2010 at 6:25 PM, James Churchman <[hidden email]
>>> wrote:
>>
>>> not posible in erlang, but many editors (eg i use textmate) will comment
>>> and uncomment multiple lines with % on each line..
>>> On 7 Dec 2010, at 15:32, Zvi wrote:
>>>
>>>> Hi,
>>>>
>>>> Matlab/Octave has single line comments, like Erlang (i.e. starting
>>>> with '%' sign). But it also have multi-line comments, like for
>>>> example:
>>>>
>>>> %{
>>>> this is example
>>>> of multi-line
>>>> comments in Matlab
>>>> %}
>>>>
>>>> which is equivalent to:
>>>>
>>>> %this is example
>>>> %of multi-line
>>>> %comments in Matlab
>>>>
>>>> How difficult is to add comments like this to Erlang?
>>>>
>>>> Thanks,
>>>> Zvi
>>>>
>>>> ________________________________________________________________
>>>> erlang-questions (at) erlang.org mailing list.
>>>> See http://www.erlang.org/faq.html
>>>> To unsubscribe; mailto:[hidden email]
>>>>
>>>
>>>
>>

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Multi-line comments in Erlang

Robert Virding-2
In reply to this post by Zvi
This issue comes up occasionally, but so far there has not been enough interest in it to warrant implementing it. It is not really difficult but there are some tricky issues which need solving and it is more difficult to use safely than you would imagine. I personally see no need.

Robert


----- "James Churchman" <[hidden email]> wrote:

> oh ok, i get what you mean. Well it can not be done with a Parse
> Transform (something i have played with a lot) unless the syntax you
> use is still valid erlang, as it wont initially parse. i imagine that
> the erlang parser itself could be very easily modified with only a few
> lines & writing your own pre-parser thing would be even easier ( <5
> LOC ? ) . Im sure this must have been mentioned a million times b4 & i
> guess it's left out as erlang is deliberately small & lean, any editor
> can handle doing multiple lines in one go & using ifdef(macro) or
> ifndef(macro) are a better way to deactivate code if thats what your
> looking for. maybe things like this inspired the language to stay
> lean. python : http://www.flickr.com/photos/nicksieger/281055485/ java
> : http://www.flickr.com/photos/nicksieger/280662707/in/photostream/
> :-)
>
>
>
> On 7 Dec 2010, at 18:20, Rapsey wrote:
>
> > Is it that important? Any proper programming editor can
> comment/uncomment
> > multiple lines.
> >
> >
> > Sergej
> >
> > On Tue, Dec 7, 2010 at 5:49 PM, Zvi . <[hidden email]>
> wrote:
> >
> >> Why do you think it's not possible?
> >> It's just simple change to Erlang source code parser.
> >> Probably this should be submitted as EEP, so OTP team will consider
> it.
> >>
> >> On Tue, Dec 7, 2010 at 6:25 PM, James Churchman
> <[hidden email]
> >>> wrote:
> >>
> >>> not posible in erlang, but many editors (eg i use textmate) will
> comment
> >>> and uncomment multiple lines with % on each line..
> >>> On 7 Dec 2010, at 15:32, Zvi wrote:
> >>>
> >>>> Hi,
> >>>>
> >>>> Matlab/Octave has single line comments, like Erlang (i.e.
> starting
> >>>> with '%' sign). But it also have multi-line comments, like for
> >>>> example:
> >>>>
> >>>> %{
> >>>> this is example
> >>>> of multi-line
> >>>> comments in Matlab
> >>>> %}
> >>>>
> >>>> which is equivalent to:
> >>>>
> >>>> %this is example
> >>>> %of multi-line
> >>>> %comments in Matlab
> >>>>
> >>>> How difficult is to add comments like this to Erlang?
> >>>>
> >>>> Thanks,
> >>>> Zvi
> >>>>
> >>>> ________________________________________________________________
> >>>> erlang-questions (at) erlang.org mailing list.
> >>>> See http://www.erlang.org/faq.html
> >>>> To unsubscribe; mailto:[hidden email]
> >>>>
> >>>
> >>>
> >>

--
Robert Virding, Erlang Solutions Ltd.


________________________________________________________________
erlang-questions (at) erlang.org mailing list.
See http://www.erlang.org/faq.html
To unsubscribe; mailto:[hidden email]

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Multi-line comments in Erlang

Robert Virding-2
In reply to this post by James Churchman
This issue comes up occasionally, but so far there has not been enough interest in it to warrant implementing it. It is not really difficult but there are some tricky issues which need solving and it is more difficult to use safely than you would imagine. I personally see no need.

Robert

----- "James Churchman" <[hidden email]> wrote:

> oh ok, i get what you mean. Well it can not be done with a Parse
> Transform (something i have played with a lot) unless the syntax you
> use is still valid erlang, as it wont initially parse. i imagine that
> the erlang parser itself could be very easily modified with only a few
> lines & writing your own pre-parser thing would be even easier ( <5
> LOC ? ) . Im sure this must have been mentioned a million times b4 & i
> guess it's left out as erlang is deliberately small & lean, any editor
> can handle doing multiple lines in one go & using ifdef(macro) or
> ifndef(macro) are a better way to deactivate code if thats what your
> looking for. maybe things like this inspired the language to stay
> lean. python : http://www.flickr.com/photos/nicksieger/281055485/ java
> : http://www.flickr.com/photos/nicksieger/280662707/in/photostream/
> :-)
>
>
>
> On 7 Dec 2010, at 18:20, Rapsey wrote:
>
> > Is it that important? Any proper programming editor can
> comment/uncomment
> > multiple lines.
> >
> >
> > Sergej
> >
> > On Tue, Dec 7, 2010 at 5:49 PM, Zvi . <[hidden email]>
> wrote:
> >
> >> Why do you think it's not possible?
> >> It's just simple change to Erlang source code parser.
> >> Probably this should be submitted as EEP, so OTP team will consider
> it.
> >>
> >> On Tue, Dec 7, 2010 at 6:25 PM, James Churchman
> <[hidden email]
> >>> wrote:
> >>
> >>> not posible in erlang, but many editors (eg i use textmate) will
> comment
> >>> and uncomment multiple lines with % on each line..
> >>> On 7 Dec 2010, at 15:32, Zvi wrote:
> >>>
> >>>> Hi,
> >>>>
> >>>> Matlab/Octave has single line comments, like Erlang (i.e.
> starting
> >>>> with '%' sign). But it also have multi-line comments, like for
> >>>> example:
> >>>>
> >>>> %{
> >>>> this is example
> >>>> of multi-line
> >>>> comments in Matlab
> >>>> %}
> >>>>
> >>>> which is equivalent to:
> >>>>
> >>>> %this is example
> >>>> %of multi-line
> >>>> %comments in Matlab
> >>>>
> >>>> How difficult is to add comments like this to Erlang?
> >>>>
> >>>> Thanks,
> >>>> Zvi
> >>>>
> >>>> ________________________________________________________________
> >>>> erlang-questions (at) erlang.org mailing list.
> >>>> See http://www.erlang.org/faq.html
> >>>> To unsubscribe; mailto:[hidden email]
> >>>>
> >>>
> >>>
> >>

________________________________________________________________
erlang-questions (at) erlang.org mailing list.
See http://www.erlang.org/faq.html
To unsubscribe; mailto:[hidden email]

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Multi-line comments in Erlang

Richard O'Keefe
In reply to this post by Zvi

On 8/12/2010, at 4:32 AM, Zvi wrote:

> Hi,
>
> Matlab/Octave has single line comments, like Erlang (i.e. starting
> with '%' sign). But it also have multi-line comments, like for
> example:
>
> %{
> this is example
> of multi-line
> comments in Matlab
> %}
>
> which is equivalent to:
>
> %this is example
> %of multi-line
> %comments in Matlab
>
> How difficult is to add comments like this to Erlang?

It's worth remembering that Erlang syntax is based on Prolog syntax,
and Prolog has always had PL/I-style /*...*/ comments.  Somewhere on
the way to Erlang, such comments were deliberately *removed* from
the language.

/* ... */ comments have no known advantages over % comments;
with adequate editing tools it is equally easy to "comment out"
or "comment in" a region either way and they are equally easy
to type or reformat.

However, /* ... */ comments come with several risks, which can
be ameliorated by syntax colouring to be sure, but not all programmers
can see.




________________________________________________________________
erlang-questions (at) erlang.org mailing list.
See http://www.erlang.org/faq.html
To unsubscribe; mailto:[hidden email]

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Multi-line comments in Erlang

Jesper Louis Andersen-2
On Tue, Dec 7, 2010 at 11:14 PM, Richard O'Keefe <[hidden email]> wrote:
>
> /* ... */ comments have no known advantages over % comments;
> with adequate editing tools it is equally easy to "comment out"
> or "comment in" a region either way and they are equally easy
> to type or reformat.

Is it, in Prolog acceptable to nest layers of /* .. */ ? It tend to be
that case which is hard to implement. Today, I see little need for
them. Most editors are fully capable of handling comment sections
spanning multiple lines with ease and the vicious idea of commenting
out code as a kind of revision control was luckily abolished with the
introduction of proper rev. control.


--
J.

________________________________________________________________
erlang-questions (at) erlang.org mailing list.
See http://www.erlang.org/faq.html
To unsubscribe; mailto:[hidden email]

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Multi-line comments in Erlang

Richard O'Keefe

On 8/12/2010, at 12:41 PM, Jesper Louis Andersen wrote:

> On Tue, Dec 7, 2010 at 11:14 PM, Richard O'Keefe <[hidden email]> wrote:
>>
>> /* ... */ comments have no known advantages over % comments;
>> with adequate editing tools it is equally easy to "comment out"
>> or "comment in" a region either way and they are equally easy
>> to type or reformat.
>
> Is it, in Prolog acceptable to nest layers of /* .. */ ?

No, most definitely NOT.  I did say they were PL/I-style comments,
which do not nest.  Nesting comments are one of those clever ideas
that turn out to be really dumb, because they don't actually work.

> It tend to be
> that case which is hard to implement.

As it happens, my Prolog tidier has code to convert plain bracketed
comments to standard form *and* nesting bracketed comments to
standard form.  As you can see, there is not a great deal of
difference.

static void
com2plain(FILE * card, FILE *line, int astcom, int endcom) {
    int c;
    int state;

    enter_comment      
    for (state = 1; (c = getc(card)) >= 0; ) {
        if (c == endcom && state != 0) break;
        state = c == astcom;
        copy_comment(c);
    }
    leave_ast_comment
    if (c < 0) SyntaxError(eofinrem);
}


static void  
com2nest(FILE * card, FILE *line, int begcom, int astcom, int endcom) {
    int c;      
    int state;
    int level;

    enter_comment
    for (state = 1, level = 1; (c = getc(card)) >= 0; ) {
        if (c == endcom && state == 1) {
            if (--level == 0) break;
        } else
        if (c == astcom && state == 2) {
            level++;
        }
        state = c == astcom ? 1 : c == begcom ? 2 : 0;
        copy_comment(c);
    }
    leave_ast_comment
    if (c < 0) SyntaxError(eofinrem);
}

Today I'd do that a bit differently, of course.

> Today, I see little need for them.



________________________________________________________________
erlang-questions (at) erlang.org mailing list.
See http://www.erlang.org/faq.html
To unsubscribe; mailto:[hidden email]

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Multi-line comments in Erlang

Stefan Marr-3
In reply to this post by Richard O'Keefe
Hi:

On 07 Dec 2010, at 23:14, Richard O'Keefe wrote:
> /* ... */ comments have no known advantages over % comments;
> with adequate editing tools it is equally easy to "comment out"
> or "comment in" a region either way and they are equally easy
> to type or reformat.
Very general statement, very specific response: Yes they do!
At least for me they are extremely helpful to document parts where I need to work around different compilers in C/C++. Inline comments with /**/ to annotate these things is the only way to keep track of all those nasty things...

However, that is neither related to the original question nor related to its usefulness in Erlang...

Best Regards
Stefan

________________________________________________________________
erlang-questions (at) erlang.org mailing list.
See http://www.erlang.org/faq.html
To unsubscribe; mailto:[hidden email]

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

RE: Multi-line comments in Erlang

dmercer
In reply to this post by Richard O'Keefe
On Tuesday, December 07, 2010, Richard O'Keefe wrote:

> Nesting comments are one of those clever ideas
> that turn out to be really dumb, because they don't actually work.

I'll bite, mainly because I've sometimes thought nesting comments would be
helpful, for instance, when commenting out large blocks of code, but it is
rare that I get to work with a language that supports them.  Since you're
almost always right about such things, why do you say that they don't
actually work?

Cheers,

David


________________________________________________________________
erlang-questions (at) erlang.org mailing list.
See http://www.erlang.org/faq.html
To unsubscribe; mailto:[hidden email]

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Speaking of comments

Edmond Begumisa
I've thought -- now and then, in the back of my mind -- about removing  
comments from actual source all-together (for all languages) and instead,  
putting them in companion files that the editor lines up side-by-side.  
More like annotating than just traditional commenting.

Has this sort of thing been done before? Is there a particular editor that  
can give me this out of the box? (I admittedly haven't explored a large  
number of editors)

Using Erlang as an example, I've secretly wanted something like...

foo.erl
foo.cts

Then an editor that could give me two panes while keeping the two files in  
sync...

foo ->  | This function does...
   blah  |   This part is buggy...
   balh  |

Also, in the right pane, I've wanted nestable trees with flexible levels  
of detail. Heck, why not even rich text? "FIX ME" in bold red. Take it  
further: login-name awareness, source-control/bug-tracker integration  
(this programmer said this, that programmer said that.)

It seems a shame that in 2010, it's still so limiting what we can do with  
comments in our source code!

- Edmond -

On Thu, 09 Dec 2010 01:39:42 +1100, David Mercer <[hidden email]> wrote:

> On Tuesday, December 07, 2010, Richard O'Keefe wrote:
>
>> Nesting comments are one of those clever ideas
>> that turn out to be really dumb, because they don't actually work.
>
> I'll bite, mainly because I've sometimes thought nesting comments would  
> be
> helpful, for instance, when commenting out large blocks of code, but it  
> is
> rare that I get to work with a language that supports them.  Since you're
> almost always right about such things, why do you say that they don't
> actually work?
>
> Cheers,
>
> David
>
>
> ________________________________________________________________
> erlang-questions (at) erlang.org mailing list.
> See http://www.erlang.org/faq.html
> To unsubscribe; mailto:[hidden email]
>


--
Using Opera's revolutionary e-mail client: http://www.opera.com/mail/

________________________________________________________________
erlang-questions (at) erlang.org mailing list.
See http://www.erlang.org/faq.html
To unsubscribe; mailto:[hidden email]

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

RE: Multi-line comments in Erlang

Bengt Kleberg
In reply to this post by dmercer
Greetings,

For commenting out code, it is possible to use:

-ifdef(never_defined).
...code
-endif().


bengt

On Wed, 2010-12-08 at 15:39 +0100, David Mercer wrote:

> On Tuesday, December 07, 2010, Richard O'Keefe wrote:
>
> > Nesting comments are one of those clever ideas
> > that turn out to be really dumb, because they don't actually work.
>
> I'll bite, mainly because I've sometimes thought nesting comments would be
> helpful, for instance, when commenting out large blocks of code, but it is
> rare that I get to work with a language that supports them.  Since you're
> almost always right about such things, why do you say that they don't
> actually work?
>
> Cheers,
>
> David
>
>
> ________________________________________________________________
> erlang-questions (at) erlang.org mailing list.
> See http://www.erlang.org/faq.html
> To unsubscribe; mailto:[hidden email]
>


________________________________________________________________
erlang-questions (at) erlang.org mailing list.
See http://www.erlang.org/faq.html
To unsubscribe; mailto:[hidden email]

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Multi-line comments in Erlang

Frédéric Trottier-Hébert
This will only work around a form (function definition, module attribute), and not within it. You won't be able to comment out only a branch of a case, or part of a function definition. Only the whole thing. This makes it less useful when wanting to comment out clauses of an OTP module.

I've found the lack of multiline comments annoying in the past, but most of the time, having the editor (vim in my case) handle it for me has been fine most of the time. It fails at commenting only part of a line when doing very specific tests and debugging, but that's about it.

--
Fred Hébert
http://www.erlang-solutions.com


On 2010-12-08, at 10:27 AM, Bengt Kleberg wrote:

> Greetings,
>
> For commenting out code, it is possible to use:
>
> -ifdef(never_defined).
> ...code
> -endif().
>
>
> bengt
>
> On Wed, 2010-12-08 at 15:39 +0100, David Mercer wrote:
>> On Tuesday, December 07, 2010, Richard O'Keefe wrote:
>>
>>> Nesting comments are one of those clever ideas
>>> that turn out to be really dumb, because they don't actually work.
>>
>> I'll bite, mainly because I've sometimes thought nesting comments would be
>> helpful, for instance, when commenting out large blocks of code, but it is
>> rare that I get to work with a language that supports them.  Since you're
>> almost always right about such things, why do you say that they don't
>> actually work?
>>
>> Cheers,
>>
>> David
>>
>>
>> ________________________________________________________________
>> erlang-questions (at) erlang.org mailing list.
>> See http://www.erlang.org/faq.html
>> To unsubscribe; mailto:[hidden email]
>>
>
>
> ________________________________________________________________
> erlang-questions (at) erlang.org mailing list.
> See http://www.erlang.org/faq.html
> To unsubscribe; mailto:[hidden email]
>


________________________________________________________________
erlang-questions (at) erlang.org mailing list.
See http://www.erlang.org/faq.html
To unsubscribe; mailto:[hidden email]

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Multi-line comments in Erlang

Richard O'Keefe
In reply to this post by Stefan Marr-3

On 8/12/2010, at 1:26 PM, Stefan Marr wrote:

> Hi:
>
> On 07 Dec 2010, at 23:14, Richard O'Keefe wrote:
>> /* ... */ comments have no known advantages over % comments;
>> with adequate editing tools it is equally easy to "comment out"
>> or "comment in" a region either way and they are equally easy
>> to type or reformat.
> Very general statement, very specific response: Yes they do!
> At least for me they are extremely helpful to document parts where I need to work around different compilers in C/C++.

You can do that equally well with // comments.

>  Inline comments with /**/ to annotate these things is the only way to keep track of all those nasty things...

On the contrary, the very first time I ever saw such annotation comments
was in Burroughs Algol, using % comments.  Prolog programmers often use
%FIXME% or something like that.



________________________________________________________________
erlang-questions (at) erlang.org mailing list.
See http://www.erlang.org/faq.html
To unsubscribe; mailto:[hidden email]

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Multi-line comments in Erlang

Richard O'Keefe
In reply to this post by dmercer

On 9/12/2010, at 3:39 AM, David Mercer wrote:

> On Tuesday, December 07, 2010, Richard O'Keefe wrote:
>
>> Nesting comments are one of those clever ideas
>> that turn out to be really dumb, because they don't actually work.
>
> I'll bite, mainly because I've sometimes thought nesting comments would be
> helpful, for instance, when commenting out large blocks of code, but it is
> rare that I get to work with a language that supports them.  Since you're
> almost always right about such things, why do you say that they don't
> actually work?

Here is a Haskell example.  Something very like this actually bit me.

        comment_close = "-}"

Comment that out:

        {-
        comment_close = "-}"
        -}

OOPS!  The comment ends at the first -}, not the second.

Before you say "but the first -} is in a quoted string",
recall that nesting comments are completely general, they are
NOT limited to escaping valid syntax in the programming language
in question.

I define "work" in this context as "you can comment out an
arbitrary chunk of text without having to worry about what is
inside it".

My text editor has a "comment out region" command that
handles comments of the form LX ... XR.  What it does is
to add extra spaces around Xs, so that this example
would be treated as

        {-
        comment_close = " - }"
        -}

and the "comment in region" command deletes single spaces
on either side of an X.  This *does* work, because it
guarantees that LX or XR brackets will never be found
inside the comment.  But that means it doesn't *need* nesting
comments at all.


________________________________________________________________
erlang-questions (at) erlang.org mailing list.
See http://www.erlang.org/faq.html
To unsubscribe; mailto:[hidden email]

Zvi
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Multi-line comments in Erlang

Zvi
In reply to this post by Rapsey
1. The beauty of dynamic languages is that you don't need tools and IDEs!
And even if you do use tools, many times you work not on your machine or on
target headless environments, with only basic editor available, or with
editor that you know poorly or which didn't configured with your macros,
etc.

2. Comments are essentially Natural language (let's say US English)
document, embedded into Programming language (Erlang) document.
Therefore, embedded document should be left intact. Ideally I would like
comments to be something, like HEREDOC.

3. Free format is the king! Language designers shouldn't dictate programmers
how to format and ident their code.
How differnt is starting comment line from '%' in Erlang, from putting 'C'
or '*' in the first column in FORTRAN?

4. In other languages, that doesn't have multiline comments I often use
ifdef(false) macro, or outright if(false) to "comment out" parts of code. I
think it's uglier, than proper multiline comments, but still better than
comment every single line.

Zvi

On Tue, Dec 7, 2010 at 8:20 PM, Rapsey <[hidden email]> wrote:

> Is it that important? Any proper programming editor can comment/uncomment
> multiple lines.
>
>
> Sergej
>
>
> On Tue, Dec 7, 2010 at 5:49 PM, Zvi . <[hidden email]> wrote:
>
>> Why do you think it's not possible?
>> It's just simple change to Erlang source code parser.
>> Probably this should be submitted as EEP, so OTP team will consider it.
>>
>> On Tue, Dec 7, 2010 at 6:25 PM, James Churchman <[hidden email]
>> >wrote:
>>
>> > not posible in erlang, but many editors (eg i use textmate) will comment
>> > and uncomment multiple lines with % on each line..
>> > On 7 Dec 2010, at 15:32, Zvi wrote:
>> >
>> > > Hi,
>> > >
>> > > Matlab/Octave has single line comments, like Erlang (i.e. starting
>> > > with '%' sign). But it also have multi-line comments, like for
>> > > example:
>> > >
>> > > %{
>> > > this is example
>> > > of multi-line
>> > > comments in Matlab
>> > > %}
>> > >
>> > > which is equivalent to:
>> > >
>> > > %this is example
>> > > %of multi-line
>> > > %comments in Matlab
>> > >
>> > > How difficult is to add comments like this to Erlang?
>> > >
>> > > Thanks,
>> > > Zvi
>> > >
>> > > ________________________________________________________________
>> > > erlang-questions (at) erlang.org mailing list.
>> > > See http://www.erlang.org/faq.html
>> > > To unsubscribe; mailto:[hidden email]
>> > >
>> >
>> >
>>
>
>
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Multi-line comments in Erlang

Daniel Goertzen-3
Thank you for reminding me about HEREDOCs.  In Python, I often use triple
quoted strings for multiline comments.  It works well, but they are exposed
to the interpreter which smells a bit.  What if erlang had HEREDOCs *plus* a
way to mark any string as a comment.  Some illustrations, using Python's
triple quoting as HEREDOC format.

X="""
This is
a multiline heredoc
""",
...


%"""
This is
a multiline comment
"""


myfun(X, Y %"An inline comment", Z) -> ...


So comment and string delimiting uses the exact same logic, but you stick a
% in front to mark it as a comment instead of a string.

Dan.


On Thu, Dec 9, 2010 at 3:48 AM, Zvi . <[hidden email]> wrote:

> 1. The beauty of dynamic languages is that you don't need tools and IDEs!
> And even if you do use tools, many times you work not on your machine or on
> target headless environments, with only basic editor available, or with
> editor that you know poorly or which didn't configured with your macros,
> etc.
>
> 2. Comments are essentially Natural language (let's say US English)
> document, embedded into Programming language (Erlang) document.
> Therefore, embedded document should be left intact. Ideally I would like
> comments to be something, like HEREDOC.
>
> 3. Free format is the king! Language designers shouldn't dictate
> programmers
> how to format and ident their code.
> How differnt is starting comment line from '%' in Erlang, from putting 'C'
> or '*' in the first column in FORTRAN?
>
> 4. In other languages, that doesn't have multiline comments I often use
> ifdef(false) macro, or outright if(false) to "comment out" parts of code. I
> think it's uglier, than proper multiline comments, but still better than
> comment every single line.
>
> Zvi
>
> On Tue, Dec 7, 2010 at 8:20 PM, Rapsey <[hidden email]> wrote:
>
> > Is it that important? Any proper programming editor can comment/uncomment
> > multiple lines.
> >
> >
> > Sergej
> >
> >
> > On Tue, Dec 7, 2010 at 5:49 PM, Zvi . <[hidden email]> wrote:
> >
> >> Why do you think it's not possible?
> >> It's just simple change to Erlang source code parser.
> >> Probably this should be submitted as EEP, so OTP team will consider it.
> >>
> >> On Tue, Dec 7, 2010 at 6:25 PM, James Churchman <
> [hidden email]
> >> >wrote:
> >>
> >> > not posible in erlang, but many editors (eg i use textmate) will
> comment
> >> > and uncomment multiple lines with % on each line..
> >> > On 7 Dec 2010, at 15:32, Zvi wrote:
> >> >
> >> > > Hi,
> >> > >
> >> > > Matlab/Octave has single line comments, like Erlang (i.e. starting
> >> > > with '%' sign). But it also have multi-line comments, like for
> >> > > example:
> >> > >
> >> > > %{
> >> > > this is example
> >> > > of multi-line
> >> > > comments in Matlab
> >> > > %}
> >> > >
> >> > > which is equivalent to:
> >> > >
> >> > > %this is example
> >> > > %of multi-line
> >> > > %comments in Matlab
> >> > >
> >> > > How difficult is to add comments like this to Erlang?
> >> > >
> >> > > Thanks,
> >> > > Zvi
> >> > >
> >> > > ________________________________________________________________
> >> > > erlang-questions (at) erlang.org mailing list.
> >> > > See http://www.erlang.org/faq.html
> >> > > To unsubscribe; mailto:[hidden email]
> >> > >
> >> >
> >> >
> >>
> >
> >
>
Zvi
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Multi-line comments in Erlang

Zvi
I think Python using '#' for comments.

On Dec 9, 5:58 pm, Daniel Goertzen <[hidden email]> wrote:

> Thank you for reminding me about HEREDOCs.  In Python, I often use triple
> quoted strings for multiline comments.  It works well, but they are exposed
> to the interpreter which smells a bit.  What if erlang had HEREDOCs *plus* a
> way to mark any string as a comment.  Some illustrations, using Python's
> triple quoting as HEREDOC format.
>
> X="""
> This is
> a multiline heredoc
> """,
> ...
>
> %"""
> This is
> a multiline comment
> """
>
> myfun(X, Y %"An inline comment", Z) -> ...
>
> So comment and string delimiting uses the exact same logic, but you stick a
> % in front to mark it as a comment instead of a string.
>
> Dan.
>
> On Thu, Dec 9, 2010 at 3:48 AM, Zvi . <[hidden email]> wrote:
> > 1. The beauty of dynamic languages is that you don't need tools and IDEs!
> > And even if you do use tools, many times you work not on your machine or on
> > target headless environments, with only basic editor available, or with
> > editor that you know poorly or which didn't configured with your macros,
> > etc.
>
> > 2. Comments are essentially Natural language (let's say US English)
> > document, embedded into Programming language (Erlang) document.
> > Therefore, embedded document should be left intact. Ideally I would like
> > comments to be something, like HEREDOC.
>
> > 3. Free format is the king! Language designers shouldn't dictate
> > programmers
> > how to format and ident their code.
> > How differnt is starting comment line from '%' in Erlang, from putting 'C'
> > or '*' in the first column in FORTRAN?
>
> > 4. In other languages, that doesn't have multiline comments I often use
> > ifdef(false) macro, or outright if(false) to "comment out" parts of code. I
> > think it's uglier, than proper multiline comments, but still better than
> > comment every single line.
>
> > Zvi
>
> > On Tue, Dec 7, 2010 at 8:20 PM, Rapsey <[hidden email]> wrote:
>
> > > Is it that important? Any proper programming editor can comment/uncomment
> > > multiple lines.
>
> > > Sergej
>
> > > On Tue, Dec 7, 2010 at 5:49 PM, Zvi . <[hidden email]> wrote:
>
> > >> Why do you think it's not possible?
> > >> It's just simple change to Erlang source code parser.
> > >> Probably this should be submitted as EEP, so OTP team will consider it.
>
> > >> On Tue, Dec 7, 2010 at 6:25 PM, James Churchman <
> > [hidden email]
> > >> >wrote:
>
> > >> > not posible in erlang, but many editors (eg i use textmate) will
> > comment
> > >> > and uncomment multiple lines with % on each line..
> > >> > On 7 Dec 2010, at 15:32, Zvi wrote:
>
> > >> > > Hi,
>
> > >> > > Matlab/Octave has single line comments, like Erlang (i.e. starting
> > >> > > with '%' sign). But it also have multi-line comments, like for
> > >> > > example:
>
> > >> > > %{
> > >> > > this is example
> > >> > > of multi-line
> > >> > > comments in Matlab
> > >> > > %}
>
> > >> > > which is equivalent to:
>
> > >> > > %this is example
> > >> > > %of multi-line
> > >> > > %comments in Matlab
>
> > >> > > How difficult is to add comments like this to Erlang?
>
> > >> > > Thanks,
> > >> > > Zvi
>
> > >> > > ________________________________________________________________
> > >> > > erlang-questions (at) erlang.org mailing list.
> > >> > > Seehttp://www.erlang.org/faq.html
> > >> > > To unsubscribe; mailto:[hidden email]
>
>

________________________________________________________________
erlang-questions (at) erlang.org mailing list.
See http://www.erlang.org/faq.html
To unsubscribe; mailto:[hidden email]

123
Loading...