PDA

View Full Version : Idea for automatic implied line continuation



Robert Hodge
24-06-2013, 16:36
One of the more awkward and unnatural aspects of Basic is the use of underscores as a line continuation. As Basic grew over the years and became more "un" Basic, a means was needed to continue lines, in a language that was never designed with this in mind. The underscore was as good as any (not much different than a \ in the C preprocessor).

However, we could do a lot better.

If a line ended with a token that would make no sense as the "last" token of the line, a continuation could be assumed.

What tokens are candidates for this?


arithmetic: + - * / \ ^
string: & .
comparison: < <= =< > >= => <>
compound: += -+ *= /= \= &= .=
logical: ALL AND ANDB OR ORB NOT NOTB SOME XOR
a final open paren: (
a final comma: ,


These are 'obvious' choices. A semi-obvious choice would be an unclosed paren, like this:

A = COS (THETA ' ( was not closed, so line can't be "done" yet
+ 1.0)

but merely having an as-yet-unclosed construct as of the end of the line is probably more bookkeeping (for Eros!) than would be polite to ask for, so I won't. :-))

There are also reasonably obvious choices, like DIM and AS. But, if there are too many of these 'obvious' choices, the list would start getting very long, and that could cause more problems that it solved.

I am sure there are C and PL/1 programmers out there that would wish TB ended every line with a ; semicolon and didn't even use implicit line termination, but we can't force one language to be another; it just doesn't work.

It may be noted that the most recent versions of Visual Basic.Net employ this implied continuation.

Anyway, that's the idea.

Petr Schreiber
24-06-2013, 17:09
Hi,

I think the implicit line continuation was introduced to ThinBASIC in version 1.8.6.0. Try these in latest TB:


String MyArray(9) = 1, 2, 3,
4, 5, 6,
7, 8, 9

MsgBox 0,
Join$(MyArray, ", ")

Long x =
5

MsgBox 0,
x


SaySomething(
"Ciao"
)

Function SaySomething( something As String )
MsgBox 0, something
End Function



Petr

Charles Pegge
24-06-2013, 17:10
Yes. ThinBasic has most of them already :)



dim as long a,b,c,d


a=1 : b=20 : c=300


d=
a+b+
c


msgbox 0,d &
" ok"

Robert Hodge
24-06-2013, 17:17
Do you know if this is documented somewhere? If so, where?

Is there a list of the specific things that imply line continuation?

ReneMiner
24-06-2013, 18:09
Not specific. Just some hint to sniff: check help for Rawtext...