Paste number 6236: Eiffel generics (from book)

Paste number 6236: Eiffel generics (from book)
Pasted by: tom_at_work
When:16 years, 7 months ago
Share:Tweet this! |
Paste contents:
Raw Source | XML | Display As
class STACK [G] feature
  count : INTEGER;
  put(x : G) is
end -- class stack

Using this class:

sp : STACK [POINT]; creates a stack of points

Eiffel also allows that:

sp : STACK [ LIST [POINT]]; creates a stack of lists of point

Eiffel also has constrained genericity:

class VECTOR [G -> NUMBER] 

The generic type must be of type number (or descendant) now.

[From "Object-Oriented Software Construction" Chapter 10, Chapter 16.4 respectively]

This paste has no annotations.

Colorize as:
Show Line Numbers

Lisppaste pastes can be made by anyone at any time. Imagine a fearsomely comprehensive disclaimer of liability. Now fear, comprehensively.