3 ms·
> This isn't true of Ada, Modula-3 or Eiffel generics. I'm not familiar with those languages, but it appears that Eiffel and Modula-3 generics only work with b
by smitherfield 10y ago
> This isn't true of Ada, Modula-3 or Eiffel generics.
I'm not familiar with those languages, but it appears that Eiffel and Modula-3 generics only work with boxed (implemented as pass-by-reference) types, and Eiffel doesn't have pass-by-value types at all.
It does look like Ada generics fulfil those three conditions.
- pjmlp 10y agoIn Eiffel, a value type is known as an expanded class and it can be given as default class attribute, or when declaring a variable. So generic instantiation will do the right thing depending on the class attributes. Modula-3 supports value types just like any Algol language, you just need to provide the types you want when instatiating a generic module interface. Modula-3 generics work at module level. Here is an example for numeric types, with a generic module for all numeric operations: https://github.com/modula3/cm3/blob/d31f6ca184c66755317ba990a2bd6fb2f0af7f0c/m3-libs/m3core/src/word/GenWord.ig https://github.com/modula3/cm3/blob/d31f6ca184c66755317ba990... Specialized to LONGINT. https://github.com/modula3/cm3/blob/d31f6ca184c66755317ba990a2bd6fb2f0af7f0c/m3-libs/m3core/src/word/Long.i3 https://github.com/modula3/cm3/blob/d31f6ca184c66755317ba990... https://github.com/modula3/cm3/blob/d31f6ca184c66755317ba990a2bd6fb2f0af7f0c/m3-libs/m3core/src/word/LongRep.i3 https://github.com/modula3/cm3/blob/d31f6ca184c66755317ba990... It is a bit convoluted, but it isn't easy to track down a simple example.