Static arrays syntax

After my previous post about the perfect vector/array syntax, I’ve been wondering about static arrays. That means fixed-size arrays that are usually allocated on the stack.

Currently I’m leaning on the following syntax for vectors (dynamically resizable arrays):

[Tester] testers

So what about those static arrays? Maybe something like:

[Tester, 4] testers

Hmm. Is that pretty or is that ugly? I don’t know…

One option would be to do what D programming language does:

//dynamic arrays:
Tester[] testers
//static arrays:
Tester[4] testers

That surely looks more familiar and traditional. But is it really any better? And is there a reason to change it? The freshness of the newer syntax? All the lines of D code, that I’ll have to rewrite with the new array syntax? But now I’m forgetting my previous posts arguments that led to this new syntax in the first place:
Rae has “opt” and “val” and “link” storage/type specifiers which affect what properties a “reference” has. When we do something like:

protected opt Tester[] testers

It is not clear what that opt refers to. That’s why our arrays also need to be prefix rather than postfix.

So, again, maybe this could still be the best syntax for Rae:

//values are default now: val[val Tester] testers
[Tester] testers
//so, static array: val[val Tester, 4] testers would be:
[Tester, 4] testers
//link to a static array containing values:
link[Tester, 4] testers
//and the most dynamic of all arrays,
//the optionally existing resizable array of optional objects: 
opt[opt Tester] maybeTesters

P.S.
How about for loops then:

for(ref Tester a_tester, testers)
{
  a_tester.doSomething
}

And should that “ref” be automatic for function arguments and foreach loops such as this one. So you’d only have to define it for arrays of opts (use link to traverse it) or arrays of links (again use link to traverse).

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s