Le 10/02/2012 23:36, Fabián Flores Vadell a écrit : > 2012/2/10 Emil Lenngren<emil.lenng...@gmail.com> > >> Can you give some examples how you mean? >> What do you need wrappers for? >> I don't think I understand fully what you mean, but it seems interesting :) >> >> /Emil >> > > I would like to show you an example, but I can't. > If I did, I would have to kill you. :P > > > > > > There is a foolish example: > > > '***************** > ' Class Person > '***************** > > $FirstName As String > $LastName As String > > Property Read FirstName As String > Property Read LastName As String > > Public Sub _new(fname As String, lname As String) > $FirstName = fname > $LastName = lname > End > > Private Function FirstName_Read() As String > Return $FirstName > End > > Private Function LastName_Read() As String > Return $LastName > End > > '********************* > ' PeopleList class > '********************* > > 'aPeople is a collaborator from which I want to expose some methods (by the > PeopleList message protocol) > > Private $aPeople As New Person[] > > 'The Call method implement the "instrospective call" "pattern" (okay, I > just made it up... but it works!) > > Public Sub Call(aMethodName As String, Optional arguments As Array = Null) > As Variant > Dim result As Variant > > If Not [Add, Clear, Count, Insert, {Max}].Exist(aMethodName) Then Return > > Object.Call($aPeople, aMethodName, arguments) > > Catch > Return Object.GetProperty($aPeople, aMethodName) > End > > 'I want avoid code like this: > > ' Public Sub Add(aPerson As Person) > ' $aPeople.Add(aPerson) > ' End > ' > ' Public Sub Insert(arrayPerson As Person[]) > ' $aPeople.Insert(arrayPerson) > ' End > ' > ' Public Sub Clear() > ' $aPeople.Clear > ' End > ' > ' Property Read Max > ' > ' Private Function Max_Read() > ' $aPeople.Max > ' End > ' > 'and so on
I don't understand why you want to avoid code like this. This is the best way to implement a PeopleList class. -- Benoît Minisini ------------------------------------------------------------------------------ Virtualization & Cloud Management Using Capacity Planning Cloud computing makes use of virtualization - but cloud computing also focuses on allowing computing to be delivered as a service. http://www.accelacomm.com/jaw/sfnl/114/51521223/ _______________________________________________ Gambas-user mailing list Gambas-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/gambas-user