Sealed classes and methods: Difference between revisions

m
julia example
(Created Nim solution.)
m (julia example)
Line 79:
 
J does not provide a mechanism to seal individual methods.
 
=={{header|Julia}}==
Julia's multiple dispatch and type system sit firmly outside the context within which sealed (non-inheritable) classes make sense.
 
First, within Julia's class type system, all inheritance is between abstract types. Objects can have inheritance from abstract types, but objects cannot inherit from other objects. Thus, in Julia, all concrete objects are final.
 
Second, because of Julia's multiple dispatch, all object methods (except certain constructors, called inner constructors) can be overloaded within user code. Thus, only inner construction methods are final methods.
 
Thus, Julia both enforces a kind of sealed classes for inheritance with all of its objects (the first above) and yet prevents any simple sealing for those same objects' methods (the second above).
 
=={{header|Nim}}==
4,102

edits