Thread overview
Documentation Errata
Feb 23, 2004
Walter
Feb 24, 2004
Vathix
Feb 24, 2004
Walter
Another Documentation Error
Feb 25, 2004
Luke D
Feb 25, 2004
larry cowan
Feb 25, 2004
Luke D
Feb 26, 2004
Stewart Gordon
February 23, 2004
On the arrays page, a static array is shown as being declared like any dynamic array, but with a number of elements in the square brackets. AFAIK you need to use the 'static' keyword to actually declare a static array. This is done throughout the entire page.

Also, under 'Array Operations':

int[] def = { 1, 2, 3 };	// dynamic array of 3 ints

This should be

int[] def = [1, 2, 3];		// dynamic array of 3 ints

Cheers,
Sigbjørn Lund Olsen
February 23, 2004
"Sigbjørn Lund Olsen" <sigbjorn@lundolsen.net> wrote in message news:c1dl3u$2kmb$1@digitaldaemon.com...
> On the arrays page, a static array is shown as being declared like any dynamic array, but with a number of elements in the square brackets. AFAIK you need to use the 'static' keyword to actually declare a static array. This is done throughout the entire page.

The static keyword isn't necessary to do static arrays.


> Also, under 'Array Operations':
>
> int[] def = { 1, 2, 3 }; // dynamic array of 3 ints
>
> This should be
>
> int[] def = [1, 2, 3]; // dynamic array of 3 ints

Good catch. Thanks!


February 24, 2004
Walter wrote:
> "Sigbjørn Lund Olsen" <sigbjorn@lundolsen.net> wrote in message
> news:c1dl3u$2kmb$1@digitaldaemon.com...
> 
>>On the arrays page, a static array is shown as being declared like any
>>dynamic array, but with a number of elements in the square brackets.
>>AFAIK you need to use the 'static' keyword to actually declare a static
>>array. This is done throughout the entire page.
> 
> 
> The static keyword isn't necessary to do static arrays.

Why doesn't this work?:

// begin test.d
int main(char[][] args)
{
	ubyte[3] test = [2, 13, 9];
	return 0;
}
// end test.d

G:\Docs\Sigbjørn>dmd test.d
test.d(3): variable test is not a static and cannot have static initializer
February 24, 2004
Sigbjørn Lund Olsen wrote:

> Walter wrote:
> 
>> "Sigbjørn Lund Olsen" <sigbjorn@lundolsen.net> wrote in message
>> news:c1dl3u$2kmb$1@digitaldaemon.com...
>>
>>> On the arrays page, a static array is shown as being declared like any
>>> dynamic array, but with a number of elements in the square brackets.
>>> AFAIK you need to use the 'static' keyword to actually declare a static
>>> array. This is done throughout the entire page.
>>
>>
>>
>> The static keyword isn't necessary to do static arrays.
> 
> 
> Why doesn't this work?:
> 
> // begin test.d
> int main(char[][] args)
> {
>     ubyte[3] test = [2, 13, 9];
>     return 0;
> }
> // end test.d
> 
> G:\Docs\Sigbjørn>dmd test.d
> test.d(3): variable test is not a static and cannot have static initializer

I don't think initializing local arrays/structs like that is implemented yet.

-- 
Christopher E. Miller
www.dprogramming.com
irc.dprogramming.com #D
February 24, 2004
"Sigbjørn Lund Olsen" <sigbjorn@lundolsen.net> wrote in message news:c1fevg$2s1e$1@digitaldaemon.com...
> Walter wrote:
> > "Sigbjørn Lund Olsen" <sigbjorn@lundolsen.net> wrote in message news:c1dl3u$2kmb$1@digitaldaemon.com...
> >
> >>On the arrays page, a static array is shown as being declared like any dynamic array, but with a number of elements in the square brackets. AFAIK you need to use the 'static' keyword to actually declare a static array. This is done throughout the entire page.
> >
> >
> > The static keyword isn't necessary to do static arrays.
>
> Why doesn't this work?:
>
> // begin test.d
> int main(char[][] args)
> {
> ubyte[3] test = [2, 13, 9];
> return 0;
> }
> // end test.d
>
> G:\Docs\Sigbjørn>dmd test.d
> test.d(3): variable test is not a static and cannot have static
initializer

I see what you mean now. I had assumed you'd meant at global level, rather than at local level.


February 25, 2004
Sorry, didn't feel like starting another thread for documentation errors since this is a pretty minor one, but the names of the expressions on the expression page are messed up.  Sorry if you already know this, it seems like a pretty easy one to catch.

Luke D


February 25, 2004
Not sure what you mean, but I found:

1. ConditionalExpression:
OrOrExpression
OrOrExpression ? Expression : ConditionalExpression

should be    OrOrExpression ? Expression : Expression  , I think.

2. UnaryExpression:    seems to allow    y = ++ ++ -- ++ ++ -- -- x;

really?

3. PostfixExpression:   has similar problems.

4. AssertExpression: Is 'assert(a==b , c==d, e!=f);' a valid meaningful statement? Compiler doesn't seem to like it.

5. ArgumentList:  seems to be identical to 'Expression' in effect.

6. NewExpression:  'BasicType' doesn't seem to be defined.  Compiler will not accept 'int' in that context.

..and that's just on a quick run-thru.

In article <c1goi6$26o8$1@digitaldaemon.com>, Luke D says...
>
>Sorry, didn't feel like starting another thread for documentation errors since this is a pretty minor one, but the names of the expressions on the expression page are messed up.  Sorry if you already know this, it seems like a pretty easy one to catch.
>
>Luke D
>
>


February 25, 2004
Ah, you know what, I was really tired when I looked at it, and it just looked wrong to me.  It makes sense now.

larry cowan wrote:

> Not sure what you mean, but I found:
> 
> 1. ConditionalExpression:
> OrOrExpression
> OrOrExpression ? Expression : ConditionalExpression
> 
> should be    OrOrExpression ? Expression : Expression  , I think.
> 
> 2. UnaryExpression:    seems to allow    y = ++ ++ -- ++ ++ -- -- x;
> 
> really?
> 
> 3. PostfixExpression:   has similar problems.
> 
> 4. AssertExpression: Is 'assert(a==b , c==d, e!=f);' a valid meaningful
> statement? Compiler doesn't seem to like it.
> 
> 5. ArgumentList:  seems to be identical to 'Expression' in effect.
> 
> 6. NewExpression:  'BasicType' doesn't seem to be defined.  Compiler will not
> accept 'int' in that context.
> 
> ..and that's just on a quick run-thru.
> 
> In article <c1goi6$26o8$1@digitaldaemon.com>, Luke D says...
> 
>>Sorry, didn't feel like starting another thread for documentation errors since
>>this is a pretty minor one, but the names of the expressions on the expression
>>page are messed up.  Sorry if you already know this, it seems like a pretty easy
>>one to catch.
>>
>>Luke D
>>
>>
> 
> 
> 
February 26, 2004
larry cowan wrote:
> Not sure what you mean, but I found:
> 
> 1. ConditionalExpression:
> OrOrExpression
> OrOrExpression ? Expression : ConditionalExpression
> 
> should be    OrOrExpression ? Expression : Expression  , I think.

No, that would cause ambiguity

	qwert ? yuiop : asdfg = hjkl

Is this

	(qwert ? yuiop : asdfg) = hjkl

or

	qwert ? yuiop : (asdfg = hjkl)

?

> 2. UnaryExpression:    seems to allow    y = ++ ++ -- ++ ++ -- -- x;
> 
> really?

Yes, at the syntactic level, as opposed to the semantic.

> 3. PostfixExpression:   has similar problems.

And similar solutions.  There's no need to complicate the syntax just to catch errors that'll be caught during the semantic analysis, and for which syntax parsing isn't a general solution anyway.

> 4. AssertExpression: Is 'assert(a==b , c==d, e!=f);' a valid meaningful
> statement? Compiler doesn't seem to like it.

You're right, that ought to be valid.  Presumably comma expressions are _semantically_ forbidden in asserts, as are assignments.  If this is the case, there's actually nothing to lose by having defined

	AssertExpression:
		assert ( ConditionalExpression )

but again, it isn't a general solution.

> 5. ArgumentList:  seems to be identical to 'Expression' in effect.

No it isn't.

Read the individual subsections of the Expressions page explaining the semantics of each form.

> 6. NewExpression:  'BasicType' doesn't seem to be defined.  Compiler will not
> accept 'int' in that context.
<snip top of upside-down reply>

OK, so maybe you really have caught one....

Stewart.

-- 
My e-mail is valid but not my primary mailbox, aside from its being the unfortunate victim of intensive mail-bombing at the moment.  Please keep replies on the 'group where everyone may benefit.