FAQ  •  Register  •  Login

Undocumented continuation line syntax?

<<

Felix

Posts: 10

Joined: Fri Jun 28, 2013 8:22 am

Location: Bucharest, Romania

Post Tue Jul 09, 2013 3:12 pm

Undocumented continuation line syntax?

Hello, everyone! First time poster here.

While working on my second ZXBasic game, I accidentally discovered a syntax feature I can't seem to find documented anywhere.

Namely, a backslash at the end of a line causes it to be concatenated with the next one. That also works inside a comment, in which case the next line is "eaten up". That's more or less like in C, if I remember correctly, but in ZXBasic it surprised me because the wiki only mentions the underscore as a continuation line.

Is there anything I missed?
<<

boriel

Site Admin

Posts: 1463

Joined: Wed Nov 01, 2006 6:18 pm

Location: Santa Cruz de Tenerife, Spain

Post Thu Jul 11, 2013 8:03 am

Re: Undocumented continuation line syntax?

Felix wrote:Hello, everyone! First time poster here.
Welcome to the forum, Felix, and sorry for the delay (I'm currently wokring in hard deadlines :oops:), but the forum has many active users, anyway. 8)

Felix wrote:While working on my second ZXBasic game, I accidentally discovered a syntax feature I can't seem to find documented anywhere.

Namely, a backslash at the end of a line causes it to be concatenated with the next one. That also works inside a comment, in which case the next line is "eaten up". That's more or less like in C, if I remember correctly, but in ZXBasic it surprised me because the wiki only mentions the underscore as a continuation line.

Is there anything I missed?

Well, the FreeBasic / Visual BASIC "standar" (ahem...) uses underscore. But ZX BASIC also uses a C-like preprocessor. This means the source code is firstly filtered through a C-Like preprocessor (CPP), called zxbpp, and then the resulting code is compiled. The C preprocessor allows backslash as a continuation line, so any line you write backslashed will be joined or translated to underscore (depending on the context).
So yes, ZX Basic allows both _ and \ as line continuation characters, but \ is not documented because it should be in the preprocessor section (... which is not documented yet! :?)
<<

Felix

Posts: 10

Joined: Fri Jun 28, 2013 8:22 am

Location: Bucharest, Romania

Post Thu Jul 11, 2013 8:42 am

Re: Undocumented continuation line syntax?

Thank you, Boriel, and don't worry about the delay.

So ZXBasic has a fully featured C-like preprocessor? That's very useful, and those are already well documented.
<<

boriel

Site Admin

Posts: 1463

Joined: Wed Nov 01, 2006 6:18 pm

Location: Santa Cruz de Tenerife, Spain

Post Thu Jul 11, 2013 8:46 am

Re: Undocumented continuation line syntax?

Felix wrote:Thank you, Boriel, and don't worry about the delay.

So ZXBasic has a fully featured C-like preprocessor? That's very useful, and those are already well documented.

Well, "fully featured" depends on the standar and version you follow. e.g. CPP from GNU C has many non-standar powerful features I've find very hard to mimic (I prefer to concentrate the efforts in the compiler). But other than that, I think it's a quite complete preprocessor. E.g. you can define macros to be used as inline functions (which are slightly faster), etc...
There are many examples in the compiler library/ directory and in this forum, if I recall correctly.

Return to Documentation

Who is online

Users browsing this forum: No registered users and 1 guest

cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by Vjacheslav Trushkin for Free Forums/DivisionCore.

phpBB SEO