#1. Question about different presentations of pointers in program

For example see code fragment, which build syntax tree for function. On C language it can be written as:

(1) word *P=&Dict[pFunc].pNode; (2) while (strcmp(Buff,"end")!=0) (-) { (3) *P= Ctrl(Buff); (4) P=&Node[*P].pRight; (-) }

On Context language:

(1) word @P=@Dict[pFunc].pNode; (2) while strcmp(@Buff,"end")!=0 do (3) P= Ctrl(@Buff); (4) @P=@Node[P].pRight; (5) end

In both fragments the assignment operators of value and address in lines 3 and 4 are written consciously with different indents. Other forms of writing of this actions also possible. What form of pointer definition and address assignment (lines 1 and 4) is presented for You as most comprehensible:

(A) word *P =&Dict[pFunc].pNode; (B) word @P =@Dict[pFunc].pNode; (C) word P^=@Dict[pFunc].pNode; (D) word P^= Dict[pFunc].pNode^;

Here Dict - array of struct, field pNode - word, @ - prefix, ^ - postfix address calculation operator.

#2. Question about control structures

In some programming languages ( C/C++/... ) operator brackets ( {..} / begin...end ) are used. To place more than one operator into control structure ( if / while / ... ) Yuo must use brackets. In other languages ( Modula/Basic/... ) any number of operators may be placed into control structure without brackets. In Pascal both variants are used ( while vs repeat/until ). If no brackets defined special keywords are used to close control structure ( end / endif / enddo / ... ). For example

while (Buff[I]!=0) // A - with brackets { if (Buff[I]=='\\') { K=I+1; } I++; } while Buff[I]!=#0 do // B - with common close keyword ( end ) if Buff[I]='\' then K=I+1; end inc I; end while Buff[I]!=#0 do // C - with different close keywords ( endif / enddo / ... ) if Buff[I]='\' then K=I+1; endif inc I; enddo while Buff[I]!=#0 do // D - with different close keyword pairs ( end if / end do / ... ) if Buff[I]='\' then K=I+1; end if inc I; end do

What form of control structures is presented for You as most suitable:

(A) Brackets (B) Common keyword (C) Different keywords (D) Different keyword pairs

Сайт создан в системе uCoz