Good morning Clinton,

I am getting some unexpected anomalous results with the following unicon file. Please note that I have stripped the file to it barest essentials to show the problem. I have created a class with a set of methods. One of those methods returns a list that contains a specific selection of the methods. The anomalous result is that when looking at the contents of the returned list, I am not getting the methods expected, there are other values being returned in the list. I have attached the output from the test run to show this.

The first list element should be the method Size but I get CopyMatrix instead. In addition, I get the class constructor Matrix__state as a recurring element of the list. Is there some peculiarity of class construction and use that I am missing?

regards

Bruce Rennie

CODE #############################3

link ximage

class Matrix(_RxC_, _sizerows_ ,_sizecols_, _formatwidth_)
    method Size()
     end
    method Rows()
    end
    method Cols()
    end
    method Row(i)
    end
    method Col(j)
    end

    method Copy()
    end

    method CopyMatrix(m)
    end

    method Transpose()
    end

    method ToString()
    end

    method ToList(m)
    end

    method ToListCO(m)
    end

    method _tolistRO(m)
    end

    method _tolistCO(m)
    end

    method _size(l)
    end

    method _extendlist(l, sz)
    end

    method SetDisplayWidth(n)
    end

    method AvailableMethods()
return [Size, Rows, Cols, Row, Col, Copy, CopyMatrix, Transpose, ToString, ToList, ToListCO, SetDisplayWidth]
    end

initially(listels, listsize)
end

invocable all

procedure main()
    local m1, g, l, f
    f := open("test output.txt", "wt")
    m1 := Matrix()
    every g := globalnames() do write(f, ximage(variable(g)))
    write(f, "Class Methods")
    l := m1.AvailableMethods()
    write(f, "Size of l:", *l)
    every g := !l do write(f, ximage(g))
    every g := 1 to *l do write(f, "l[", g, "]:\n", ximage(l[g]), "\n\n")
    write(f, ximage(l))

end

TEST OUTPUT #######################################

procedure main
class constructor Matrix__state
record constructor Matrix__methods
procedure Matrix_Size
procedure Matrix_Rows
procedure Matrix_Cols
procedure Matrix_Row
procedure Matrix_Col
procedure Matrix_Copy
procedure Matrix_CopyMatrix
procedure Matrix_Transpose
procedure Matrix_ToString
procedure Matrix_ToList
procedure Matrix_ToListCO
procedure Matrix__tolistRO
procedure Matrix__tolistCO
procedure Matrix__size
procedure Matrix__extendlist
procedure Matrix_SetDisplayWidth
procedure Matrix_AvailableMethods
procedure Matrix_initially
R_Matrix__methods_1 := Matrix__methods()
   R_Matrix__methods_1.Size := procedure Matrix_Size
   R_Matrix__methods_1.Rows := procedure Matrix_Rows
   R_Matrix__methods_1.Cols := procedure Matrix_Cols
   R_Matrix__methods_1.Row := procedure Matrix_Row
   R_Matrix__methods_1.Col := procedure Matrix_Col
   R_Matrix__methods_1.Copy := procedure Matrix_Copy
   R_Matrix__methods_1.CopyMatrix := procedure Matrix_CopyMatrix
   R_Matrix__methods_1.Transpose := procedure Matrix_Transpose
   R_Matrix__methods_1.ToString := procedure Matrix_ToString
   R_Matrix__methods_1.ToList := procedure Matrix_ToList
   R_Matrix__methods_1.ToListCO := procedure Matrix_ToListCO
   R_Matrix__methods_1._tolistRO := procedure Matrix__tolistRO
   R_Matrix__methods_1._tolistCO := procedure Matrix__tolistCO
   R_Matrix__methods_1._size := procedure Matrix__size
   R_Matrix__methods_1._extendlist := procedure Matrix__extendlist
   R_Matrix__methods_1.SetDisplayWidth := procedure Matrix_SetDisplayWidth
R_Matrix__methods_1.AvailableMethods := procedure Matrix_AvailableMethods
   R_Matrix__methods_1.initially := procedure Matrix_initially
procedure Matrix
procedure Matrixinitialize
procedure ximage
procedure xdump
function open
function globalnames
function write
function variable
function proc
function table
function type
function image
function tab
function find
function sort
function any
function move
Class Methods
Size of l:12
procedure Matrix_CopyMatrix
R_Matrix__state_1 := Matrix__state()
procedure Matrix_Transpose
R_Matrix__state_1 := Matrix__state()
procedure Matrix_ToString
R_Matrix__state_1 := Matrix__state()
procedure Matrix_ToList
R_Matrix__state_1 := Matrix__state()
procedure Matrix_ToListCO
R_Matrix__state_1 := Matrix__state()
procedure Matrix_SetDisplayWidth
R_Matrix__state_1 := Matrix__state()
l[1]:
procedure Matrix_CopyMatrix


l[2]:
R_Matrix__state_1 := Matrix__state()


l[3]:
procedure Matrix_Transpose


l[4]:
R_Matrix__state_1 := Matrix__state()


l[5]:
procedure Matrix_ToString


l[6]:
R_Matrix__state_1 := Matrix__state()


l[7]:
procedure Matrix_ToList


l[8]:
R_Matrix__state_1 := Matrix__state()


l[9]:
procedure Matrix_ToListCO


l[10]:
R_Matrix__state_1 := Matrix__state()


l[11]:
procedure Matrix_SetDisplayWidth


l[12]:
R_Matrix__state_1 := Matrix__state()


L1 := list(12,{R_Matrix__state_1 := Matrix__state()
      R_Matrix__state_1})
   L1[1] := procedure Matrix_CopyMatrix
   L1[3] := procedure Matrix_Transpose
   L1[5] := procedure Matrix_ToString
   L1[7] := procedure Matrix_ToList
   L1[9] := procedure Matrix_ToListCO
   L1[11] := procedure Matrix_SetDisplayWidth



On 09/04/13 04:59, Clinton Jeffery wrote:
Bruce,

It is moderately easy to filter the whole list of global names to find only the procedure-valued items, using image() and variable(), e.g.

every g := globalnames() do write(image(variable(g)))

There are some subtleties for class methods, they are not quite the same as procedures since they require a compatible object instance in order to call them, but I am not sure how much you already know about that. Feel free to ask followup questions.

Clint


On Sun, Apr 7, 2013 at 7:28 PM, Bruce & Breeanna Rennie <bren...@dcsi.net.au <mailto:bren...@dcsi.net.au>> wrote:

    Good morning to all,

    I have a method in a class I am developing that returns a list of
    available methods. The class has a number of other methods which
    are not
    in this list.

    For debugging purposes, I would like to get the names of the
    associated
    methods in a similar vein to name() or methodnames(). That is when one
    of these returned values from the list is supplied as a parameter
    then I
    would like to get the name of the method. Is there a simple way to do
    this? An additional question relates to getting the current list of
    classes that are in the current program?

    regards

    Bruce Rennie

    
------------------------------------------------------------------------------
    Minimize network downtime and maximize team effectiveness.
    Reduce network management and security costs.Learn how to hire
    the most talented Cisco Certified professionals. Visit the
    Employer Resources Portal
    http://www.cisco.com/web/learning/employer_resources/index.html
    _______________________________________________
    Unicon-group mailing list
    Unicon-group@lists.sourceforge.net
    <mailto:Unicon-group@lists.sourceforge.net>
    https://lists.sourceforge.net/lists/listinfo/unicon-group




------------------------------------------------------------------------------
Minimize network downtime and maximize team effectiveness.
Reduce network management and security costs.Learn how to hire
the most talented Cisco Certified professionals. Visit the
Employer Resources Portal
http://www.cisco.com/web/learning/employer_resources/index.html


_______________________________________________
Unicon-group mailing list
Unicon-group@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/unicon-group

------------------------------------------------------------------------------
Precog is a next-generation analytics platform capable of advanced
analytics on semi-structured data. The platform includes APIs for building
apps and a phenomenal toolset for data science. Developers can use
our toolset for easy data analysis & visualization. Get a free account!
http://www2.precog.com/precogplatform/slashdotnewsletter
_______________________________________________
Unicon-group mailing list
Unicon-group@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/unicon-group

Reply via email to