#18 in-line comments need a blank space

closed-fixed
1
2007-12-14
2007-12-10
futurdorko
No

Yet another comments matter..Using in-line comments without leaving a blank space between the last instruction and the symbol # causes gretl to halt claiming for an invalid character.

e.g.
<i>
nulldata 100

a = 1# error
</i>

<o>
gretl version 1.7.0
Current session: 2007/12/10 18:52
? nulldata 100
periodicity: 1, maxobs: 100,
observations range: 1-100
? a = 1# error
> a = 1#
Invalid character '#'

Error executing script: halting
> a = 1# error
</o>

Discussion

1 2 > >> (Page 1 of 2)
  • Logged In: YES
    user_id=1368575
    Originator: NO

    The function strip_inline_comments(), in lib/src/interact.c actually filters the string " #", rather than the character "#", unless it happens to be the first non-whitespace character. This is of course easy to modify, but I'm not sure of what else this may break, so I'm leaving this alone until Allin clarifies the matter. For the moment, just put a space before "#".

     
  • Sven S.
    Sven S.
    2007-12-13

    • priority: 5 --> 3
     
  • Sven S.
    Sven S.
    2007-12-13

    Logged In: YES
    user_id=1330711
    Originator: NO

    Bug or feature?

    Of course the mismatch between documentation and actual behavior is a bug, but I would be inclined to rather change the docs to reflect the current status quo. Not having a blank in there is bad style, or can somebody provide an example where it is really useful to have the # character right next to the code? If not, then the behavior should not be changed IMHO. (maybe adding a more informative error message, too)

    thanks,
    sven

     
  • Allin Cottrell
    Allin Cottrell
    2007-12-13

    • priority: 3 --> 1
    • assigned_to: nobody --> allin
     
  • Allin Cottrell
    Allin Cottrell
    2007-12-13

    Logged In: YES
    user_id=330339
    Originator: NO

    I agree with Sven on this: let's leave the code as is but
    fix the manual.

    Can anyone find where the valid comment syntax is discussed
    in the manual? I'm afraid it's not obvious!

     
  • Sven S.
    Sven S.
    2007-12-13

    Logged In: YES
    user_id=1330711
    Originator: NO

    Actually, p.55 of the gretl guide shows some printf lines with # characters that don't have any whitespace around them, so that would suggest that changing the current behavior really would break something.

    I'm not sure the comment syntax must be added explicitly to the guide, as there are many obvious examples. IMHO it's more important to print a more meaningful error message; maybe check if the invalid character was '#' and then print the additional message "if you were trying to write in-line comments, you must leave a blank (space) before the '#'" or something like that.

    -sven

     
  • futurdorko
    futurdorko
    2007-12-13

    Logged In: YES
    user_id=1533827
    Originator: YES

    I strongly disagree with this, since putting "#" is at least as useful as putting " #", and maybe even a little bit more since you need only one key pressing. About the bad style, it's a rather personal matter, and as it's called style, it should be allowed to the user to use his own, whether good or not.
    And last but not least i have never seen a compiler/interpreter halting for such a silly matter. IMHO.

     
  • Sven S.
    Sven S.
    2007-12-13

    Logged In: YES
    user_id=1330711
    Originator: NO

    I didn't intend to criticize you when I wrote "bad style", sorry. Nevertheless I think most people prefer the blank for readability. You could even interpret the status quo as part of gretl's inherent syntax, and then it wouldn't be a style issue anymore.

    Apart from these secondary or cosmetic issues, the problem with the (s)printf command is real, AFAICS. IMHO it shows that such changes are problematic and should only be done for important reasons.

    Of course, I am neither the coder nor the decider.

    cheers,
    sven

     
  • Allin Cottrell
    Allin Cottrell
    2007-12-13

    Logged In: YES
    user_id=330339
    Originator: NO

    I personally abhor comments run into code with no spaces,
    but I agree that _if_ we consider this a matter of style
    it should be up to the user.

    Sven's point about (s)printf shouldn't be an issue, since
    we check to see if comment characters are enclosed in
    quotes, and we treat them as special only if they are
    not so enclosed. I'm committing a change to CVS, but not
    closing this bug just yet: if anyone finds any bad
    side-effects please post!

     
  • futurdorko
    futurdorko
    2007-12-13

    Logged In: YES
    user_id=1533827
    Originator: YES

    I knew Sven don't worry..i was fighting for freedom! :P

     
1 2 > >> (Page 1 of 2)