Plange


a function object that can be cast to any function type, and throws when invoked

Notes

The abstract keyword is used to declare interfaces that will be implemented by derived types. This information is also used by the compiler to detect attempts to instantiate types with abstract members.

Example

//Base type
Animal := type {
	<Void → Void> speak ← abstract; //there is no default implementation
};

//Derived type
Cat := type inheriting Animal {
	speak ← { Meow(); }; //override the inherited speak method
};

<List<Animal> → Void> choir := (animals) {    
	for (animal in animals) {
		animal.speak();
	}
};

<Cat> bernard;
<Cat> russel;
List<Cat> kittehs := [ bernard, russel ];
choir(kittehs); //covariant argument
			

copyright © Brent Lewis 2017