Define a primitive data type: Difference between revisions

add UNIX Shell
m (→‎{{header|Scala}}: Rm Scala imp category)
(add UNIX Shell)
Line 1,475:
1 to foo
foo .</lang>
 
=={{omit fromheader|UNIX Shell}}==
{{works with|ksh93}}
ksh93 has
* compound variables and
* "discipline functions" which get fired at get/set/unset events
<lang bash>typeset -i boundedint
function boundedint.set {
nameref var=${.sh.name}
if (( 1 <= .sh.value && .sh.value <= 10 )); then
# stash the valid value as a backup, in case we need to restore it
typeset -i var.previous_value=${.sh.value}
else
print -u2 "value out of bounds"
# restore previous value
.sh.value=${var.previous_value}
fi
}
 
boundedint=-5; echo $boundedint
boundedint=5; echo $boundedint
boundedint=15; echo $boundedint</lang>
{{output}}
<pre>value out of bounds
0
5
value out of bounds
5</pre>
 
=={{header|Ursala}}==
Line 1,723 ⟶ 1,751:
{{omit from|TI-89 BASIC|Does not have user-defined data structures.}}
{{omit from|Vim Script}}
{{omit from|UNIX Shell}}
Anonymous user