metaeducation / ren-c

Library for embedding a Rebol interpreter into C codebases
GNU Lesser General Public License v3.0
126 stars 27 forks source link

syntax error if issue! is directly followed by a semicolon ";" #1086

Closed IngoHohmann closed 3 years ago

IngoHohmann commented 3 years ago
>> #a;
** Syntax Error: invalid "issue" -- "#a"
** Where: transcode if load trap ext-console-impl entrap console
** Near: (line 1) #a;
** File: --anonymous--
** Line: 1
hostilefork commented 3 years ago

This is by design...to avoid people using #; to try and get a semicolon character and getting unexpected results.

Since ; are legal in things like URLs generically, I don't think people should be putting them up against things... one space off is a minimum, but I prefer 2 in practice.

IngoHohmann commented 3 years ago

I do get your point, and why isn't ";" allowed in issues!s, if it is allowed in text!?

And shouldn't this be changed to ";"

>> last "abc;"
== #;

Though we all know, that molded data does not necessarily have to be loadable, this seems a bit unfortunate to me:

>> load mold last ";"
(i) Info: use WHY for error information
** Syntax Error: invalid "issue" -- "#"
** Where: transcode if load console
** Near: (line 1) #;
** File: --anonymous--
** Line: 1
hostilefork commented 3 years ago

why isn't ";" allowed in issues!s,

It's allowed, it just needs quotes around it. So do ] and ( and things like that.

Though we should consider if #paired(cases)should[be]legal...and URLs have a similar question.

And shouldn't this be changed to ";"

Yep, good point. It needs to be unified with the FILE! code for making the decisions about whether to put things in quotes or not, and all that needs to be better.

Glad you're looking at it, and if you want to work on putting together tests that would be great... I'd like to see more things like this one, which was a precursor to the unification:

https://github.com/metaeducation/ren-c/blob/6eb0ae5f5330aa81fa306d89cd0e1facff31b902/tests/datatypes/issue.test.reb#L37-L59

If we have some of those for what MOLD expectations are, it would be great.

Though we all know, that molded data does not necessarily have to be loadable,

I'd like that to be as true as it can be; even to the point of having a debug mode where LOAD always internally does one pass of molding what it got in out, and then reloading it and comparing to see it's identical...

So generally, assume any problems with that are just something not gotten around to yet.

hostilefork commented 3 years ago

To be clear: I would probably prefer it if semicolons were only considered comments if they had space to their left:

#  ; empty issue with comment
#;  ; a single-character semicolon issue!

Considering the general principles of space-separation in the language, that seems an easy-enough rule to absorb. It would suggest that a;b and a; b would be errors, which I'm personally fine with. Though I have seen some cases where the no-op of semicolon-ness has been taken advantage of to LOAD foreign notations which were mostly compatible...but needed semicolon as an end-of-line marker. :-/

But without that rule in place for the rest of the language, it makes sense for ISSUE! to error here, and ask you to write #";"

IngoHohmann commented 3 years ago

But it is in effect for some of the rest of the language:

>> http://www.abc.de/look;
== http://www.abc.de/look;

And I feel issue! is conceptually nearer to url! than to word!

hostilefork commented 3 years ago

But it is in effect for some of the rest of the language:

I actually hadn't checked to notice URLs were doing that (Rebol2 and Red do not). Apparently neither does R3-Alpha, so this is something that was hacked into Ren-C at some point.

It seems to me that implementing a space-significance rule for comments is probably the best answer. Went ahead and tried doing that.

hostilefork commented 3 years ago

As much as I'd like to write tests all day for these things, there's a pile of stuff to do...

...so I can really just start it off, add some if you feel inclined:

https://github.com/metaeducation/ren-c/pull/1087/files#diff-a5b72ba76d0a93f2d434a4733bd6a23e9d9a2b9469a6f65c7e76dffe284cee13R1-R50