ANSI Basic: is FreeBasic standard-compliant?
ANSI Basic: is FreeBasic standard-compliant?
Many textbooks have some code examples in basic (to solve math problems, to test algorithms and so on): often, they use a "generic" form of basic, that should work on almost every basic interpreter or compiler.
When FreeBasic had been created, it was just another basic compiler, so no one really cared if it was 100% standard compliant or not (a lot of basic dialects are not standard compliant). But nowaday, the situation is changing: Freebasic is officially considered the best basic compiler for linux (http://www.linuxlinks.com/article/20090 ... ilers.html), so it's not unlikely that it will soon become the "gold standard": every linux user who wants to test a piece of basic code will use freebasic, because it will be the official solution (just as they now use GCC to test C and C++ code: there are other C/C++ compilers, but GCC is the "official" one). So, it would be a shame if a "standard" compiler doesn't work with standard code.
That's why, in my opinion, Freebasic should support (only in qb mode, of course) some features even if they're deprecated: DEF FN, for example. It's ugly, it's useless (FUNCTION is far better)... but it's part of ANSI basic, so a compiler that cannot accept it is not a full basic compiler. Maybe DEF FN could be resolved at a preprocessor level, working like a macro.
It could be used as an alternative to #MACRO or #DEFINE: after all, "const" is already a sort of "#DEFINE" that use the "=" instead of the space in the definition.
Another serious incompatibility (even if not defined in ANSI basic) is the impossibility to have scalars and arrays with the same name: since many old interpreters accepted only one or two characters in a variable name, often the same name was used for a variable and an array, leading to errors when porting the code to FreeBasic. Is there any chance to have it fixed?
What do you think? Should FreeBasic be able to compile old basic snippets? (at least, for educational purposes or for math testing?)
When FreeBasic had been created, it was just another basic compiler, so no one really cared if it was 100% standard compliant or not (a lot of basic dialects are not standard compliant). But nowaday, the situation is changing: Freebasic is officially considered the best basic compiler for linux (http://www.linuxlinks.com/article/20090 ... ilers.html), so it's not unlikely that it will soon become the "gold standard": every linux user who wants to test a piece of basic code will use freebasic, because it will be the official solution (just as they now use GCC to test C and C++ code: there are other C/C++ compilers, but GCC is the "official" one). So, it would be a shame if a "standard" compiler doesn't work with standard code.
That's why, in my opinion, Freebasic should support (only in qb mode, of course) some features even if they're deprecated: DEF FN, for example. It's ugly, it's useless (FUNCTION is far better)... but it's part of ANSI basic, so a compiler that cannot accept it is not a full basic compiler. Maybe DEF FN could be resolved at a preprocessor level, working like a macro.
It could be used as an alternative to #MACRO or #DEFINE: after all, "const" is already a sort of "#DEFINE" that use the "=" instead of the space in the definition.
Another serious incompatibility (even if not defined in ANSI basic) is the impossibility to have scalars and arrays with the same name: since many old interpreters accepted only one or two characters in a variable name, often the same name was used for a variable and an array, leading to errors when porting the code to FreeBasic. Is there any chance to have it fixed?
What do you think? Should FreeBasic be able to compile old basic snippets? (at least, for educational purposes or for math testing?)
Re: ANSI Basic: is FreeBasic standard-compliant?
They usually use an old Dartmouth derived interpreted Basic. But most of those snippets are not in a really standard, but in a multitude of modified interpreters. Not all are really 100% compat.angros47 wrote:Many textbooks have some code examples in basic (to solve math problems, to test algorithms and so on): often, they use a "generic" form of basic, that should work on almost every basic interpreter or compiler.
I note that you didn't post a reference to the standard. What standard are you talking about? Is it a currently active ISO standard?When FreeBasic had been created, it was just another basic compiler, so no one really cared if it was 100% standard compliant or not (a lot of basic dialects are not standard compliant).
A random "links" site is "officially"?But nowaday, the situation is changing: Freebasic is officially considered the best basic compiler for linux (http://www.linuxlinks.com/article/20090 ... ilers.html),
No. The situation with C and C++ and its stringent and often implemented formal standards is fundamentally different from standards of other languages.so it's not unlikely that it will soon become the "gold standard": every linux user who wants to test a piece of basic code will use freebasic, because it will be the official solution (just as they now use GCC to test C and C++ code: there are other C/C++ compilers, but GCC is the "official" one). So, it would be a shame if a "standard" compiler doesn't work with standard code.
This because C was tied to Unix from the very earliest, and Unix applications were only source recompilable. The large existing base of C product sourcecode made the standards process extremely conservative and lowest common denomitor, but on the other hand standards-use very widespread. This is not the case for other languages. (except maybe Java in the Enterprise sphere, but Java nor C# are really languages with multiple, equal standards based compilers. Oracle resp. Microsoft control those languages)
I don't see why the development team wouldn't accept proper patches that do so. If somebody wants to waste time on that why not?That's why, in my opinion, Freebasic should support (only in qb mode, of course) some features even if they're deprecated: DEF FN, for example. It's ugly, it's useless (FUNCTION is far better)... but it's part of ANSI basic, so a compiler that cannot accept it is not a full basic compiler. Maybe DEF FN could be resolved at a preprocessor level, working like a macro.
No. The real worth of the snippets is low and there are already enough minimalistic C based interpreters for that purpose , and those are much better suited for code written for interpreters. I don't personally see no grave reason to implement it in FB.What do you think? Should FreeBasic be able to compile old basic snippets? (at least, for educational purposes or for math testing?)
I think FB should better focus on its strength, namely being a compiler.
Re: ANSI Basic: is FreeBasic standard-compliant?
There are two standards: ANSI X3.60-1978 Minimal Basic and ANSI X3.113-1987 "Full Basic". These standards were subsequently adopted by International Organization for Standardization (ISO).marcov wrote:I note that you didn't post a reference to the standard. What standard are you talking about? Is it a currently active ISO standard?When FreeBasic had been created, it was just another basic compiler, so no one really cared if it was 100% standard compliant or not (a lot of basic dialects are not standard compliant).
http://en.wikipedia.org/wiki/BASIC#Standards
There are also ECMA (European Computer Manufacturers Association) standards:
The Minimal Standard is referred to as: ECMA-55.
http://www.ecma-international.org/publi ... 201978.pdf
The Full Standard is referred to as :ECMA-116
http://web.archive.org/web/201110141401 ... 201986.pdf
Re: ANSI Basic: is FreeBasic standard-compliant?
I mean, are they freely available? Many ISO documents require a hefty fee (from several hundred to several thousand)angros47 wrote:There are two standards: ANSI X3.60-1978 Minimal Basic and ANSI X3.113-1987 "Full Basic". These standards were subsequently adopted by International Organization for Standardization (ISO).marcov wrote: I note that you didn't post a reference to the standard. What standard are you talking about? Is it a currently active ISO standard?
Usually considered toilet paper. But in this case it could be useful since ecma is more generous with docs, and wikipedia seems to indicate they are mostly the same as ansi.There are also ECMA (European Computer Manufacturers Association) standards:
But I still think this is a task for interpreted BASICs (QB64?) not FB. And even if not, who is going to fork the cash, and implement it?
Re: ANSI Basic: is FreeBasic standard-compliant?
1) QB64 is not an interpreter, it's a translator to c++.
2) Since the ECMA doc is almost identical, it could be used as a reference. As far as I can tell, FreeBasic is already 98% compliant with the standard (at least for the minimal basic); making it 100% compliant might not be too difficult, and could be worth the effort.
2) Since the ECMA doc is almost identical, it could be used as a reference. As far as I can tell, FreeBasic is already 98% compliant with the standard (at least for the minimal basic); making it 100% compliant might not be too difficult, and could be worth the effort.
Re: ANSI Basic: is FreeBasic standard-compliant?
I thought it focused more on interpreted dialects.angros47 wrote:1) QB64 is not an interpreter, it's a translator to c++.
Yes.2) Since the ECMA doc is almost identical, it could be used as a reference.
As said I don't see the worth personally.As far as I can tell, FreeBasic is already 98% compliant with the standard (at least for the minimal basic); making it 100% compliant might not be too difficult, and could be worth the effort.
But the easiest is to simply start making tests for the testsuite using the spec, and then start working on a patch.
-
- Posts: 5494
- Joined: Sep 12, 2005 20:06
- Location: California
Re: ANSI Basic: is FreeBasic standard-compliant?
I'm with marcov on this one. I don't see much value in this.
If it gets done, that might be neat, but I wouldn't over-hype the effect it would have on the compiler and its usage, which I assume would be zero.
If it gets done, that might be neat, but I wouldn't over-hype the effect it would have on the compiler and its usage, which I assume would be zero.
Re: ANSI Basic: is FreeBasic standard-compliant?
Personally I don't want to work through a huge specification if I can avoid it, but if someone were to do that part and figure out which individual features may need to be added to fbc, I may be interested in working on them or help someone do that, because that's what I like to do.
Of course -lang qb isn't my main interest by far, but it'd be great if fbc could claim to be compatible to certain standards, if even possible.
Of course -lang qb isn't my main interest by far, but it'd be great if fbc could claim to be compatible to certain standards, if even possible.
Re: ANSI Basic: is FreeBasic standard-compliant?
Actually, I think that Freebasic is already very close to specifications, and it might fullfill them very soon, by adding a couple of features (that, I just discovered, are already in the to-do list: http://fbc.svn.sourceforge.net/viewvc/f ... iew=markup)
I understand that they have low priority, but when I saw version .90, I hoped that they had been added. In my opinion, these features are not so marginal, but, from the answers I got, I see that I am in the minority.
I understand that they have low priority, but when I saw version .90, I hoped that they had been added. In my opinion, these features are not so marginal, but, from the answers I got, I see that I am in the minority.
Re: ANSI Basic: is FreeBasic standard-compliant?
> The Minimal Standard is referred to as: ECMA-55
41 pages, 16 MiB !!! , 1978
> The Full Standard is referred to as :ECMA-116
207 pages , 70 MiB !!! , 1986
Scanning rocks :-D (but the content is obsolete ...)
Anyway, the portability of BASIC will fail on the very same problem as portability of other languages: lack of good hardware and OS standards (graphics? sound? non-standard char's? file I/O? even just keyboard (INKEY$$$ is hacky, may one keypress brew a longer string or return a one-char string multiple times?), ... ).
41 pages, 16 MiB !!! , 1978
> The Full Standard is referred to as :ECMA-116
207 pages , 70 MiB !!! , 1986
Scanning rocks :-D (but the content is obsolete ...)
Anyway, the portability of BASIC will fail on the very same problem as portability of other languages: lack of good hardware and OS standards (graphics? sound? non-standard char's? file I/O? even just keyboard (INKEY$$$ is hacky, may one keypress brew a longer string or return a one-char string multiple times?), ... ).