Sync
This commit is contained in:
parent
6f050a029e
commit
776bba907c
3887 changed files with 59894 additions and 7280 deletions
|
|
@ -0,0 +1 @@
|
|||
01 Foo CONSTANT AS "Foo".
|
||||
|
|
@ -0,0 +1 @@
|
|||
78 Foo VALUE "Foo".
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
CONSTANT SECTION.
|
||||
01 Foo VALUE "Foo".
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
:- object(immutable).
|
||||
|
||||
% forbid using (complementing) categories for adding to or
|
||||
% modifying (aka hot patching) the object
|
||||
:- set_logtalk_flag(complements, deny).
|
||||
% forbid dynamically adding new predicates at runtime
|
||||
:- set_logtalk_flag(dynamic_declarations, deny).
|
||||
|
||||
:- public(foo/1).
|
||||
foo(1). % static predicate by default
|
||||
|
||||
:- private(bar/2)
|
||||
bar(2, 3). % static predicate by default
|
||||
|
||||
:- end_object.
|
||||
|
|
@ -1,2 +1,22 @@
|
|||
msg = "Hello World"
|
||||
puts msg = "Hello World"
|
||||
msg << "!"
|
||||
puts msg #=> Hello World!
|
||||
|
||||
puts msg.frozen? #=> false
|
||||
msg.freeze
|
||||
puts msg.frozen? #=> true
|
||||
begin
|
||||
msg << "!"
|
||||
rescue => e
|
||||
p e #=> #<RuntimeError: can't modify frozen String>
|
||||
end
|
||||
|
||||
puts msg #=> Hello World!
|
||||
|
||||
msg2 = msg
|
||||
|
||||
# An object is frozen and it is not a variable.
|
||||
msg = "hello world" # A new object was assigned to the variable.
|
||||
|
||||
puts msg.frozen? #=> false
|
||||
puts msg2.frozen? #=> true
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue