Message Boards Message Boards

0
|
2208 Views
|
5 Replies
|
1 Total Likes
View groups...
Share
Share this post:

A simple question about something that has been bothering me

I have noticed that often, when I am adding a comment above a line as in: (* ,,,,,,,,, *) I will notice that at the end of the comment there is a lower case, gray x as in:

(* A comment *) x

That lower case x is also associated with lines being tabbed in such a way that it states that I have a syntax error. But all I have to do is add a space after the *) and the x disappears and the tabbling becomes normal.

But what is worse, is that the lower case, grayed x, does not occur after the comment, but to a comment that is further down in the code! This means that it can be easy to miss the x (unless you notice the odd tabbing). And if you run your code, without adding that space after the comment, you get errors in your code. I wonder if anybody else has experienced the same thing.

I just want to understand why I have to have a space after the (* ..... *)

POSTED BY: Henrick Jeanty
5 Replies

If you have a cell with the following content:

a(*A comment*)
b

it is interpeted as two separate inputs. On the contrary, with this

Module[{}, a(*A comment*)
  b]

it is interpreted as a multiplication. Try evaluating them.

POSTED BY: Gianluca Gorni

Hello Eric, Based on your suggestion that the x means that the interpreter seems to see a multiplication, I went ahead and tried different scenarios and indeed whenever an implicit multiplication was a possibility, the x would appear. That solves that problem although I will be on the lookout for cases where that is not the case (meaning that multiplication doesn't make sense) and will report on those with the code sample.

Thanks for your help.

POSTED BY: Henrick Jeanty

Hello Eric, Thank you for your reply. I will try to find an example. But here is the funny thing. The previous statement before the comment ends with a ";". Also when I add the space after the *), the lower case grayed x disappears and then, if I remove the space I just put in, the x doesn't reappear.

I am using Mathematica 13.1.0.0

POSTED BY: Henrick Jeanty
Posted 1 year ago

Well, I just tried some things based on that description, and I cannot reproduce this. A more detailed set of steps will probably be needed.

POSTED BY: Eric Rimbey
Posted 1 year ago

Can you provide an explicit example (being clear about where every whitespace character is)? In the meantime, I'm pretty sure that whenever you see a little gray x, that's the front end telling you that it's interpreting the surrounding expression as a multiplication. So, if you just type 1 2, you'll see 1x2. If this is what is happening in your case, then there must be something nearby that would be reasonable to interpret as a multiplication, and that wouldn't be a comment (unless maybe there is a version specific behavior that I haven't seen). So, you need to provide more details either about the expression itself or what sequence of keystrokes led up to it.

POSTED BY: Eric Rimbey
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract