Am 05.12.2016 12:01 schrieb "denisgolovan" <denisgolo...@yandex.ru>: > > > 05.12.2016, 13:35, "Sven Barth" <pascaldra...@googlemail.com>: >> >> I really don't get why some people think of generics as complex -.- > > > Exactly for the cited reason. See below. > > > Using plain old arrays, requires reinventing the wheel because you end up > > writing duplicate functions for each array type (array of string) instead > > of a general purpose algorithm for many types.. > > It's not possible to get uniform interfaces that would play nice with algorithms. > > Try writing a _single_ function for sorting static arrays, dynamic arrays,open arrays, generic containers(T*List * all value types). > The standard recipe is re-implement everything from scratch over and over again. > Even now, when we have generic functions - I am forced to specialize them by hand! Even C# got it right... > Another issue is that some special functions are considered "special" - you cannot overload them (SetLength, Copy, ...). > Yet another thing is that arrays are nice value-pretending types (refcouting), but most generics are classes! > We desperately need http://bugs.freepascal.org/view.php?id=30687 to get record based generics value types back to the language. > > Basically it's all about combinatorics when combining functions. > Either compiler does it for you, or you are forced to do it manually instead. > > To sum up, generics in current implementation add too little while exploding combinatorial variety of algorithms. >
Again: I don't see why anyone thinks of generics as complex. Your mail did not answer that in any way. Regards, Sven
_______________________________________________ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal