Converting my libraries to Void Safe raised questions

1 message Options
Embed this post
Permalink
Jimmy Johnson

Converting my libraries to Void Safe raised questions

Reply Threaded More More options
Print post
Permalink
The code is below.  My class MATRIX inherits from ARRAY2 keeping feature `make'.  Class ROW_MATRIX then inherits from MATRIX renaming `make' from ARRAY2 as `matrix_make' and restricts the export of that feature to {NONE}.
Class ROW_MATRIX then provides a new creation feature `make' which takes one argument (the number of columns), because the number of rows in the matrix must always be one.

Here is the problem when trying to convert to void safe.  Feature `resize' from ARRAY2 calls `make' (renamed as `matrix_make' here) in a create instruction for an object declared as like Current.  This give an expected "Creation instruction used call to improper feature".

What did this show up now?  This seems like an error wheather void-safe or not.  Could this have something to do with "full class checking" which I just turned on?

Number two.  Maybe someone can help me with the design flaw because now I am forced to add `matrix_make' as a creation feature, but this would allow a user to create a ROW_MATRIX with more than one row, violating the invariant.

This seems like a problem pattern to me.  The ancestor needs access to a feature for creation which otherwise should not be exported, even for creation.




class MATRIX inherit ARRAY2 ... end

class
  ROW_MATRIX
inherit MATRIX
  rename
    make as matrix_make  -- make was from ARRAY2
  export
    {NONE}
      matrix_make -- because the new make will take only one argument
  end
create
  make,
  matrix_make    -- must add but undesirable.

feature {NONE} -- Initialization
  make (a_number_columns: INTEGER)
    do
      matrix_make (1, a_number_columns)  
    end