Jump to content

Enforced immutability: Difference between revisions

added Factor
(→‎{{header|UNIX Shell}}: adding c shell)
(added Factor)
Line 345:
As a functional language, everything in F# is immutable by default. Interestingly, <code>const</code> is a reserved word but is non-functional.
<lang fsharp>let hello = "Hello!"</lang>
 
=={{header|Factor}}==
Tuple slots may be declared <code>read-only</code>. For example, the <code>range</code> class declares its slots <code>read-only</code>:
<lang factor>TUPLE: range
{ from read-only } { length read-only } { step read-only } ;</lang>
 
Note that the <code>CONSTANT:</code> word does nothing to enforce immutability on the object it places on the stack, as it is functionally equivalent to a standard word definition with stack effect <code>( -- obj )</code>.
 
=={{header|Go}}==
1,808

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.