Spinroot

A forum for Spin users

You are not logged in.

#1 2011-08-19 08:39:32

KeesPronk
Member
Registered: 2011-01-04
Posts: 12

Inconsistency in for-loop descrption/grammar

In [url]http://spinroot.com/spin/Man/for.html[/url] the second grammar line states that one should use the colon in the for statement for arrays:
   for '(' varref ':' array ')' '{' sequence '}'  .

However, the example given a little later shows that one should use the 'in' keyword.

      int a[10];
    for (i in a) {
        printf("i = %d\n", i)
    }


This problem is also in the grammar in [url]http://spinroot.com/spin/Man/grammar.html[/url] .

As an aside, the examples would be slightly more self-explanatory if they would show that one needs to declare the loop control variable.

Kees.

Offline

#2 2011-08-19 16:07:48

spinroot
forum
Registered: 2010-11-18
Posts: 691
Website

Re: Inconsistency in for-loop descrption/grammar

Thanks for pointing this out!
It's fixed.

Offline

#3 2011-08-25 21:20:42

KeesPronk
Member
Registered: 2011-01-04
Posts: 12

Re: Inconsistency in for-loop descrption/grammar

As far as i understand things:

The second line in the grammar

range    : varref ':' expr '..' expr
            | varref ':' varref                                 // this line may be deleted now
            | varref IN varref

may now be deleted.

Offline

#4 2011-08-27 00:30:09

spinroot
forum
Registered: 2010-11-18
Posts: 691
Website

Re: Inconsistency in for-loop descrption/grammar

okay -- it's gone

Offline

Board footer

Powered by FluxBB