Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Author
Message
Mike Johnson
TGC Developer
22
Years of Service
User Offline
Joined: 13th Sep 2002
Location: United Kingdom
Posted: 21st Jan 2011 10:56
Another thing that has been brought up is the use of brackets for commands / regular function calls. This would mean the likes of:

sync

Get changed to:

sync ( )

And commands like LoadImage go from:

LoadImage "your image.png", 1

to:

LoadImage ( "your image.png", 1 )

It will be useful to get an idea of numbers on this and whether the majority favour it. It's something that I am keen to see.
C0wbox
18
Years of Service
User Offline
Joined: 6th Jun 2006
Location: 0,50,-150
Posted: 21st Jan 2011 11:41
I think it'll depend on whether the language is trying to be more like C++ or more like DBP. (I wouldn't mind either.)

Green Gandalf
VIP Member
19
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 21st Jan 2011 12:00
I'm in favour.

A consistent rule would be especially useful to beginners - and the present mixture just occasionally catches me out too.

The advantages outweigh the disadvantages of awkward looking things like sync().

I guess you can't win though. Will we see a rash of newcomer questions along the lines of "why doesn't this work?":

baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 21st Jan 2011 12:01
Yes +1

I think consistancy is something missing from DBP too.

C0wbox
18
Years of Service
User Offline
Joined: 6th Jun 2006
Location: 0,50,-150
Posted: 21st Jan 2011 12:05 Edited at: 21st Jan 2011 12:06
If we're going with brackets for parameters is there a way to do it so that commands that don't have any parameters don't need brackets.

So that a program might look like this:


Instead of this:


baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 21st Jan 2011 12:22
Agreed C0wbox, that would be crazy!

dark coder
22
Years of Service
User Offline
Joined: 6th Oct 2002
Location: Japan
Posted: 21st Jan 2011 12:45
Quote: "I think it'll depend on whether the language is trying to be more like C++ or more like DBP. (I wouldn't mind either.)"


The programming language spectrum doesn't go from either DBPro to C++ you know... Making it so all function calls require brackets just makes the language more consistent and means a beginner doesn't have to remember as many rules.

Also, your second code example is completely wrong, if/else/select/endselect/case/endcase/endif/for/next/while/endwhile/repeat/until/do/loop are all flow control statements and not functions you call, so adding brackets to those doesn't make any sense.

Green Gandalf
VIP Member
19
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 21st Jan 2011 12:45
The problem with that is that a future language enhancement might introduce "sync(cameraId)" or "sync(cameraMask)". You'd then be faced with the possibility of either breaking everyone's old code or having two systems side by side.

No, if you're going to do it at all, do it consistently.
Kevin Picone
22
Years of Service
User Offline
Joined: 27th Aug 2002
Location: Australia
Posted: 21st Jan 2011 12:48
Sync is a function, it'd need brackets.

IanM
Retired Moderator
22
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 21st Jan 2011 13:41
Since I originally raised it, I'll have to vote 'yes' for this one.

Having a more consistent format for code will make it much easier to write tools that can reason about that code - that includes the compiler too, which should make it faster.

bitJericho
22
Years of Service
User Offline
Joined: 9th Oct 2002
Location: United States
Posted: 21st Jan 2011 14:31 Edited at: 21st Jan 2011 14:35
What? Brackets are for functions that return values.

So you should do this:

return = LoadImage(1, "filename")

where return is true on success, false on failure

and PureBasic allows the constant #PB_Any to be used in the object/image number, and the function will return the image number on success.

This is the best feature ever invented. I no longer have to worry about item/object numbers because I just store em in a variable.

This should be done in AppGameKit for sure!

[center]
Join the TGC Group!
http://tehcodez.groups.live.com
thenerd
15
Years of Service
User Offline
Joined: 9th Mar 2009
Location: Boston, USA
Posted: 21st Jan 2011 15:31
do()
something(1,2,3)
sync()
loop()

do and loop would not have brackets, because those are core parts of the language. Sync should though.

Diggsey
18
Years of Service
User Offline
Joined: 24th Apr 2006
Location: On this web page.
Posted: 21st Jan 2011 16:01
Yes

[b]
swissolo
14
Years of Service
User Offline
Joined: 9th Jan 2010
Location:
Posted: 21st Jan 2011 16:01
@thenerd:
Why would sync have brackets? Only commands requiring input should have them, because what use are the 2 brackets there?

Anyways I say...

YES! +1

swis
bitJericho
22
Years of Service
User Offline
Joined: 9th Oct 2002
Location: United States
Posted: 21st Jan 2011 16:07
Quote: "Why would sync have brackets? Only commands requiring input should have them, because what use are the 2 brackets there?"


I disagree, only commands that return values should have them!

[center]
Join the TGC Group!
http://tehcodez.groups.live.com
Diggsey
18
Years of Service
User Offline
Joined: 24th Apr 2006
Location: On this web page.
Posted: 21st Jan 2011 16:10
The brackets are there to show it's a function call. That it's going to run some other code which you may not have written. It shouldn't matter whether it returns a value or requires parameters or anything.

[b]
thenerd
15
Years of Service
User Offline
Joined: 9th Mar 2009
Location: Boston, USA
Posted: 21st Jan 2011 16:16
Quote: "The brackets are there to show it's a function call. That it's going to run some other code which you may not have written. It shouldn't matter whether it returns a value or requires parameters or anything."

This.

bitJericho
22
Years of Service
User Offline
Joined: 9th Oct 2002
Location: United States
Posted: 21st Jan 2011 16:49
Yeah, I could see it that way, but to me, it makes sense in basic if it's got brackets, it'll be returning a value of some kind.

val() returns a values
DO does not return a value

I'm of the opinion if you're making a function that doesn't return a value you're doing it wrong.

[center]
Join the TGC Group!
http://tehcodez.groups.live.com
Benjamin
21
Years of Service
User Offline
Joined: 24th Nov 2002
Location: France
Posted: 21st Jan 2011 17:02
Quote: "
DO does not return a value"


Green Gandalf
VIP Member
19
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 21st Jan 2011 17:18
Ditto.
Diggsey
18
Years of Service
User Offline
Joined: 24th Apr 2006
Location: On this web page.
Posted: 21st Jan 2011 17:27 Edited at: 21st Jan 2011 17:28
@Jerico2day
Yes, but your example of "DO" is not a function anyway so wouldn't have brackets. (Uh oh... just started the what is a function discussion again)

Using some real code as an example.
Without brackets:


With brackets:


[b]
Benjamin
21
Years of Service
User Offline
Joined: 24th Nov 2002
Location: France
Posted: 21st Jan 2011 17:30
On topic, for consistency I think it would be a good idea to use brackets all the time, even for functions that don't return values.
bitJericho
22
Years of Service
User Offline
Joined: 9th Oct 2002
Location: United States
Posted: 21st Jan 2011 18:15 Edited at: 21st Jan 2011 18:17
Quote: "function GetEscapeKey()
if escapekey()
while escapekey()
sleep(1)
endwhile
exitfunction 1
endif
endfunction 0"


Oh I see what you guys are saying.

Yeah, I'd prefer it either way then.

Use brackets when you want to return a value (even if you don't capture the value), and no brackets if you don't want to capture a value back.

So in effect, you can write your code either way as diggsey posted, only when you use the brackets, you can use a variable to capture whether the command was successful or not (or whatever the developer chose to return).

This is how it's done in a bunch of languages I've used.

[center]
Join the TGC Group!
http://tehcodez.groups.live.com
Diggsey
18
Years of Service
User Offline
Joined: 24th Apr 2006
Location: On this web page.
Posted: 21st Jan 2011 18:33 Edited at: 21st Jan 2011 18:33
Quote: "Oh I see what you guys are saying."


Not quite

We're saying you have to use brackets when calling other code.

The reason that "function", "endfunction", "while", "endwhile", "if", "endif", "exitfunction" don't use brackets is because they are not functions, whereas commands like "sync", "ink", "box", etc. ARE functions, so you must use brackets for them at all times.

The problem is that whereas in other languages, the distinction between a function and a word that is part of the language is fairly obvious, in DBPro it is difficult to explain the difference, since they are both highlighted in the same way in the editor, but I'll have a go anyway:

Commands like "sync" go and run some code. For the case of "sync", this code updates the screen, checks if the escape key was pressed, etc. but the main point is that when you write "sync" it runs some other code. The suggestion in this thread is that all of these commands should use brackets to call them.

Commands like "if" and "while" do not run any other code, they simply control the flow of the program. Without them the program would just run through from the first line to the last in order. These commands would never use brackets, because they cannot be "called". There is no code behind them which will run, they are what they are.

[b]
Fatal Berserker
14
Years of Service
User Offline
Joined: 2nd Jul 2010
Location:
Posted: 21st Jan 2011 21:42
Quote: "do
something(1,2,3)
sync
loop"


Why not:

do
{
something(1,2,3);
sync();
}

Diggsey
18
Years of Service
User Offline
Joined: 24th Apr 2006
Location: On this web page.
Posted: 21st Jan 2011 21:48
Because then we might as well use C++

I'm fairly sure TGC want to keep as close to BASIC as possible without sacrificing speed or power. Having brackets around all functions is not un-common among BASIC dialects, and actually makes the language more consistent, and therefore easier to use. And in the process, people will learn the difference between a function and a flow control statement

[b]
Green Gandalf
VIP Member
19
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 21st Jan 2011 21:53
Absolutely right.

Quote: "And in the process, people will learn the difference between a function and a flow control statement"


Even me perhaps?
LeeBamber
TGC Lead Developer
24
Years of Service
User Offline
Joined: 21st Jan 2000
Location: England
Posted: 21st Jan 2011 22:41
Sounds like most of us want the consistency of brackets for commands, but flow control statements should be left alone for the sake of sanity. An example of an AppGameKit program:

Do
a=10
For b=1 To 20
If MouseX()>100 Then Print ( MouseY() ) : c=MouseMoveX()
Sync()
Next b
Loop

I think the above looks MUCH better than:

Do()
A=10
For ( B=1 To 20 )
If ( MouseX()>100 ) Then Print ( MouseY() ) : C=MouseMoveX()
Sync()
Next ( B )
Loop()

More feedback most welcome!

I drink tea, and in my spare time I write software.
IanM
Retired Moderator
22
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 21st Jan 2011 22:56
Yes, I agree.

One quick question, about the example code you posted (first example), in particular the Print function - how are you planning on dealing with the newline/no-newline thing? Use an extra function like whey do in other languages? (Pascal Write/WriteLn => BASIC Print/PrintLn)

LeeBamber
TGC Lead Developer
24
Years of Service
User Offline
Joined: 21st Jan 2000
Location: England
Posted: 21st Jan 2011 22:58
Yes indeed. In DBP, there is already a command called PRINTC which does this concatenation feature, but the age old ; symbol provided us BASIC users with a cheat for many wonderful years

I drink tea, and in my spare time I write software.
Green Gandalf
VIP Member
19
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 21st Jan 2011 23:04
I agree too, but I don't recall anyone seriously suggesting this:

dark coder
22
Years of Service
User Offline
Joined: 6th Oct 2002
Location: Japan
Posted: 22nd Jan 2011 05:52
Also, requiring brackets would mean there would be no need for any concatenation symbol for multi-line statements, like:



Diggsey
18
Years of Service
User Offline
Joined: 24th Apr 2006
Location: On this web page.
Posted: 22nd Jan 2011 11:12
Might be difficult to parse statements such as this though:


Or this:


I think it would make the compiler too accepting. If you put that second code snippet in because you forgot to write the expression for "a" it would still compile fine.

[b]
dark coder
22
Years of Service
User Offline
Joined: 6th Oct 2002
Location: Japan
Posted: 22nd Jan 2011 12:00
I wasn't aware such assignments were a feature, in DBPro it compiles, but it doesn't seem to do anything. Even if it did, I don't really see the point of it.

bitJericho
22
Years of Service
User Offline
Joined: 9th Oct 2002
Location: United States
Posted: 22nd Jan 2011 12:06 Edited at: 22nd Jan 2011 12:06
No, I do get what you're saying. But if you look at DBP, brackets are used for functions returning values (or user made functions), and commands that don't use brackets don't return values.

I like it this way. I just wish more dbp commands took advantage of returning values for us to use in code.

[center]
Join the TGC Group!
http://tehcodez.groups.live.com
Diggsey
18
Years of Service
User Offline
Joined: 24th Apr 2006
Location: On this web page.
Posted: 22nd Jan 2011 12:06 Edited at: 22nd Jan 2011 12:07
@DC
It's a comparison!

a = b = 1 will set a to 1 if b is 1.

a = b = 3 will set a to 1 if b is 3
etc.

[b]
dark coder
22
Years of Service
User Offline
Joined: 6th Oct 2002
Location: Japan
Posted: 22nd Jan 2011 12:41
Quote: "@DC
It's a comparison!"


Oh, the joys of using = for both assignment and comparison .

bitJericho
22
Years of Service
User Offline
Joined: 9th Oct 2002
Location: United States
Posted: 22nd Jan 2011 13:28 Edited at: 22nd Jan 2011 13:32
There's three options, use different assignment operator or different comparison operators or use the same assignment and comparison operators.

A new assignment operator would take a long time for most people to adjust to, though is in my opinion the best option. A new assignment operator may be something like "<<" or "<-" or whatever.

A new comparison operator means that there will be errors when you mean to compare but you assign, but would be slightly easier to catch and wouldn't be misconstrued as a compiler bug. (== for comparison, = for assignment)

Or leave it as is in basic, ( = for assignment, = for comparison, and the only difference is context)

[center]
Join the TGC Group!
http://tehcodez.groups.live.com
Diggsey
18
Years of Service
User Offline
Joined: 24th Apr 2006
Location: On this web page.
Posted: 22nd Jan 2011 13:40
I think it should be left the same as it is

Maybe a shorter default line continuation character though...

[b]
Green Gandalf
VIP Member
19
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 22nd Jan 2011 13:43
Quote: "A new assignment operator would take a long time for most people to adjust to, though is in my opinion the best option. A new assignment operator may be something like "<<" or "<-" or whatever."


I agree, except ... The "<<" looks like "much less than" or perhaps "shift left twice" whereas the "<-" looks like "less than minus" so when I see "a<-b" I read that as the condition "a less than minus b". I have that difficulty with many of the composite symbolic operators - they just don't mean the right thing at first glance and I have to get the manual out. Very time-consuming.

One of the first languages I used had ":=" as the assignment operator and it was very convenient. Not sure I'd recommend it here though.

On balance, I'd still opt for

Quote: "Or leave it as is in basic, ( = for assignment, = for comparison, and the only difference is context)"
bitJericho
22
Years of Service
User Offline
Joined: 9th Oct 2002
Location: United States
Posted: 22nd Jan 2011 14:01
oh, I like :=

[center]
Join the TGC Group!
http://tehcodez.groups.live.com
Green Gandalf
VIP Member
19
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 22nd Jan 2011 14:36
I hesitate to suggest this, but

+1

[Not sure about the implications for colons though. ]
Benjamin
21
Years of Service
User Offline
Joined: 24th Nov 2002
Location: France
Posted: 22nd Jan 2011 14:39
Shouldn't this discussion be in the operators thread? It seems all the discussions are spilling over to each other.

Anyway I think := is ugly, personally.
Green Gandalf
VIP Member
19
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 22nd Jan 2011 14:42
Er, yes. I don't know how we got onto that in this thread. Sorry.

[Actually, I think it was Diggsey's post that inadvertently started it and then we all forgot what we should have been discussing.]
bitJericho
22
Years of Service
User Offline
Joined: 9th Oct 2002
Location: United States
Posted: 22nd Jan 2011 14:45
Considering we're all just surfing around all the threads, I'm both not surprised this happened nor am I particularly concerned

[center]
Join the TGC Group!
http://tehcodez.groups.live.com
Fatal Berserker
14
Years of Service
User Offline
Joined: 2nd Jul 2010
Location:
Posted: 22nd Jan 2011 20:39
Quote: "Anyway I think := is ugly, personally."

Especially if u want to append 3

The Slayer
Forum Vice President
15
Years of Service
User Offline
Joined: 9th Nov 2009
Playing: (Hide and) Seek and Destroy on my guitar!
Posted: 24th Jan 2011 02:39
I think that it would be a nice feature if the brackets (square or round), would be added automatically by the IDE after a reserved word (command). That would eliminate accidental typo errors, and increase typing speed.

Cheers

SLAYER RULES! YEAH, MAN!!
Fatal Berserker
14
Years of Service
User Offline
Joined: 2nd Jul 2010
Location:
Posted: 24th Jan 2011 10:44 Edited at: 24th Jan 2011 10:44
Quote: "I think that it would be a nice feature if the brackets (square or round), would be added automatically by the IDE after a reserved word (command). That would eliminate accidental typo errors, and increase typing speed."

If thats so, please make it optional. Because i will instinctivly type the bracket =p

Green Gandalf
VIP Member
19
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 24th Jan 2011 11:23
Quote: "Because i will instinctivly type the bracket"


Same here. I find autofill and autocomplete features to be very confusing.
Yodaman Jer
User Banned
Posted: 25th Jan 2011 18:57
Quote: "...i will instinctivly type the bracket"

"Same here. I find autofill and autocomplete features to be very confusi"



Yup, same here! In fact, last night I was programming some functions for my level editor, and I accidentally kept typing brackets after commands like "set camera view". I just got so used to typing brackets, and I had this discussion in my head, and as a result spent a lot of time fixing a ton of typos in my program.

I'm for brackets as well, and please make the autocomplete feature optional (if you choose to put it in at all).

Login to post a reply

Server time is: 2024-11-21 17:48:19
Your offset time is: 2024-11-21 17:48:19