Just another update
This commit is contained in:
parent
a25938f123
commit
00a190b0a6
6591 changed files with 94363 additions and 23227 deletions
|
|
@ -1,2 +1 @@
|
|||
Demonstrate any means your language has to prevent the modification of values, or to create objects that cannot be modified after they have been created.
|
||||
{{omit from|MUMPS}} <!-- All variables can be altered. -->
|
||||
|
|
|
|||
4
Task/Enforced-immutability/00META.yaml
Normal file
4
Task/Enforced-immutability/00META.yaml
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
---
|
||||
category:
|
||||
- Initialization
|
||||
note: Enforced immutability
|
||||
|
|
@ -0,0 +1 @@
|
|||
real, parameter :: pi = 3.141593
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
subroutine sub1(n)
|
||||
real, intent(in) :: n
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
*process source attributes xref;
|
||||
constants: Proc Options(main);
|
||||
Dcl three Bin Fixed(15) Value(3);
|
||||
Put Skip List(1/three);
|
||||
Put Skip List(1/3);
|
||||
End;
|
||||
|
|
@ -1,2 +1 @@
|
|||
my $pi is readonly = 3 + rand;
|
||||
my $pi ::= 3 + rand; # same thing, SSA-ish form
|
||||
my $pi ::= 3 + rand;
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
puts msg = "Hello World"
|
||||
msg = "Hello World"
|
||||
msg << "!"
|
||||
puts msg #=> Hello World!
|
||||
|
||||
|
|
@ -12,10 +12,9 @@ rescue => e
|
|||
end
|
||||
|
||||
puts msg #=> Hello World!
|
||||
|
||||
msg2 = msg
|
||||
|
||||
# An object is frozen and it is not a variable.
|
||||
# The object is frozen, not the variable.
|
||||
msg = "hello world" # A new object was assigned to the variable.
|
||||
|
||||
puts msg.frozen? #=> false
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
# There are two methods in the copy of the object.
|
||||
msg = "Hello World!".freeze
|
||||
msg2 = msg.clone # Copies the frozen and tainted state of obj.
|
||||
msg3 = msg.dup # It doesn't copy the status (frozen, tainted) of obj.
|
||||
puts msg2 #=> Hello World!
|
||||
puts msg3 #=> Hello World!
|
||||
puts msg2.frozen? #=> true
|
||||
puts msg3.frozen? #=> false
|
||||
Loading…
Add table
Add a link
Reference in a new issue