Hi!

----

The following example...
-- snip --
namespace chessengine
{
        typeset -T board_t=(
                compound -a b

                function create
                {
                        tower_t    _.b[0][0].figure
                        knight_t   _.b[0][1].figure
                        bishop_t   _.b[0][2].figure
                        queen_t    _.b[0][3].figure
                        king_t     _.b[0][4].figure
                        bishop_t   _.b[0][5].figure
                        knight_t   _.b[0][6].figure
                        tower_t    _.b[0][7].figure
                        for ((i=0 ; i < 8 ; i++ )) ; do
                                pawn_t  _.b[1][i].figure
                        done
                }
        
                function move
                {
                        integer f_x=$1
                        integer f_y=$2
                        integer t_x=$3
                        integer t_y=$4

                        if [[ -v _.b[t_x][t_y].figure ]] ; then
                                printf $"Can't move to %d/%d, field blocked\n" 
t_x t_y
                                return 1
                        fi
                        if [[ ! -v _.b[f_x][f_y].figure ]] ; then
                                printf $"No chesspiece at %d/%d\n" f_x f_y
                                return 1
                        fi
        
                        typeset -m "_.b[t_x][t_y].figure=_.b[f_x][f_y].figure"
                        unset "_.b[f_x][f_y]"
                        return 0
                }
        )

        typeset -T tower_t=(
                typeset name='Tower'
        )
        typeset -T knight_t=(
                typeset name='Knight'
        )
        typeset -T bishop_t=(
                typeset name='Bishop'
        )
        typeset -T queen_t=(
                typeset name='Queen'
        )
        typeset -T king_t=(
                typeset name='King'
        )
        typeset -T pawn_t=(
                typeset name='Pawn'
        )

}

function main
{
        compound c
        .chessengine.board_t c.board
        

#       c.board.move 1 7 3 7
#       c.board.move 0 7 2 7
#       c.board.move 2 7 2 0
#       c.board.move 2 0 0 0
        
        print -v c
}

main
-- snip --

... should AFAIK print this...
-- snip --
        board_t board=(
                typeset -C -a b=(
                        [0]=(
                                (
                                        tower_t figure=(
                                                name=Tower
                                        )
                                )
                                (
                                        knight_t figure=(
                                                name=Knight
                                        )
                                )
                                (
                                        bishop_t figure=(
                                                name=Bishop
                                        )
                                )
                                (
                                        queen_t figure=(
                                                name=Queen
                                        )
                                )
                                (
                                        king_t figure=(
                                                name=King
                                        )
                                )
                                (
                                        bishop_t figure=(
                                                name=Bishop
                                        )
                                )
                                (
                                        knight_t figure=(
                                                name=Knight
                                        )
                                )
                                (
                                        tower_t figure=(
                                                name=Tower
                                        )
                                )
                        )
[1]=(
                                (
                                        pawn_t figure=(
                                                name=Pawn
                                        )
                                )
                                (
                                        pawn_t figure=(
                                                name=Pawn
                                        )
                                )
                                (
                                        pawn_t figure=(
                                                name=Pawn
                                        )
                                )
                                (
                                        pawn_t figure=(
                                                name=Pawn
                                        )
                                )
                                (
                                        pawn_t figure=(
                                                name=Pawn
                                        )
                                )
                                (
                                        pawn_t figure=(
                                                name=Pawn
                                        )
                                )
                                (
                                        pawn_t figure=(
                                                name=Pawn
                                        )
                                )
                                (
                                        pawn_t figure=(
                                                name=Pawn
                                        )
                                )
                        )
                )
        )
)
-- snip --

... but ast-ksh.2013-07-27 on SuSE 12.3/AMD64/64bit prints:

-- snip --
(
        board_t board=(
                typeset -C -a b=(
                        (
                                (
                                )
                                (
                                )
                                (
                                )
                                (
                                )
                                (
                                )
                                (
                                )
                                (
                                )
                                (
                                )
                        )
                        (
                                (
                                )
                                (
                                )
                                (
                                )
                                (
                                )
                                (
                                )
                                (
                                )
                                (
                                )
                                (
                                )
                        )
                )
        )
)
-- snip --

The issue here seems to be that .chessengine.board_t.create doesn't
search the namespace "chessengine" for types... ;-(

----

Bye,
Roland

-- 
  __ .  . __
 (o.\ \/ /.o) [email protected]
  \__\/\/__/  MPEG specialist, C&&JAVA&&Sun&&Unix programmer
  /O /==\ O\  TEL +49 641 3992797
 (;O/ \/ \O;)
_______________________________________________
ast-developers mailing list
[email protected]
http://lists.research.att.com/mailman/listinfo/ast-developers

Reply via email to