Oxygen Basic
Programming => Bugs & Feature Requests => Topic started by: Mike Lobanovsky on May 27, 2014, 11:15:15 PM
-
Hi Charles,
The following is a 100% bug:
dim as string cur_line = "<eof>"
if cur_line = "<eof>" then: print "got eof"
cur_line = ""
end if
.
-
No Error.
dim as string cur_line = "<eof>"
if cur_line = "<eof>" then
print "got eof"
cur_line = ""
end if
-
Mike,
If there is any code after "then" on the same line, it will assume it is a single liner, including any colons.
Internally, single liner ifs are automatically appended with endif.
-
Or without stupid then
dim as string cur_line = "<eof>"
if cur_line = "<eof>"
print "got eof"
cur_line = ""
end if
-
Gentlemen,
There is nothing on the same line with if/then because ":" is a line break. I could agree with you if ":" weren't supported at all but since it is, this is a bug.
I know pretty well that if/then and print will work if separated by a hard line break but ":" is also a line break, albeit soft, in BASIC terms except when used in conjunction with a label.
In my opinion, this is a 100% bug pardonnable for the time being only if Charles promises us to fix it up at the earliest time possible. :)
-
Mike, I will contemplate your argument :)
if then has always been a bit odd in various basics, in that colons in such expressions, are not equivalent to line breaks.
Oxygen currently supports the following single liner syntax. (an else clause can also be appeneded appended):
if a>b then b=a
if a>b : b=a
if a>b {b=a}
if a>b then {b=a}
if a>b : {b=a}
-
Oxygen currently supports the following single liner syntax. (an else clause can also be appeneded):
Appended: better for learner like me.
No wonder that my English is so bad. ;D
-
My view on one-liners:
1. BASIC (colon-delimited something/anything/whatever may contain colons of their own)
if a>b then something [else whatever]
if a>b then : something [: elseif a<b then : anything] [: else : whatever] : end if
2. Quazi-BASIC (curly braces denote a scope that can contain colons)
if a>b then {something} [else {whatever}]
if a>b then : {something} [: elseif a<b then : {anything}] [: else : {whatever}] : end if
if a>b {something} [else {whatever}]
if a>b : {something} [: elseif a<b : {anything}] [: else : {whatever}] : end if
3. Not a BASIC! (http://www.fbsl.net/phpbb2/images/smilies/icon_m_tomato.gif)
if a>b : b=a
if a>b : {b=a}
8)
-
well
i don't have to much problems with oxygen if/{else}/end if
because i tend to avoid then in
if / end if block
of course ....i use then in one line
if a>b then a=a+1
-
Aurel,
I'm perfectly aware that Oxygen is a quazi BASIC and I'm not insisting on it being pure but I'd like to see it being able to cope with pure BASIC syntax too, at least fundamentally. It's not a question of what you are or are not having problems with. For all we care you can get accustomed to using scopes (curly braces) in each and every multiline block of code if you like. But more BASIC-oriented users should have their chance as well. Isn't it called OxygenBasic after all?
I have nothing personal against building a superset upon BASIC, e.g. as we did in FBSL (I should say, very moderately, hehe...), but let's not break up BASIC's fundamental constructs in the process.
The cases printed in red are weird and they break up usual BASIC syntax. I say I ported and debugged the Toy interpreter in FBSL within an hour even using pure BASIC syntax. And I did it while in fact I could've written it all in a twice shorter and more efficient notation omitting almost all its global and local variables altogether in the process. But I'm beating about the bush with Oxygen for maybe five days in a row already.
-
I say I ported and debugged the Toy interpreter in FBSL within an hour even using pure BASIC syntax. And I did it while in fact I could've written it all in a twice shorter and more efficient notation omitting almost all its global and local variables altogether in the process.
It would be great if you could create the "twice shorter and more efficient notation omitting almost all its global and local variables altogether in the process" version. I always welcome shorter/faster/etc. ways of doing things..
Thanks!
-
1 if a=1 : b=1 'endif implied
2 if a=1 : b=1 : end if 'endif explicit
I'm thinking seriously about option 2, Mike. It's a finely balanced decision.
This is Oxygen's current preferred scheme for single liners.
/*
SINGLE LINERS
=============
LOOPS AND LOOPING CONDITIONALS
do : exit do : end do 'explicit end
while a<=10 : a-=1 : wend 'explicit end
for a = 1 to 10 : b+=a : next 'explicit end
NON LOOPING CONDITIONALS
if a=1 : b=1 'endif implied
case a : b=1 'endcase implied
FUNCTIONS
function f(a) as sys = a*a 'end function implied
sys f(a)=a*a 'end function implied
TYPES
type vector float x,y,z 'end type implied
DIMS
dim vector a,b,c 'end dim implied
ENUMS
enum Colors red,green,blue 'end enum implied
*/
-
I always welcome shorter/faster/etc. ways of doing things..
I will do it with pleasure as soon as we are through with O2 port of Toy interpreter here.
In the meantime, please have a look at the FBSL script that's a full-fledged BMP-to-RES file compiler. It doesn't use a single variable declaration or assignment statement that'd add runtime overhead. The second snapshot is a test .BMP precompiled into a .RES file using this pico-compiler and linked into an executable, as seen on loading the said resource .BMP with a call to LoadResource() WinAPI.
Thanks for your interest in FBSL!
.
-
Charles,
This table looks very elegant and consistent indeed. It is however not compliant with BASIC tradition whenever even a single soft line break (:) appears within the code line. Moreover, it breaks up traditional BASIC block constructs if the soft line break appears on the first code line because you're refusing to accept : as a legit line break.
You're sacrificing tradition mercilessly to the harmony of your table and you're scaring me off as a BASIC user. :(
-
-But more BASIC-oriented users should have their chance as well.
: Mike
But i am one of them....
But I'm beating about the bush with Oxygen for maybe five days in a row already.
Heh ...I am beating all the time and because of that i often forget what is what
but this is standard tactic anyway...
Well Mike
I know that you can make better version but this one by Ed is somehow
good as example ...
I don't know is there a way to replace UDT variables with ordinary typed...maybe :-\
-
Option 2 would be consistent with a colon always being interpreted as a soft line break.
2 if a=1 : b=1 : end if 'endif explicit
That leaves case as the slightly odd one out.
case a : b=1
-
No oddity seen here, Charles. The case that follows marks unambiguously the end of case immediately preceding it while end select will mark the end of entire block.
-
I don't know is there a way to replace UDT variables with ordinary typed...maybe :-\
Absolutely no problem here, Aurel. Just split each UDT into two simple variables and create two arrays for them. The array sizes will be the same and the indices within them will point to the same elements that they pointed to when each two-member UDT was still a single entity. This would be the easiest problem throughout the entire port. :)
but this is standard tactic anyway...
But it shouldn't be, at least as far as standard language constructs are concerned. This is why I'm so agitated: Charles is shaking the foundations and I'm already seeing the first bricks fall off the roof and bump on my head. :)
-
I think option 2 tips the balance in your favour, Mike: :)
We can now do expressions like this (if we really want to):
sys a=2, b=0
if a=1 : b=1 : elseif a=2 : b=2 else b=3 : end if
or
if a=1 then : b=1 : elseif a=2 then : b=2 : else : b=3 : end if
print b
-
Are you sure there are no typos here?
sys a=2, b=0
if a=1 : b=1 : elseif a=2 : b=2 else b=3 : end if
print b
And I suppose there may be anything instead of a sys here? (Just asking to be on the safe side, hehe...)
A voice in the wilderness again... yet maybe this is somehow better than nothing at all. :)
-
Yes, Any primitive type: int, float or string.
I'm testing as we 'speak'. It works any which way. keywords then / else / elseif : are all expression terminators.
-
It works any which way. keywords then / else / elseif : are all expression terminators.
Does that mean :'s after then and before else and elseif (and I suppose, before end too) are optional???
-
The colon after then is essential to distinguish it from lines like
if a>1 then b=1
Similarly, a colon must come after an elseif condition.
end if / endif must be preceded by a colon under current parsing rules.
then is optional in these cases
-
This is why I'm glad Peter Verhas made the wise decision to only allow one statement per line.
This is a legal variable name in SB.
Hi = Hello:World
-
Charles,
Is your
b=2 else b=3
correct?
Hi John,
one statement per line
No "soft" line breaks (like : here) at all?
-
PRINT test( _
arg1, _
arg2, _
"""
Multi
Line
String
""")
This is one statement.
-
This is one statement.
Got it. The only legit line break is a *nix LF (0xA).
BTW FBSL's multiline string would be
"
Multi
Line
String
"
to be printed as
Multi
Line
String
Yours would be printed to the console as
"
Multi
Line
String
"
Charles,
What about my last question, please?
-
Yes Mike, the else syntax works the same as before. I am almost ready to post an update. Just working through the permutations.
if a=1 then b=1 else b=5
-
a = _
"""
"Multi",
"Line',
'String'
"""
:)
-
Charles,
Please "yes" or "no":
if a=1 : b=1 : elseif a=2 : b=2 else b=3 : end if
does not require a colon before else, does it?
-
John,
What will your print a look like?
-
Yes, yes! else terminates an expression in all cases.
Oxygen also supports multiline strings btw.
Can be confusing when one quote mark is missing :)
-
a = _
"""
"Multi",
"Line',
'String'
"""
PRINT a,"\n"
jrs@laptop:~/sb/sb22/test$ scriba mls.sb
"Multi",
"Line',
'String'
jrs@laptop:~/sb/sb22/test$
-
Can be confusing when one quote mark is missing :)
Major contributor to hair loss.
-
Oh,
Charles, my English must be failing me tonight. :)
Yes, yes!
Does it mean
"Yes, it does. It does need a colon within this context!"
or
"No, it doesn't. It does not need a colon within this context!"
The reason why I'm asking is because the Russian sentences like "No, it does" and "Yes, it doesn't" are perfectly legal and only correct from the Russian grammar perspective.
Sorry for being especially dumb tonight.
P.S. Can be confusing when one quote mark is missing :)
Should have proper syntax highlighting in your editor to avoid confusion. :P
-
Major contributor to hair loss.
Anything to lose yet? ;)
"Multi",
"Line',
'String'
Understood. """ is simply a marker of a multiline string.
-
Mike,
Yes, else it does not need a colon, and No, a colon is unnecessary :)
However in the older single liner syntax colons must not be used
if a=1 then b=1 : : : : else : : : : b=5
if a=1 then b=1 else b=5
New:
if a=1 then : b=1 else b=5 : end if
if a=1 then : b=1 : else : b=5 : end if
if a=1 : b=1 : else : b=5 : end if
-
Yes, else does not need a colon
1. I thought Pegge looked more an Italian, not Russian, last name to me. :D
1. OMFG! From bad to worse... Charles, you owe me two bottles of beer this evening. First, for all the hopes I lost in this discussion. And second, for the new brand name I invented for Oxygen: Crypt-o-BASIC!
I should sleep it off on a pill. See you tomorrow, gentlemen!
:D
-
Goodnight both,
Unfortunately, I have no beer in stock, though I have port and some brandy. But what you really need is some of my cocoa and ginger porridge. :)
Update:
http://www.oxygenbasic.org/o2zips/Oxygen.zip
PS:
To check which version of Oxygen you have:
print version
"A40 08:44 29/05/2014"
Further update.
This single liner format is now supported (no colons required)
if a=1 then b=2 else b=99 end if
as well as:
if a=1 then b=2 else b=99
Mike's original quest is also satisfied:
if a=1 then : b=1
c=2
end if
Also set a better trap for unclosed quotes
-
To check which version of Oxygen you have:...
This single liner format is now supported (no colons required)...
as well as:...
Mike's original quest is also satisfied:...
Also set a better trap for unclosed quotes
Hi Charles,
This looks much much better than a plate of ginger porridge or even two bottles of beer.
Thanks a lot! :D