|
Post by Carl Gundel on Jun 8, 2020 10:33:59 GMT -5
Let compare the following two lines:
LB 4.5.1 syntax:
#1.gb "down;place 1 1;color white;backcolor white;boxfilled 10 10;place 5 5"
Possible LB 5 syntax allowing cascading calls: #1.gb down(); place(1, 1); color("white"); backcolor("white"); boxfilled(10, 10); place(5, 5)
Current with LB 5 you need to do this:
#1.gb down() #1.gb place(1, 1) #1.gb color("white") #1.gb backcolor("white") #1.gb boxfilled(10, 10) #1.gb place(5, 5)
The legacy syntax is more compact, but as soon as you start adding variables it becomes hard to read:
Legacy syntax with some variables: #1.gb "down;place 1 1;color "; firstColor$; ";backcolor white;boxfilled "; boxX; " "; boxY; " ;place 5 5"
LB 5 cascading syntax with some variables: #1.gb down(); place(1, 1); color(firstColor$); backcolor("white"); boxfilled(boxX, boxY); place(5, 5)
In this case the LB 5 syntax is actually more compact, and definitely much more readable.
-Carl
|
|
|
Post by Rod on Jun 8, 2020 11:13:06 GMT -5
I like the last cascading syntax. I don’t like the line by line syntax. If I recall Chung had huge strings drawing graphics in 4.5 I think he implied it ran faster than line by line.
But for coding, cascading would be good, faster or not.
|
|
|
Post by Chris Iverson on Jun 8, 2020 11:18:15 GMT -5
Definitely like the cascading idea.
|
|
|
Post by Carl Gundel on Jun 8, 2020 11:28:45 GMT -5
I like the last cascading syntax. I don’t like the line by line syntax. If I recall Chung had huge strings drawing graphics in 4.5 I think he implied it ran faster than line by line. But for coding, cascading would be good, faster or not. Each syntax has its advantages. The new LB syntax is easier for a lot of people.
|
|
|
Post by tsh73 on Jun 8, 2020 17:03:57 GMT -5
I wonder about ( ; ) in cascading syntax.
Like, legacy:
#1.gb "down;place 1 1;color "; firstColor$ we make a big string, concatenating in via ( ; ) and feed it to graphicbox to handle There is clear reason We could take that string - print it to inspection - or store it and feed to some other graphicbox later. (and could make string UDF that will spill string of valid commands - and use it here)
Now, what ( ; ) stays in new syntax?
#1.gb down(); place(1, 1); color(firstColor$)
is separate pieces -
place(1, 1) a sub/function that could be used on it's own somehow?
Is there a way to make something in that syntax (like UDF) to make a things not existing yet, like say drawing a triangle?
|
|
|
Post by Chris Iverson on Jun 8, 2020 17:08:49 GMT -5
From what I can tell, a semicolon would be used as the separator between multiple chained graphics commands.
#1.gb down(); place(1, 1); color(firstColor$)
is equivalent to:
#1.gb down() #1.gb place(1, 1) #1.gb color(firstColor$)
The one question this brings up to me, now that I think about it, though:
Would graphics commands be the only thing that could be chained like that? Or could that be abstracted and applied to the general object syntax? Including user-made objects/modules when that winds up making it in?
For example, could do something like:
query$ = "some sql" #db execute(query$); disconnect()
To run a query and disconnect from a database.
|
|
|
Post by Carl Gundel on Jun 8, 2020 21:06:05 GMT -5
Would graphics commands be the only thing that could be chained like that? Or could that be abstracted and applied to the general object syntax? Including user-made objects/modules when that winds up making it in? For example, could do something like: query$ = "some sql" #db execute(query$); disconnect() To run a query and disconnect from a database. Yup, that's the idea.
|
|
|
Post by Brandon Parker on Jun 11, 2020 21:26:08 GMT -5
Why not simply use the line concatenator that is used in LB4? The colon ":" ...
The parser would simply send each subsequent command to the previously listed object until a new line is encountered or a new object is encountered.
Just a thought ...
{:0)
Brandon Parker
|
|
|
Post by Carl Gundel on Jun 13, 2020 10:42:02 GMT -5
Why not simply use the line concatenator that is used in LB4? The colon ":" ... The parser would simply send each subsequent command to the previously listed object until a new line is encountered or a new object is encountered. Just a thought ... {:0) Brandon Parker Maybe... or even a comma might work. thanks for the suggestion. For your consideration: #1.gb down(); place(1, 1); color(firstColor$)
#1.gb down() : place(1, 1) : color(firstColor$)
#1.gb down(), place(1, 1), color(firstColor$) I still prefer the semicolon, I must admit. The comma comes in second place for me. The use of a colon seems wrong because it is supposed to separate statements from each other, so this actually breaks with BASIC syntax by inventing a new use for it.
|
|
|
Post by Gordon Rahman on Jun 13, 2020 13:40:05 GMT -5
Carl,
I like the semicolon too. In line with LB4 drawing statements.
Gordon.
|
|
|
Post by tsh73 on Jun 13, 2020 16:03:53 GMT -5
semicolon does work with old drawing statements because it's line concatenation Here it does not have a reason it is used as new delimiter
as for colon should separate statements: does cascading syntax
#1.gb down(); place(1, 1); color(firstColor$)
in effect has same meaning as (VB-style)
WITH #1.gb down() place(1, 1) color(firstColor$) END WITH
Then each line is, in effect, a statement though compacted one (down() instead of #1.gb down() ) - but that was the point, in the first place.
|
|
|
Post by Gordon Rahman on Jun 13, 2020 16:20:10 GMT -5
Hello tsh73,
Good point. To copy/paste by the VB-style is as easy as copying a long line.
Gordon
p.s. How do you get those extra between-lines out here? I always have to edit my message here.
|
|