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.

AppGameKit Classic Chat / Array access

Author
Message
Mike Johnson
TGC Developer
21
Years of Service
User Offline
Joined: 13th Sep 2002
Location: United Kingdom
Posted: 21st Jan 2011 10:59
Seen some comments on array access and the use of square brackets. This would change the access from:

myArray ( 1 ) = "abc"

to:

myArray [ 1 ] = "abc"

To me the second method is much clearer and is more unlikely to cause confusion.
Scraggle
Moderator
20
Years of Service
User Offline
Joined: 10th Jul 2003
Location: Yorkshire
Posted: 21st Jan 2011 12:16
Definitely the second method especially if using brackets after all commands.

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

Agree +1

C0wbox
17
Years of Service
User Offline
Joined: 6th Jun 2006
Location: 0,50,-150
Posted: 21st Jan 2011 12:19
I spose the square brackets is a more logical way to do it, but I'm going to miss my curvy array brackets. <Sniff>

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:21
Yes.

Agree +1.
bitJericho
21
Years of Service
User Offline
Joined: 9th Oct 2002
Location: United States
Posted: 21st Jan 2011 13:20
Well, it is basic or some other language. Basic traditionally uses () symbols. I say stick with basic instead of turning the language into some other language. Unless it's not basic

[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:32
Quote: "I say stick with basic instead of turning the language into some other language. "


Why? I see no reason against altering the syntax if it makes the code more concise.
Fatal Berserker
13
Years of Service
User Offline
Joined: 2nd Jul 2010
Location:
Posted: 21st Jan 2011 21:47
It is better to have it on the level that most languages are.
Most people program in C# or C++. And to have to remember Dark Basic becomes a nightmare.

I used to program in Dark Basic Pro all the time, after a year or so of just C# and C++ programming i look back at it and it is an untidy mush.

Quote: "Why? I see no reason against altering the syntax if it makes the code more concise."


LeeBamber
TGC Lead Developer
24
Years of Service
User Offline
Joined: 21st Jan 2000
Location: England
Posted: 21st Jan 2011 22:44
Looks like square brackets are winning so far Any more votes for roundy ones?

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

TBH, it was probably only the lack of square-bracket keys on older keyboards that stopped the original Dartmouth College team from using them when they invented the language in the first place. If you use that as the excuse, then how can anyone complain?

Diggsey
17
Years of Service
User Offline
Joined: 24th Apr 2006
Location: On this web page.
Posted: 21st Jan 2011 23:22
I actually did lol at that

[b]
Kevin Picone
21
Years of Service
User Offline
Joined: 27th Aug 2002
Location: Australia
Posted: 21st Jan 2011 23:49
Quote: "To me the second method is much clearer and is more unlikely to cause confusion. "


only if for those that don't come from a BASIC gackground. It's just another rule change for the sake a rule change.

thenerd
15
Years of Service
User Offline
Joined: 9th Mar 2009
Location: Boston, USA
Posted: 22nd Jan 2011 00:50
Square brackets also make a lot of sense because they do not require the Shift key to use, which makes typing it a lot faster.

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 01:05
Quote: "It's just another rule change for the sake a rule change"


I don't think so. It makes the distinction between array references and function calls very obvious. We continually get problems with novice programmers who get confused between the two (due in part to the fact that the compiler cannot know which is intended when the array or function hasn't been declared - different brackets would help both the compiler and the user).
Kevin Picone
21
Years of Service
User Offline
Joined: 27th Aug 2002
Location: Australia
Posted: 22nd Jan 2011 01:49
You're making the assumption that end user 'understands' what an array or function is to begin with, which defeats the purpose. You end up two set of rules, one for arrays another for functions. Breaks the objective of simplifying the syntax.

From a compiler perspective, it's irrelevant as the 'type' of the keyword is already known. The only question would be if the parser is to support single up multiple instances of keywords within a modules/scopes. Which is where many such perceived issues stem from.

Diggsey
17
Years of Service
User Offline
Joined: 24th Apr 2006
Location: On this web page.
Posted: 22nd Jan 2011 01:52
No matter how much of a beginner you are, you simply cannot treat functions and arrays the same and expect it to work! Functions and arrays by their very nature require two sets of rules, so it makes sense to mirror their logical differences with differences in syntax.

[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 02:05
Precisely.
The Slayer
Forum Vice President
14
Years of Service
User Offline
Joined: 9th Nov 2009
Playing: (Hide and) Seek and Destroy on my guitar!
Posted: 22nd Jan 2011 03:05
Quote: "Square brackets also make a lot of sense because they do not require the Shift key to use, which makes typing it a lot faster."

That's not true. It may be like that on keyboards in the US, but not in other countries. On some keyboards you need to press the 'Alt Gr' button key to use the brackets, so it wouldn't be faster to type. So, changing the use of square brackets (to type faster) instead of round brackets, doesn't count everywhere.

Cheers

SLAYER RULES! YEAH, MAN!!
thenerd
15
Years of Service
User Offline
Joined: 9th Mar 2009
Location: Boston, USA
Posted: 22nd Jan 2011 03:37
Quote: "That's not true. It may be like that on keyboards in the US, but not in other countries. On some keyboards you need to press the 'Alt Gr' button key to use the brackets, so it wouldn't be faster to type. So, changing the use of square brackets (to type faster) instead of round brackets, doesn't count everywhere."

Oh... my mistake.

Brk_oth
18
Years of Service
User Offline
Joined: 8th Aug 2005
Location: Australia
Posted: 22nd Jan 2011 05:05
I vote for square brackets for arrays.
I believe it shall help new programmers to have a more distinct difference between arrays and functions.
Plus it is a standard for most other languages, which should narrow down confusion for people migrating between languages to the AppGameKit for the first time.

No signature found...
DMXtra
21
Years of Service
User Offline
Joined: 28th Aug 2002
Location: United States
Posted: 22nd Jan 2011 08:27
Here is my opinion....

So far we have been talking about using () for the commands, why not keep things consistent?

Yeah, sure the square brackets are easier to type, and yes it lets the arrays stand out from other commands, but really what is the point?

If you are going to be doing any programming in your life at all you are going to have to get into arrays at some point. Functions and arrays are not something that people would get mixed up over.

Consistency is more important. This is one of my biggest problems with Dark Basic, the syntax is not consistent.

I vote for the harder to type ()

Dark Basic Pro - The Bedroom Coder's Language of choice for the 21st Century.
dark coder
21
Years of Service
User Offline
Joined: 6th Oct 2002
Location: Japan
Posted: 22nd Jan 2011 08:38
That's the whole point, read Diggsey's post.

Kevin Picone
21
Years of Service
User Offline
Joined: 27th Aug 2002
Location: Australia
Posted: 22nd Jan 2011 10:34
Quote: " No matter how much of a beginner you are, you simply cannot treat functions and arrays the same and expect it to work!
Functions and arrays by their very nature require two sets of rules, so it makes sense to mirror their logical differences with differences in syntax."


A preference is one thing, and having tested this very change, the argument that the brackets simplify the concept of either arrays or functions is highly subjective.

If somebody is typing,

SomeFunction(someparameter) = SomeInputValue

Then clearly it's not the brackets at fault, rather their grasp of concept.

DMXtra
21
Years of Service
User Offline
Joined: 28th Aug 2002
Location: United States
Posted: 22nd Jan 2011 10:57
function blah ()
code...
endfunction

myarray (1) = "abc"

This is how it should be done, it is very consistent.

******************************

Check out Visual Basic Script Arrays:

<script type="text/vbscript">
Dim myArray(3)
myArray(0) = "Clean Underwear"
myArray(1) = "Vacuum Cleaner"
myArray(2) = "New Computer"
myArray(3) = "Talking Bass"
For Each present In myArray
document.write(present)
document.write("<br />")
Next
</script>

Dark Basic Pro - The Bedroom Coder's Language of choice for the 21st Century.
Diggsey
17
Years of Service
User Offline
Joined: 24th Apr 2006
Location: On this web page.
Posted: 22nd Jan 2011 11:28
Quote: "Then clearly it's not the brackets at fault, rather their grasp of concept."


That's exactly my point. Why even suggest to them in the first place that they are the same thing by using the same syntax?

Say I'm a beginner who has used functions but not arrays and I come across this code:


"items(0)" looks like a function call, so I would then carry on reading assuming that items() is a function.

If I came across this code:


I would wonder what the square brackets mean. I look at the help files and see that they are used for arrays, and now I can learn what they are, without getting myself completely confused about functions!

[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 11:53
I agree totally.
bitJericho
21
Years of Service
User Offline
Joined: 9th Oct 2002
Location: United States
Posted: 22nd Jan 2011 12:16 Edited at: 22nd Jan 2011 13:06
I'll change my vote to [edit: square] brackets. The more I think about it, the more I like it.

[center]
Join the TGC Group!
http://tehcodez.groups.live.com
Diggsey
17
Years of Service
User Offline
Joined: 24th Apr 2006
Location: On this web page.
Posted: 22nd Jan 2011 12:28
Uh, square or regular?

[b]
IanM
Retired Moderator
21
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 22nd Jan 2011 12:43
Personally, I don't mind too much either way, but then I use whichever one is in the current language I'm using anyway.

I do believe that square brackets are easier to parse from both a compiler and a beginners POV though.

Also, the 'have to press extra keys' is a nonsense excuse to use on either side of the argument - I haven't seen anyone make a point that we should use ' instead of " because ' doesn't need a shift on their keyboard. Or that we should replace the FUNCTION keyword with FN because it's shorter. Let's drop the bogus reasons shall we?

@DMExtra,
I could throw in an identically-acting piece of JScript as a counter example. Neither would give a reason to use one format over another. 'Argument from authority' is no argument at all.

Kevin Picone
21
Years of Service
User Offline
Joined: 27th Aug 2002
Location: Australia
Posted: 22nd Jan 2011 16:03
Diggsey,

erm, where is this Utopian world where users "look in the help files" you speak of ?

Quote: "
Why even suggest to them in the first place that they are the same thing by using the same syntax?
"


I understand where you're coming from, but it's not like an array or function materializes out of nowhere. If it's user defined, then it's declared inside the program, if it's a built it whatever, then there's IDE assisted help.

So if the only reasoning is that it might save some users a few trips to the help files ? - Then that doesn't seem like a strong argument for change to me.

Just to play devils advocate for a second, why not use [] for function calls and () for arrays ? - The reasoning is just as sound what's being proposed.


Quote: "I do believe that square brackets are easier to parse from both a compiler"


disagree.

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 16:30
Quote: "Just to play devils advocate for a second, why not use [] for function calls and () for arrays ? - The reasoning is just as sound what's being proposed."


Yes, since there's no essential difference, why not stick with the version that's been proposed?
Diggsey
17
Years of Service
User Offline
Joined: 24th Apr 2006
Location: On this web page.
Posted: 22nd Jan 2011 16:31
Quote: "Just to play devils advocate for a second, why not use [] for function calls and () for arrays ? - The reasoning is just as sound what's being proposed."


That would be just as good, were it not for the fact that every other language does the opposite, so why make life difficult?

[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 16:32
That too.

[I think he was just winding us up. ]
Diggsey
17
Years of Service
User Offline
Joined: 24th Apr 2006
Location: On this web page.
Posted: 22nd Jan 2011 16:35
Quote: "erm, where is this Utopian world where users "look in the help files" you speak of ?"


OK, they may post on the forum or something, but at least we'll get a question about what square brackets do, rather than some garbled nonsense about assigning values to a function. It's far more difficult to unlearn something than it is to learn it.

[b]
dark coder
21
Years of Service
User Offline
Joined: 6th Oct 2002
Location: Japan
Posted: 22nd Jan 2011 16:45 Edited at: 22nd Jan 2011 16:47
Quote: "So if the only reasoning is that it might save some users a few trips to the help files ? - Then that doesn't seem like a strong argument for change to me."


I don't think that was even the main reasoning to begin with, calling functions and accessing arrays are completely different concepts so they should be separated in terms of syntax is the main reason.

To put it another way, gosub and goto in DBPro are completely different concepts, but they both use the same syntax, except gosub's target label requires a return statement somewhere after the label. Yes, the user has written the gosub label with the paired return statement, but it's not immediately clear what's going on if you just see the label. This syntax change is the equivalent of proposing the gosub label/return construct be altered to be easily distinguishable from the goto label, because their usage is very different. (and yes, I think the gosub/goto should be changed so that goto uses the current label system and gosub no longer exists)


Quote: "Just to play devils advocate for a second, why not use [] for function calls and () for arrays ? - The reasoning is just as sound what's being proposed."


Why not replace the '=' assignment operator with 'pony'? Because no one else does.

swissolo
14
Years of Service
User Offline
Joined: 9th Jan 2010
Location:
Posted: 22nd Jan 2011 17:59
value pony 4...

could get used to it.

I don't think this is an improtant subject compared to the others, I like [] brackets, but it is rather insignifigant of a change. Either way is fine.

swis
Phaelax
DBPro Master
20
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 22nd Jan 2011 19:44
I vote for square brackets on arrays. When scanning over code, it makes it easier to pick out arrays from function calls.

"Only the educated are free" ~Epictetus
"Imagination is more important than knowledge..." ~Einstein
DMXtra
21
Years of Service
User Offline
Joined: 28th Aug 2002
Location: United States
Posted: 22nd Jan 2011 21:58
Well, it looks like it's going to be square brackets then.

I suppose it's not really that big of a deal as long as it's the only thing with square brackets.

Dark Basic Pro - The Bedroom Coder's Language of choice for the 21st Century.
Kevin Picone
21
Years of Service
User Offline
Joined: 27th Aug 2002
Location: Australia
Posted: 23rd Jan 2011 01:28
Quote: "That would be just as good, were it not for the fact that every other language does the opposite, so why make life difficult?"


By every, you mean conventions employed in none BASIC dialects.

According to TGC / LEE they seem fairly keen upon keeping some passing resemblance with BASIC.


Quote: "I don't think that was even the main reasoning to begin with, calling functions and accessing arrays are completely different concepts so they should be separated in terms of syntax is the main reason.
"


I understand the reasoning, but disagree that it enhances clarity significantly.


Quote: "Why not replace the '=' assignment operator with 'pony'? Because no one else does."


There's always one.

Diggsey
17
Years of Service
User Offline
Joined: 24th Apr 2006
Location: On this web page.
Posted: 23rd Jan 2011 01:36
Quote: "By every, you mean conventions employed in none BASIC dialects."


I'm sorry but I've never even heard of a BASIC dialect which uses [] for function calls and () for arrays.

Yes, there are some languages which use () for both
Yes, there are some languages which use [] for arrays and () for functions
But there are no languages I know of which use [] for functions and () for arrays. Therefore, as there's no point making life difficult, the choice is between using () for both or [] for arrays and () for functions.

Which is why your statement:
Quote: "Just to play devils advocate for a second, why not use [] for function calls and () for arrays ? - The reasoning is just as sound what's being proposed."


Is wrong.

[b]
Green Gandalf
VIP Member
19
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 23rd Jan 2011 01:42
It's not exactly "wrong". Just silly.
Diggsey
17
Years of Service
User Offline
Joined: 24th Apr 2006
Location: On this web page.
Posted: 23rd Jan 2011 01:47 Edited at: 23rd Jan 2011 01:47
Well he said "The reasoning is just as sound what's being proposed."

The reasoning is not just as sound because there is an extra reason not to do it that way, so he's wrong. Sorry to be picky but it's true

[b]
Green Gandalf
VIP Member
19
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 23rd Jan 2011 01:51
You're right. I was wrong as well.

As I've said on many an occasion it's past the witching hour here and I really shouldn't be posting this late.
Kevin Picone
21
Years of Service
User Offline
Joined: 27th Aug 2002
Location: Australia
Posted: 23rd Jan 2011 01:52
Quote: "I'm sorry but I've never even heard of a BASIC dialect which uses [] for function calls and () for arrays."


erm, and where exactly did I say there was ?

I'm not suggesting that either convention be adopted (far from it !), rather just demonstrating this is about following external conventions. Conventions which are not BASIC.

dark coder
21
Years of Service
User Offline
Joined: 6th Oct 2002
Location: Japan
Posted: 23rd Jan 2011 05:59
Quote: "Conventions which are not BASIC."


So what? This is just a simple syntax alteration that makes different concepts look different in usage, it doesn't change the code structure in any way. Your posts are all pretty much an 'appeal to popularity', which isn't an argument about why keeping the () syntax for array access is superior to the [] syntax. It's already been highlighted multiple times that using square bracket notation makes differentiating function calls from array access more apparent when they can otherwise look identical. So besides sticking to tradition, why keep it that way?

mr_d
DBPro Tool Maker
17
Years of Service
User Offline
Joined: 26th Mar 2007
Location: Somewhere In Australia
Posted: 24th Jan 2011 03:27
I have voted for the square brackets change in the online survey mainly for clarity reason (of arrays and functions).
DB(P)'s version of BASIC was never really standard anyway (e.g. the multiple keyword commands), so any changes that can simplify it further for both new users and experienced ones as well will get my vote.

(\___/)
(='.'=) Copy bunny into your signature to
("_(" help him gain world domination.
Zotoaster
19
Years of Service
User Offline
Joined: 20th Dec 2004
Location: Scotland
Posted: 25th Jan 2011 12:51
Quote: "Quote: "I do believe that square brackets are easier to parse from both a compiler"

disagree."


I disagree with your disagreement

"everyone forgets a semi-colon sometimes." - Phaelax
Kevin Picone
21
Years of Service
User Offline
Joined: 27th Aug 2002
Location: Australia
Posted: 25th Jan 2011 12:58
I'll bite, upon what basis ?

Zotoaster
19
Years of Service
User Offline
Joined: 20th Dec 2004
Location: Scotland
Posted: 25th Jan 2011 13:04
I'm not talking strictly parsing the brackets. As far as a compiler is concerned, () is just as easy as []. But as this discussion is going on about, the types of the brackets show what type of operation you're performing. If you try and read a value from an undeclared array, then at least it knows you're trying to access an array, rather than call a function

"everyone forgets a semi-colon sometimes." - Phaelax
Kevin Picone
21
Years of Service
User Offline
Joined: 27th Aug 2002
Location: Australia
Posted: 25th Jan 2011 13:27
So I take it, you're working upon the assumption that function and array names are allowed to overlap ?

Dim Type[100]
Print(Type[0])

Can't imagine this being supported. It's more likely to use single instance keywords, so any old binary chop, or LUT will pull a matched in virtually fixed time.

Login to post a reply

Server time is: 2024-04-16 07:53:28
Your offset time is: 2024-04-16 07:53:28