Define a primitive data type: Difference between revisions

m
→‎{{header|Sidef}}: make the range inclusive
m (→‎{{header|Sidef}}: make the range inclusive)
 
(30 intermediate revisions by 12 users not shown)
Line 4:
 
=={{header|Ada}}==
<langsyntaxhighlight lang="ada">type My_Type is range 1..10;</langsyntaxhighlight>
The compiler identifies the range of valid values from the range specification ''1..10'' and automatically builds in bounds checking where it is needed. The compiler is smart enough to omit bounds checking when it is not needed.
<langsyntaxhighlight lang="ada">A : My_Type := 3;
B : My_Type := A;</langsyntaxhighlight>
The compiler will omit bounds checking for the assignment of A to B above because both values are of My_Type. A cannot hold a value outside the range of 1..10, therefore the assignment cannot produce an out of bounds result.
 
Line 17:
 
{{works with|ALGOL 68G|Any - tested with release mk15-0.8b.fc9.i386}}
<langsyntaxhighlight lang="algol68"> # assume max int <= ABS - max negative int #
INT max bounded = ( LENG max int * max int > long max int | ENTIER sqrt(max int) | max int );
Line 177:
OD;
except bounds error:
SKIP</langsyntaxhighlight>
Output:
<pre>
Line 192:
As of February 2009 no open source libraries to do this task have been located.
 
=={{header|C sharpATS}}==
{{works with|ATS|Postiats (that is, ATS2)}}
 
Runtime bounds checking is expensive, so code ''given to the user'' typically has such checks turned off. The user is getting a dangerous version of the program!
 
Also, the programmer cannot discover violations except by running the program.
 
Is it not better, if possible, to have ''the compiler'' detect the mistake?
 
<syntaxhighlight lang="ats">(*
 
Here is the type:
 
*)
 
typedef rosetta_code_primitive_type =
[i : int | 1 <= i; i <= 10] int i
 
(*
 
You do not have to insert bounds checking, and the compiler inserts no
bounds checking. You simply *cannot* assign an out-of-range value.
 
(Proviso: unless you do some serious cheating.)
 
*)
 
implement
main0 (argc, argv) =
let
var n : rosetta_code_primitive_type
in
n := 1;
n := 10;
n := 11
end
 
(*
 
An attempt to compile this program *will fail* when it typechecks ‘n := 11’:
 
$ patscc primitive_type-postiats.dats
/path/to/primitive_type-postiats.dats: 282(line=21, offs=3) -- 373(line=27, offs=6): error(3): unsolved constraint: C3NSTRprop(C3TKmain(); S2Eapp(S2Ecst(<=); S2EVar(0->S2Eintinf(11)), S2Eintinf(10)))
/path/to/primitive_type-postiats.dats: 282(line=21, offs=3) -- 373(line=27, offs=6): error(3): unsolved constraint for lvar preservation
typechecking has failed: there are some unsolved constraints: please inspect the above reported error message(s) for information.
exit(ATS): uncaught exception: _2tmp_2ATS_2dPostiats_2src_2pats_error_2esats__FatalErrorExn(1025)
 
*)</syntaxhighlight>
 
The compiler’s messages are cryptic, but this problem could be overcome with devoted work on the compiler. (It is, after all, copylefted software and can be forked.)
 
There is a more serious downside. It is stated in [[#Ada|the Ada section]] that the Ada compiler is smart enough to know when to leave out bounds checks. In contrast, the ATS compiler will ''reject'' the program, unless it ''knows'' it can ‘leave out bounds checks’.
 
On the other hand, ''if you have no proof'' that a value is within the bounds 1..10, you must avoid attempting the assignment; but you can instead put something like '''if 1 <= k then if k <= 10 then n := k else abort() else abort()'''. In other words, you ''can'' insert a bounds check. It is often done, and there is an '''assertloc''' macro for doing so. The compiler lets you know you need the bounds check, but will not do it for you.
 
(You can also seriously cheat by using something like '''$UNSAFE.prop_assert''', but that is another topic. I mention it to encourage individual enquiry.)
 
=={{header|C sharp|C#}}==
Strictly speaking, this task is impossible in C# because a type that behaves like an integer (<code>int</code>, or <code>System.Int32</code>; <code>Integer</code> in VB.NET) must be a struct (in order to have value-type semantics), and, since C# does not allow the definition of a parameterless constructor for a struct (instead generating a default parameterless constructor that sets each of its fields to the default value for the type of the field), an instance of the struct with the forbidden value of zero can be created through that default constructor.
 
Line 199 ⟶ 256:
Through operator overloading, it is possible to declare types in C# with the full complement of operators available on the primitive types. The following structure attempts to mimic the behavior of the <code>int</code> type in C# on .NET Core as much as possible, including interfaces and static members, delegating as much implementation as possible to the <code>Integer</code> type itself.
 
<langsyntaxhighlight lang="csharp">using System;
using System.Globalization;
 
Line 313 ⟶ 370:
public static bool TryParse(string s, ref int result) => int.TryParse(s, out result);
#endregion
}</langsyntaxhighlight>
 
=={{header|C++}}==
Line 320 ⟶ 377:
This class relies on implicit conversions to do most int operations; however the combined operations with assignment have to be coded explicitly.
 
<langsyntaxhighlight lang="cpp">#include <stdexcept>
 
class tiny_int
Line 381 ⟶ 438:
private:
unsigned char value; // we don't need more space
};</langsyntaxhighlight>
 
=={{header|Clojure}}==
Line 387 ⟶ 444:
Use proxy on java.lang.Number so it can be used in Clojure's math operations.
 
<langsyntaxhighlight lang="clojure">(defn tinyint [^long value]
(if (<= 1 value 10)
(proxy [Number] []
(doubleValue [] value)
(longValue [] value))
(throw (ArithmeticException. "integer overflow"))))</langsyntaxhighlight>
 
{{out}}
Line 411 ⟶ 468:
The built-in integer type specifier provides range parameters. <code>deftype</code> may be used to define an alias for it.
 
<langsyntaxhighlight lang="lisp">(deftype one-to-ten ()
'(integer 1 10))</langsyntaxhighlight>
 
For a bounds check, one may use <code>typep</code> (a predicate) or <code>check-type</code> (signals an error if not of the type).
 
<langsyntaxhighlight lang="lisp">(defun word (i)
(check-type i one-to-ten)
(case i
Line 428 ⟶ 485:
(8 "eight")
(9 "nine")
(10 "ten")))</langsyntaxhighlight>
 
(Note that the above can be written without the separate check-type by using <code>ecase</code> instead of <code>case</code>, which signals an error when no case matches.)
Line 434 ⟶ 491:
To inform the compiler that a variable will be of a certain type, permitting optimizations, use a declaration:
 
<langsyntaxhighlight lang="lisp">(dolist (i numbers)
(declare (type one-to-ten i))
...)</langsyntaxhighlight>
 
Note, however, that the standard does not specify what happens in the event that a declaration is false (though [[SBCL]], for example, does perform type checks on any declaration except when <code>safety</code> is 0); use <code>check-type</code> for portable bounds checks.
Line 442 ⟶ 499:
=={{header|D}}==
 
<langsyntaxhighlight Dlang="d">import std.exception, std.string, std.traits;
 
/++
Line 525 ⟶ 582:
assert(i < 5);
assert(j > i);
}</langsyntaxhighlight>
 
=={{header|Delphi}}==
Line 534 ⟶ 591:
The code below defines a new type <code>TinyInt</code>, provides bounds checking and implementation of all standard arithmetic operators:
 
<langsyntaxhighlight lang="dyalect">type TinyInt(Integer value) {
throw @Overflow(value) when value is <1 or >10
} with Lookup, Show
 
func TinyInt as Integer => this.value
func TinyInt + (other) => TinyInt(this.value + other as Integer)
private {
func getInteger(x) {
match x {
Integer => x,
TinyInt => x.toInteger(),
_ => throw "Type \"\(x.getType()::name)\" is not supported by this operation."
}
}
func TinyInt * (other) => TinyInt(this.value * other as Integer)
func boundsCheck(x) {
if x < 1 || x > 10 {
throw "Overflow"
}
x
}
}
func TinyInt.TinyInt - (iother) cons=> {TinyInt(this.value - other as Integer)
boundsCheck(Integer(i))
}
func TinyInt.toString() decons {
this.toString()
}
func TinyInt.toInteger() decons {
this
}
func TinyInt + (other) decons {
let z = this + getInteger(other)
TinyInt(z)
}
func TinyInt * (other) decons {
let z = this * getInteger(other)
TinyInt(z)
}
func TinyInt - (other) decons {
let z = this - getInteger(other)
TinyInt(z)
}
func TinyInt / (other) decons=> {TinyInt(this.value / other as Integer)</syntaxhighlight>
let z = this / getInteger(other)
TinyInt(z)
}</lang>
 
Sample usage (interactive session):
Line 590 ⟶ 610:
 
dy>x += 4
TinyInt (7) :: TinyInt
 
dy>x * 2
Operation overflows</pre>
Runtime exception Dy601: Overflow.
Stack trace:
at boundsCheck(Dyalect.Debug.Par) in <stdio>, line 13, column 9
at TinyInt(Dyalect.Debug.Par) in <stdio>, line 19, column 29
at *(Dyalect.Debug.Par) in <stdio>, line 37, column 13
at <external code>
at TinyInt(Dyalect.Debug.Par) in <stdio>, line 19, column 29
at *(Dyalect.Debug.Par) in <stdio>, line 37, column 13
at <external code></pre>
 
=={{header|E}}==
<langsyntaxhighlight lang="e">def MyNumber := 1..10
 
for i :MyNumber in [0, 5, 10, 15, 20, 25] {
println(i)
}</langsyntaxhighlight>
(Note: The region guard, while provided with E, is entirely unprivileged code, and could be argued not to be "primitive".)
 
=={{header|EchoLisp}}==
Types are native objects (Boolean, ..) , or defined by predicates and/or combinations of other types. They are used to check data values or to define functions signatures. The '''types.lib''' library must be loaded.
<langsyntaxhighlight lang="scheme">
(require 'types)
(require 'math)
Line 644 ⟶ 656:
(f10 42 666)
❗ error: One-ten : type-check failure : 42 → 'f10:x'
</syntaxhighlight>
</lang>
 
=={{header|Elena}}==
ELENA 46.x:
<langsyntaxhighlight lang="elena">import extensions;
sealed struct TinyInt : BaseNumber
{
int value;
int cast() = value;
constructor(int n)
{
if (n <= 1 || n >= 10)
{
InvalidArgumentException.raise()
};
value := n
}
cast t(string s)
{
value := s.toInt();
if (value <= 1 || value >= 10)
{
InvalidArgumentException.raise()
}
}
TinyInt add(TinyInt t)
= value + (cast int(t));
TinyInt subtract(TinyInt t)
= value - (cast int(t));
TinyInt multiply(TinyInt t)
= value * (cast int(t));
TinyInt divide(TinyInt t)
= value / (cast int(t));
bool equal(TinyInt t)
= value == (cast int(t));
bool less(TinyInt t)
= value == (cast int(t));
 
string toPrintable()
=> value;
}
public program()
{
TinyInt i := 4t;
TinyInt j := i + i;
console.printLine("4t = ", i);
try
console.printLine("8t = ", j);
{
console.write("4t + 8t = ");
 
try
{
i + j
}
catch(InvalidArgumentException e)
{
console.printLine("A value is out of range")
}
}</langsyntaxhighlight>
{{out}}
<pre>
4t = 4
8t = 8
4t + 8t = A value is out of range
</pre>
 
=={{header|Euphoria}}==
In Euphoria types are special functions that may be used in declaring the allowed values for a variable. A type must have exactly one parameter and should return an atom that is either true (non-zero) or false (zero). Types can also be called just like other functions. The types '''object''', '''sequence''', '''atom''' and '''integer''' are predefined.
<langsyntaxhighlight lang="euphoria">type My_Type(integer i)
return i >= 1 and i <= 10
end type</langsyntaxhighlight>
 
=={{header|Factor}}==
We can accomplish this using a predicate class. A predicate class must be a subclass of an existing class and allows the programmer to write a predicate which determines membership.
<langsyntaxhighlight lang="factor">PREDICATE: my-int < integer [ 0 > ] [ 11 < ] bi and ;</langsyntaxhighlight>
This automatically creates the <code>my-int?</code> predicate word which determines whether an object is a <code>my-int</code>.
<langsyntaxhighlight lang="factor">11 my-int? ! f
10 my-int? ! t
"hello" my-int? ! f</langsyntaxhighlight>
We can now write methods that specialize on <code>my-int</code>. We will define an increment word, <code>++</code>, which increments <code>integer</code>s by <tt>1</tt> but divides <code>my-int</code>s by <tt>2</tt>.
<langsyntaxhighlight lang="factor">GENERIC: ++ ( m -- n )
M: integer ++ 1 + ;
M: my-int ++ 2/ ;
 
10 ++ ! 5
11 ++ ! 12</langsyntaxhighlight>
 
=={{header|Forth}}==
Line 739 ⟶ 764:
=== Method 1: Safe Integer Store operators===
Forth is a fetch and store based virtual machine. If we create a safe version of store (!) the programmer simply uses this operator rather than the standard store operator.
<LANGsyntaxhighlight lang="text">DECIMAL
: CLIP ( n lo hi -- n') ROT MIN MAX ;
: BETWEEN ( n lo hi -- flag) 1+ WITHIN ;
Line 747 ⟶ 772:
: SAFE! ( n addr -- )
OVER 1 10 BETWEEN 0= ABORT" out of range!"
! ;</LANGsyntaxhighlight>
Testing
<LANGsyntaxhighlight lang="text">VARIABLE X
7 X SAFE! X ? 7 ok
12 X CLIP! X ? 10 ok
Line 759 ⟶ 784:
$7FAA2B0C throw
$7FAD4698 c(abort")
</syntaxhighlight>
</LANG>
=== Method 2: redefine standard "store" operator as DEFER word ===
Using the code in Method 1, we can re-define the store (!) operator to be switchable.
<LANGsyntaxhighlight lang="text">DECIMAL
: FAST! ( n addr -- ) ! ; ( alias the standard version)
 
Line 770 ⟶ 795:
: LIMITS-ON ( -- ) ['] SAFE! IS ! ;
: LIMITS-OFF ( -- ) ['] FAST! IS ! ;
: CLIPPING-ON ( -- ) ['] CLIP! IS ! ; </LANGsyntaxhighlight>
 
Testing
<LANGsyntaxhighlight lang="text">VARIABLE Y
 
LIMITS-OFF ok
Line 795 ⟶ 820:
$7FAA2B0C throw
$7FAD4460 c(abort")
</syntaxhighlight>
</LANG>
=== Method 3: Create a safe VALUE assignment operator===
A VALUE defines a numerical data type that returns it's value rather than an address (pointer) like a variable.
We can create a word that assigns a number to a VALUE but tests for out of range errors.
<LANGsyntaxhighlight lang="text">: (->) ( n <text> -- )
OVER 1 10 BETWEEN 0= ABORT" out of range!"
>BODY ! ;
Line 807 ⟶ 832:
IF POSTPONE ['] POSTPONE (->) \ compiling action
ELSE ' (->) \ interpret action
THEN ; IMMEDIATE</LANGsyntaxhighlight>
 
Test
<LANGsyntaxhighlight lang="text">0 VALUE Z ok
99 TO Z ok ( normal assignment)
Z . 99 ok
Line 819 ⟶ 844:
$7FAA2B0C throw
$7FAD4570 c(abort")
$7FAD45DC (->)</LANGsyntaxhighlight>
 
=={{header|Fortran}}==
Line 826 ⟶ 851:
The module gives an example of how a ''bounded integer'' could be implemented in Fortran (not all the needed interfaces are implemented, and only the one for the + operator are shown). Bounds are checked at run-time.
 
<langsyntaxhighlight lang="fortran">module Bounded
implicit none
 
Line 927 ⟶ 952:
end function bounded_add_bbb
 
end module Bounded</langsyntaxhighlight>
 
<langsyntaxhighlight lang="fortran">program BoundedTest
use Bounded
implicit none
Line 953 ⟶ 978:
c = c + b ! warning (c=10)
 
end program BoundedTest</langsyntaxhighlight>
 
=={{header|Free Pascal}}==
''See [[#Pascal|Pascal]]''
<langsyntaxhighlight lang="pascal">type
range = 1..10;
var
Line 965 ⟶ 990:
{$rangeChecks on}
n := n + 10; // will yield a run-time error
end;</langsyntaxhighlight>
The FPC (Free Pascal compiler) by default does ''not generate'' range checks.
Assigning a value out of range is possible.
Line 976 ⟶ 1,001:
 
=={{header|FreeBASIC}}==
<langsyntaxhighlight lang="freebasic">' FB 1.05.0 Win64
 
Type MyInteger
Line 1,015 ⟶ 1,040:
Print
Print "Press any key to quit"
Sleep</langsyntaxhighlight>
 
{{out}}
<pre>
i = 10 j = 3 k = 4 j + 6 = 9 j + k = 7
</pre>
 
=={{header|Frink}}==
Frink can set "constraints" on variables that must be enforced at all times. One way is to define a function that returns <CODE>true</CODE> if the constraint is met. This constraint is checked whenever assigning a new value to the variable.
<syntaxhighlight lang="frink">oneToTen[x] := isInteger[x] AND x >= 1 AND x <= 10
 
var y is oneToTen = 1
 
while (true)
{
println[y]
y = y + 1
}</syntaxhighlight>
{{out}}
<pre>
1
2
3
4
5
6
7
8
9
10
Error: BasicContext: Cannot set symbol y, ContextFrame threw exception:
Constraint not met: function oneToTen[11] returned false.
In expression:
y = y + 1
</pre>
 
Line 1,031 ⟶ 1,085:
 
2. Go doesn't support operator overloading and so methods need to be defined for the standard operations on integers. As in the case of the Kotlin entry, only the basic arithmetic operations and the increment and decrement operations have been catered for below.
<langsyntaxhighlight lang="go">package main
 
import "fmt"
Line 1,086 ⟶ 1,140:
fmt.Println("t1 + 1 =", t1.Inc())
fmt.Println("t1 - 1 =", t1.Dec())
}</langsyntaxhighlight>
 
{{out}}
Line 1,105 ⟶ 1,159:
Haskell doesn't have any built-in subrange types. However, it is possible to declare arbitrary types that "behave like" any of the built-in types on the "usual" numeric etc. operations, because these operations are defined by type-classes. So we generalize the task a bit, and first declare a generic container type that supports an additional ''check'' operation. Then, we lift any operation in the base type to the container type, by executing the check after each operation:
 
<langsyntaxhighlight lang="haskell">{-# OPTIONS -fglasgow-exts #-}
 
data Check a b = Check { unCheck :: b } deriving (Eq, Ord)
Line 1,148 ⟶ 1,202:
quotRem = lift2p quotRem
divMod = lift2p divMod
toInteger = lift toInteger</langsyntaxhighlight>
Now we can declare the a subrange 1..10 of integer like this:
 
<langsyntaxhighlight lang="haskell">newtype TinyInt = TinyInt Int
 
instance Checked TinyInt Int where
check x | x >= 0 && x <= 10 = Check x
| otherwise = error "Out of range"</langsyntaxhighlight>
In the same way, we could now declare the subtype of the even integers:
<langsyntaxhighlight lang="haskell">newtype EvenInt = EvenInt Int
 
instance Checked EvenInt Int where
check x | even x = Check x
| otherwise = error "Not even"</langsyntaxhighlight>
 
Similarly, we could declare the subtype of floating point numbers with restricted exponent, and so on.
Line 1,167 ⟶ 1,221:
=={{header|J}}==
J excels in composition rather than permitting verb overloading. Express a dyadic operation as verb__object1 object2 rather than object1 verb object2 . The example uses the verb ''add'' . The constructor, create, retains j's array data structure opposed to limiting to an atom.
<syntaxhighlight lang="j">
<lang J>
NB. z locale by default on path.
type_z_=: 3!:0
Line 1,187 ⟶ 1,241:
end.
)
</syntaxhighlight>
</lang>
 
<pre>
Line 1,216 ⟶ 1,270:
This example class throws an exception if the value is out of the bounds; it is implemented only in the assignment method "assign" and the addition method "add". The class can be easily extended.
 
<langsyntaxhighlight lang="java">class BoundedIntOutOfBoundsException extends Exception
{
public BoundedIntOutOfBoundsException(int v, int l, int u) {
Line 1,286 ⟶ 1,340:
}
}
}</langsyntaxhighlight>
 
=={{header|JavaScript}}==
 
<langsyntaxhighlight JavaScriptlang="javascript">function Num(n){
n = Math.floor(n);
if(isNaN(n))
Line 1,312 ⟶ 1,366:
var y = new Num(0); //TypeError
var z = new Num(11); //TypeError
</syntaxhighlight>
</lang>
 
=={{header|jq}}==
In the following, we define a new type named "smallint", with arithmetic operations that either return the "smallint" one would expect from ordinary arithmetic, or else return nothing (an empty stream), as opposed to returning null or raising an error. The choice of an empty stream is made to highlight this alternative.
By design, jq's types are constrained to be JSON types, so jq's type system cannot be used to create a new type, but we can create a parallel type system based on JSON objects. We shall do so using the convention that if an object has a key named "type", then the type of the object will be the given value:<langsyntaxhighlight lang="jq">def typeof:
if type == "object" and has("type") then .type else type end;</langsyntaxhighlight>We also define a generic "pretty-print" filter:
<langsyntaxhighlight lang="jq">def pp:
if type == "object" and has("type") then "\(.type)::\(.value)"
else .
end;</langsyntaxhighlight>Our instances of smallint will look like this: {"type": "smallint", "value": 0}
 
This definition ensures that jq's basic tests for equality and inequality (== and !=) can be used for the instances of smallint.
Line 1,330 ⟶ 1,384:
As of this writing, the official release of jq does not support modules, so we will not use jq's new module system here, but it would allow us to place all the smallint functions in a Smallint module.
 
To generate instances of smallint, we define a function, smallint(i), that will return an instance corresponding to an integer, i, if it is in range. As noted above, it will otherwise return nothing at all (as opposed to null or raising an error):<langsyntaxhighlight lang="jq">def smallint(i): i as $i
| if (i|type) == "number" and i == (i|floor) and i > 0 and i < 11 then {"type": "smallint", "value": i}
else empty
Line 1,343 ⟶ 1,397:
split("::") | smallint( .[1] | tonumber )
else empty
end ;</langsyntaxhighlight>That leaves just basic arithmetic operations: add minus times mod div <langsyntaxhighlight lang="jq">def add(a;b): smallint(a.value + b.value);
def minus(a;b): smallint(a.value - b.value);
def times(a;b): smallint(a.value * b.value);
def mod(a;b): smallint(a.value % b.value);
def divide(a;b): smallint( (a.value / b.value) | floor );</langsyntaxhighlight>Examples:<syntaxhighlight lang ="jq">s(1) < s(3) # => true
add( s(1); s(2)) | pp # "smallint::3"
add( s(6); s(6)) # (nothing)</langsyntaxhighlight>
 
=={{header|Julia}}==
Julia has true, machine-optimized user defined primitives, but they are defined as contiguous groups of N bits:
 
<langsyntaxhighlight lang="julia">struct LittleInt <: Integer
val::Int8
function LittleInt(n::Real)
Line 1,377 ⟶ 1,431:
@show a * LittleInt(2)
@show b ÷ LittleInt(2)
@show a * b</langsyntaxhighlight>
 
{{out}}
Line 1,394 ⟶ 1,448:
 
Rather than attempt to reproduce all functions or operators which the Int type supports, only the basic arithmetic operators and the increment and decrement operators are catered for below:
<langsyntaxhighlight lang="scala">// version 1.1
 
class TinyInt(i: Int) {
Line 1,430 ⟶ 1,484:
println("t1 + 1 = ${++t1}")
println("t2 - 1 = ${--t2}")
}</langsyntaxhighlight>
 
{{out}}
Line 1,446 ⟶ 1,500:
 
=={{header|Lasso}}==
<langsyntaxhighlight Lassolang="lasso">define dint => type {
data private value
Line 1,474 ⟶ 1,528:
dint(10) + 1 // Error: 11 greater than 10
dint(10) * 2 // Error: 20 greater than 10
</syntaxhighlight>
</lang>
 
=={{header|Lua}}==
<syntaxhighlight lang="lua">BI = { -- Bounded Integer
new = function(self, v) return setmetatable({v = self:_limit(v)}, BI_mt) end,
_limit = function(self,v) return math.max(1, math.min(math.floor(v), 10)) end,
}
BI_mt = {
__index = BI,
__call = function(self,v) return self:new(v) end,
__unm = function(self) return BI(-self.v) end,
__add = function(self,other) return BI(self.v+other.v) end,
__sub = function(self,other) return BI(self.v-other.v) end,
__mul = function(self,other) return BI(self.v*other.v) end,
__div = function(self,other) return BI(self.v/other.v) end,
__mod = function(self,other) return BI(self.v%other.v) end,
__pow = function(self,other) return BI(self.v^other.v) end,
__eq = function(self,other) return self.v==other.v end,
__lt = function(self,other) return self.v<other.v end,
__le = function(self,other) return self.v<=other.v end,
__tostring = function(self) return tostring(self.v) end
}
setmetatable(BI, BI_mt)</syntaxhighlight>
Example usage:
<syntaxhighlight lang="lua">zero, one, two, three, four, five = BI(0), BI(1), BI(2), BI(3), BI(4), BI(5)
six, seven, eight, nine, ten, eleven = BI(6), BI(7), BI(8), BI(9), BI(10), BI(11)
print("zero through eleven:\t", zero, one, two, three, four, five, six, seven, eight, nine, ten, eleven)
print("zero less than one?\t", zero < one)
print("eleven greater than ten?", eleven > ten)
print("negative one equals one:", -one)
print("zero plus one equals two:", zero + one)
print("one minus one equals one:", one - one)
print("two minus three equals one:", two - three)
print("three minus two equals one:", three - two)
print("two times three equals six:", two * three)
print("two times three equals six?", two * three == six)
print("three times four equals ten?", three * four == ten)
print("one divided by two equals one:",one / two)
print("five divided by two equals two:", five / two)
print("order of operations (seven):", one + two * three)
print("order of operations (nine):", (one + two) * three)
print("eight mod three equals two:", eight % three)
print("eight mod two equals one:", eight % two)
print("two to the third equals eight:", two ^ three)
print("two to the fourth equals ten:", two ^ four)</syntaxhighlight>
{{out}}
<pre>zero through eleven: 1 1 2 3 4 5 6 7 8 9 10 10
zero less than one? false
eleven greater than ten? false
negative one equals one: 1
zero plus one equals two: 2
one minus one equals one: 1
two minus three equals one: 1
three minus two equals one: 1
two times three equals six: 6
two times three equals six? true
three times four equals ten? true
one divided by two equals one: 1
five divided by two equals two: 2
order of operations (seven): 7
order of operations (nine): 9
eight mod three equals two: 2
eight mod two equals one: 1
two to the third equals eight: 8
two to the fourth equals ten: 10</pre>
 
=={{header|M2000 Interpreter}}==
Line 1,487 ⟶ 1,605:
We can use Currency, Decimal, Double, Single, Long, Integer for primitive data types. When we see type using Type$() we get "Group" (the user object type) but using TypeExp$() (defined in this example) we get group value's type, as Currency here.
 
<syntaxhighlight lang="m2000 interpreter">
<lang M2000 Interpreter>
Module CheckDataType {
Module CheckThis {
Line 1,567 ⟶ 1,685:
}
CheckDataType
</syntaxhighlight>
</lang>
 
=={{header|MATLAB}}==
Line 1,574 ⟶ 1,692:
In a folder named "@RingInt"
RingInt.m:
<langsyntaxhighlight MATLABlang="matlab">classdef RingInt
properties
Line 1,661 ⟶ 1,779:
end %classdef
</langsyntaxhighlight>
 
Sample Usage:
<langsyntaxhighlight MATLABlang="matlab">>> RingInt(10) + 1
 
ans =
Line 1,686 ⟶ 1,804:
ans =
 
1</langsyntaxhighlight>
 
=={{header|Modula-3}}==
In Modula-3, subrange types are automatically subtypes of their base type, so if you define a type called <code>MyInt</code> to be the subrange [1..10] then <code>MyInt</code> is a subtype of <code>INTEGER</code>. If we defined <code>MyChar</code> as the subrange ['A'..'C'] then <code>MyChar</code> would be a subtype of <code>CHAR</code>.
<langsyntaxhighlight lang="modula3">TYPE MyInt = [1..10];</langsyntaxhighlight>
<code>MyInt</code> can now be used anywhere an <code>INTEGER</code> can, such as the standard arithmetic functions. Trying to assign a value outside of the range of <code>MyInt</code> will result in a compile time warning, and/or a runtime error.
 
=={{header|Nim}}==
Subranges are supported by the language and automatically boundchecked:
<langsyntaxhighlight Nimlang="nim">type
MyInt = range[1..10]
 
Line 1,702 ⟶ 1,820:
x = x + 6 # Runtime error: unhandled exception: value out of range: 11 notin 1 .. 10 [RangeDefect]
 
x = 12 # Compile-time error: conversion from int literal(12) to MyInt is invalid</langsyntaxhighlight>
 
=={{header|OCaml}}==
<langsyntaxhighlight lang="ocaml">exception Out_of_bounds
 
type 'a bounds = { min: 'a; max: 'a }
Line 1,731 ⟶ 1,849:
(mk_bounded res a.bounds)
;;
(** val op : ('a -> 'a -> 'a) -> 'a bounded -> 'a bounded -> 'a bounded *)</langsyntaxhighlight>
 
Using in the interactive top level:
<langsyntaxhighlight lang="ocaml"># let range = mk_bounds 1 10 ;;
val range : int bounds = {min = 1; max = 10}
 
Line 1,747 ⟶ 1,865:
 
# op ( + ) a b ;;
- : int bounded = {value = 7; bounds = {min = 1; max = 10}}</langsyntaxhighlight>
 
which can be used with floats in the same way:
<langsyntaxhighlight lang="ocaml"># let rf = mk_bounds 1.0 10.0 ;;
val rf : float bounds = {min = 1.; max = 10.}
 
Line 1,756 ⟶ 1,874:
and b = mk_bounded 5.6 rf in
op ( +. ) a b ;;
- : float bounded = {value = 7.8; bounds = {min = 1.; max = 10.}}</langsyntaxhighlight>
 
=={{header|ooRexx}}==
<langsyntaxhighlight lang="oorexx">/* REXX ----------------------------------------------------------------
* 21.06.2014 Walter Pachl
* implements a data type tinyint that can have an integer value 1..10
Line 1,808 ⟶ 1,926:
if wordpos(methName, "+ - * / % //")>0 then -- an arithmetic message in hand?
forward message (methName) to (v) array (methArgs[1])
</syntaxhighlight>
</lang>
'''output'''
<pre>a=1
Line 1,833 ⟶ 1,951:
In this case we are lucky. As a feature of constraint programming we can easily constrain the domain of integers.
 
<langsyntaxhighlight lang="oz">declare
I
in
I::1#10
I = {Pow 2 4}</langsyntaxhighlight>
 
Output:
Line 1,851 ⟶ 1,969:
 
=={{header|Pascal}}==
<langsyntaxhighlight lang="pascal">type
naturalTen = 1..10;</langsyntaxhighlight>
As per ISO 7185, any (attempted) assignment out of range constitutes an error.
However, the processor (usually a compiler) is permitted to leave such an error undetected.
Line 1,859 ⟶ 1,977:
=={{header|Perl}}==
{{works with|Perl|5}}
<langsyntaxhighlight lang="perl">package One_To_Ten;
use Carp qw(croak);
use Tie::Scalar qw();
Line 1,878 ⟶ 1,996:
$t = 11; # dies, too big
$t = 'xyzzy';
# dies, too small. string is 0 interpreted numerically</langsyntaxhighlight>
 
=={{header|Phix}}==
{{trans|Euphoria}}
In Phix types are special functions that may be used in declaring the allowed values for a variable. A type must have exactly one parameter and should return true (non-zero) or false (zero). Types can also be called just like other functions. The types '''object''', '''sequence''', '''string''', '''atom''' and '''integer''' are predefined.
<!--<syntaxhighlight lang="phix">(phixonline)-->
<lang Phix>type iten(integer i)
<span style="color: #008080;">type</span> <span style="color: #000000;">iten</span><span style="color: #0000FF;">(</span><span style="color: #004080;">integer</span> <span style="color: #000000;">i</span><span style="color: #0000FF;">)</span>
return i>=1 and i<=10
<span style="color: #008080;">return</span> <span style="color: #000000;">i</span><span style="color: #0000FF;">>=</span><span style="color: #000000;">1</span> <span style="color: #008080;">and</span> <span style="color: #000000;">i</span><span style="color: #0000FF;"><=</span><span style="color: #000000;">10</span>
end type</lang>
<span style="color: #008080;">end</span> <span style="color: #008080;">type</span>
<!--</syntaxhighlight>-->
You can then declare variables of the new type just as you would the builtins
<!--<syntaxhighlight lang="phix">(phixonline)-->
<lang Phix>integer i
<span style="color: #004080;">integer</span> <span style="color: #000000;">i</span>
iten i10</lang>
<span style="color: #000000;">iten</span> <span style="color: #000000;">i10</span>
<!--</syntaxhighlight>-->
and typechecking occurs automatically
<!--<syntaxhighlight lang="phix">(phixonline)-->
<lang Phix>i = 11 -- fine
<span style="color: #000000;">i</span> <span style="color: #0000FF;">=</span> <span style="color: #000000;">11</span> <span style="color: #000080;font-style:italic;">-- fine</span>
i10 = 11 -- runtime error</lang>
<span style="color: #000000;">i10</span> <span style="color: #0000FF;">=</span> <span style="color: #000000;">11</span> <span style="color: #000080;font-style:italic;">-- runtime error (desktop/Phix only, not pwa/p2js)</span>
<!--</syntaxhighlight>-->
Note that standard practice is to get a program running and fully tested on desktop/Phix first, ''before'' using pwa/p2js to run it in a browser.
 
=={{header|PicoLisp}}==
{{trans|Java}}
<langsyntaxhighlight PicoLisplang="picolisp">(class +BoundedInt)
# value lower upper
 
Line 1,926 ⟶ 2,051:
(set> B 9)
(when (catch 'boundedIntOutOfBounds (+> A (val> B)) NIL)
(prinl @) ) ) )</langsyntaxhighlight>
Output:
<pre>: (main)
Line 1,933 ⟶ 2,058:
 
=={{header|PowerShell}}==
<syntaxhighlight lang="powershell">
<lang PowerShell>
[Int][ValidateRange(1,10)]$n = 3 # $n can only accept integers between 1 and 10
</syntaxhighlight>
</lang>
 
 
=={{header|PureBasic}}==
<syntaxhighlight lang="purebasic">If OpenConsole()
Structure Persona
nombre.s{15}
apellido.s{30}
edad.w
List amigos$()
EndStructure
Dim MyFriends.Persona(100)
; Aquí la posición '1' del array MyFriends()
; contendrá una persona y su propia información
MyFriends(1)\nombre = "Carlos"
MyFriends(1)\apellido = "Gzlez."
MyFriends(1)\edad = 47
individuo.Persona
individuo\nombre = "Juan"
individuo\apellido = "Hdez."
individuo\edad = 49
; Ahora, agrega algunos amigos
AddElement(individuo\amigos$())
individuo\amigos$() = "Lucia"
AddElement(individuo\amigos$())
individuo\amigos$() = "Isabel"
ForEach individuo\amigos$()
Debug individuo\amigos$()
Next
;Estructura extendida
Structure Domicilio Extends Persona
calle.s
numero.b
EndStructure
MyFriends.Domicilio\calle = "Grillo"
MyFriends.Domicilio\numero = 20
PrintN(individuo\nombre + " " + individuo\apellido + " " + Str(individuo\edad) + " " + Str(MyFriends.Domicilio\numero))
PrintN(MyFriends(1)\nombre + " " + MyFriends(1)\apellido + " " + Str(MyFriends(1)\edad))
If TypeOf(Persona\edad) = #PB_Word
Debug "Edad ess un 'Word'"
EndIf
superficie.f
If TypeOf(superficie) = #PB_Float
Debug "superficie es un 'Float'"
EndIf
Print(#CRLF$ + #CRLF$ + "--- terminado, pulsa RETURN---"): Input()
CloseConsole()
EndIf</syntaxhighlight>
 
 
=={{header|Python}}==
This doesn't really apply as Python names don't have a type, but something can be done:
<langsyntaxhighlight lang="python">>>> class num(int):
def __init__(self, b):
if 1 <= b <= 10:
Line 1,960 ⟶ 2,147:
>>> type(x)
<class '__main__.num'>
>>></langsyntaxhighlight>
 
=={{header|Racket}}==
 
=={{header|QBasic}}==
{{works with|QBasic}}
<syntaxhighlight lang="qbasic">
TYPE TipoUsuario
nombre AS STRING * 15
apellido AS STRING * 30
edad AS INTEGER
END TYPE
 
DIM usuario(1 TO 20) AS TipoUsuario
 
usuario(1).nombre = "Juan"
usuario(1).apellido = "Hdez."
usuario(1).edad = 49
 
PRINT usuario(1).nombre, usuario(1).apellido, usuario(1).edad
</syntaxhighlight>
 
 
=={{header|Racket}}==
Most Racket programmers will use contracts to enforce additional guarantees on values. In the following example, the program exports <tt>x</tt> with a contract that ensures it is a number between 1 and 10.
 
<langsyntaxhighlight lang="racket">
#lang racket
 
Line 1,974 ⟶ 2,180:
 
(define x 5)
</syntaxhighlight>
</lang>
 
In Typed Racket, it is possible to define a type that only contains the integers from 1 to 10. However, this type is inconvenient to use and is unlikely to be used in practice.
 
<langsyntaxhighlight lang="racket">
#lang typed/racket
 
Line 1,990 ⟶ 2,196:
(: y 1UpTo10)
(define y 18)
</syntaxhighlight>
</lang>
 
=={{header|Raku}}==
(formerly Perl 6)
 
<syntaxhighlight lang="raku" perl6line>subset OneToTen of Int where 1..10;
 
my OneToTen $n = 5;
$n += 6;</langsyntaxhighlight>
 
Here the result 11 fails to smartmatch against the range <code>1..10</code>, so the second assignment throws an exception. You may use any valid smartmatch predicate within a <code>where</code> clause, so the following one-argument closure is also legal:
 
<syntaxhighlight lang="raku" perl6line>subset Prime of Int where -> $n { $n > 1 and so $n %% none 2 .. $n.sqrt }</langsyntaxhighlight>
 
=={{header|Retro}}==
<syntaxhighlight lang="retro">{{
<lang Retro>{{
variable update
---reveal---
Line 2,011 ⟶ 2,217:
: to dup 1 10 within [ update on ] [ drop "Out of bounds\n" puts ] if ;
: limited: create 1 , &.limited reclass ;
}}</langsyntaxhighlight>
 
This creates a data element that returns a value from 1 to 10. Alteration of the value is possible using '''to'''.
 
<langsyntaxhighlight Retrolang="retro">limited: foo
1 to foo
foo .s
51 to foo
foo .s
bye</langsyntaxhighlight>
 
=={{header|Ruby}}==
Line 2,038 ⟶ 2,244:
and define a method_missing method.
 
<langsyntaxhighlight lang="ruby">require 'test/unit'
include Test::Unit::Assertions
 
Line 2,123 ⟶ 2,329:
 
assert_raise(ArgumentError) { c = a + b } # => invalid value '12', must be an integer
assert_raise(ArgumentError) { c = b - a } # => invalid value '-2', must be an integer</langsyntaxhighlight>
 
=={{header|Rust}}==
Line 2,139 ⟶ 2,345:
A simple example of implementing the newtype pattern manually would look like this:
 
<langsyntaxhighlight lang="rust">use std::convert::TryFrom;
 
mod test_mod {
Line 2,178 ⟶ 2,384:
let bar: i8 = foo.into();
println!("{} == {}", foo, bar);
}</langsyntaxhighlight>
 
However, there exist crates such as [https://lib.rs/crates/derive_more derive_more] to automate the parts other than the restricted construction logic based on a simple <code>#[derive(Add, Copy, Clone, Debug, Div, Into, Mul, Sub)]</code> and so on and so forth.
 
=={{header|Scala}}==
{{libheader|Scala}}<langsyntaxhighlight Scalalang="scala"> class TinyInt(val int: Byte) {
import TinyInt._
require(int >= lower && int <= upper, "TinyInt out of bounds.")
Line 2,196 ⟶ 2,402:
}
 
val test = (TinyInt.lower to TinyInt.upper).map(n => TinyInt(n.toByte))</langsyntaxhighlight>
 
=={{header|Sidef}}==
<langsyntaxhighlight lang="ruby">subset Integer < Number { .is_int }
subset MyIntLimit < Integer { . ~~ (1 ..^ 10) }
 
class MyInt(value < MyIntLimit) {
Line 2,235 ⟶ 2,441:
 
a *= 2 # a=6
say a+b # error: class `MyInt` does not match MyInt(12)</langsyntaxhighlight>
 
=={{header|Swift}}==
 
<syntaxhighlight lang="swift">struct SmallInt {
var value: Int
 
init(value: Int) {
guard value >= 1 && value <= 10 else {
fatalError("SmallInts must be in the range [1, 10]")
}
 
self.value = value
}
 
static func +(_ lhs: SmallInt, _ rhs: SmallInt) -> SmallInt { SmallInt(value: lhs.value + rhs.value) }
static func -(_ lhs: SmallInt, _ rhs: SmallInt) -> SmallInt { SmallInt(value: lhs.value - rhs.value) }
static func *(_ lhs: SmallInt, _ rhs: SmallInt) -> SmallInt { SmallInt(value: lhs.value * rhs.value) }
static func /(_ lhs: SmallInt, _ rhs: SmallInt) -> SmallInt { SmallInt(value: lhs.value / rhs.value) }
}
 
extension SmallInt: ExpressibleByIntegerLiteral {
public init(integerLiteral value: Int) { self.init(value: value) }
}
 
extension SmallInt: CustomStringConvertible {
public var description: String { "\(value)" }
}
 
let a: SmallInt = 1
let b: SmallInt = 9
let c: SmallInt = 10
let d: SmallInt = 2
 
print(a + b)
print(c - b)
print(a * c)
print(c / d)
print(a + c)</syntaxhighlight>
 
{{out}}
 
<pre>10
1
10
5
Runner/main.swift:17: Fatal error: SmallInts must be in the range [1, 10]
Illegal instruction: 4</pre>
 
=={{header|Tcl}}==
Tcl does not attach types to values or variables, but it does allow the programmer to create traces on variables that can be used to enforce type-like constraints among other things. Traces are procedures that execute when variables are read, written and/or unset. (Traces are also available for commands and for the execution of a script.) Tcl's compiler does not enforce these constraints; they're strictly runtime entities.
<langsyntaxhighlight lang="tcl">namespace eval ::myIntType {
variable value_cache
array set value_cache {}
Line 2,275 ⟶ 2,528:
error [format $errMsg $varname $value]
}
}</langsyntaxhighlight>
 
So, in an interactive tclsh we can see:
Line 2,301 ⟶ 2,554:
 
=={{header|Toka}}==
<langsyntaxhighlight lang="toka">needs quotes
{
variable update
Line 2,312 ⟶ 2,565:
value:1-10: foo
1 to foo
foo .</langsyntaxhighlight>
 
=={{header|UNIX Shell}}==
Line 2,319 ⟶ 2,572:
* compound variables and
* "discipline functions" which get fired at get/set/unset events
<langsyntaxhighlight lang="bash">typeset -i boundedint
function boundedint.set {
nameref var=${.sh.name}
Line 2,334 ⟶ 2,587:
boundedint=-5; echo $boundedint
boundedint=5; echo $boundedint
boundedint=15; echo $boundedint</langsyntaxhighlight>
{{output}}
<pre>value out of bounds
Line 2,355 ⟶ 2,608:
corresponding operations on natural numbers with no further bounds
checking required.
<langsyntaxhighlight Ursalalang="ursala">#import nat
 
my_number ::
Line 2,363 ⟶ 2,616:
 
add = my_number$[the_number: sum+ ~the_number~~]
mul = my_number$[the_number: product+ ~the_number~~]</langsyntaxhighlight>
test program:
<langsyntaxhighlight Ursalalang="ursala">#cast _my_number
 
total = add(my_number[the_number: 3],my_number[the_number: 4])</langsyntaxhighlight>
output:
<pre>
Line 2,373 ⟶ 2,626:
</pre>
test program demonstrating bounds checking:
<langsyntaxhighlight Ursalalang="ursala">#cast _my_number
 
total = mul(my_number[the_number: 3],my_number[the_number: 4])</langsyntaxhighlight>
compile-time diagnostic output:
<pre>
Line 2,381 ⟶ 2,634:
</pre>
Note that restricted types are not idiomatic in Ursala if all we really want is integer arithmetic with run-time bounds checking, which can be done more directly like this.
<langsyntaxhighlight Ursalalang="ursala">#import nat
 
#library+
Line 2,387 ⟶ 2,640:
#import
^|A(~&,//+ nrange(1,10)?</~& <'out of bounds'>!%)*
~&n-=<'sum','difference','product','quotient','remainder'>*~ %QI nat</langsyntaxhighlight>
This code creates a new library of functions of natural numbers by selecting several of them by name from the standard <code>nat</code> library and putting a wrapper around each one that checks the bounds on the result and throws an exception if necessary. These functions can be used as drop-in replacements for the standard ones.
 
Line 2,395 ⟶ 2,648:
 
TinyInt.cls:
<langsyntaxhighlight lang="vb">Private mvarValue As Integer
 
Public Property Let Value(ByVal vData As Integer)
Line 2,412 ⟶ 2,665:
'vb defaults to 0 for numbers; let's change that...
mvarValue = 1
End Sub</langsyntaxhighlight>
 
Usage (in this case, from a form):
<langsyntaxhighlight lang="vb">Public x As TinyInt
 
Private Sub Form_Click()
Line 2,426 ⟶ 2,679:
Randomize Timer
Set x = New TinyInt '"Set = New" REQUIRED
End Sub</langsyntaxhighlight>
 
=={{header|Visual Basic .NET}}==
Line 2,435 ⟶ 2,688:
Note that some operators return a <code>Double</code> instead of a new <code>LimitedInt</code>. This was intentional in order to match the behavior of the corresponding <code>Integer</code> operators in VB.NET. Also note that some members are commented out. This is because the newest supported release of VB.NET (as of 2019-09-14) does not support the .NET Core <code>Span(Of T)</code> and <code>ReadOnlySpan(Of T)</code> types.
 
<langsyntaxhighlight lang="vbnet">Structure LimitedInt
Implements IComparable, IComparable(Of LimitedInt), IConvertible, IEquatable(Of LimitedInt), IFormattable
 
Line 2,703 ⟶ 2,956:
End Function
#End Region
End Structure</langsyntaxhighlight>
 
=={{header|Visual FoxPro}}==
Visual FoxPro can't define primitives but they can be emulated with custom classes.
<langsyntaxhighlight lang="vfp">LOCAL o As BoundedInt
o = NEWOBJECT("BoundedInt")
DO WHILE NOT o.lHasError
Line 2,737 ⟶ 2,990:
ENDIF
THIS.lHasError = .T.
ENDDEFINE</langsyntaxhighlight>
 
=={{header|Wren}}==
To do this in Wren, you need to define a new TinyInt class with a suitable constructor and re-implement all the operators which apply to integers, checking (in the case of those that return an integer) that the result is within bounds and throwing an error if it isn't.
 
Note that inheriting from the basic types, such as Num, is not recommendedallowed.
 
The following carries out this procedure for a few basic operations and shows examples of their usage including throwing an out of bounds error on the last one.
<langsyntaxhighlight ecmascriptlang="wren">class TinyInt {
construct new(n) {
if (!(n is Num && n.isInteger && n >= 1 && n <= 10)) {
Line 2,755 ⟶ 3,008:
n { _n }
 
+(other) { TinyInt.new(_n + other.n) }
-(other) { var res = TinyInt.new(_n +- other.n) }
*(other) { TinyInt.new(_n * other.n) }
if (res < 1 || res > 10) Fiber.abort("Result must be an integer between 1 and 10.")
/(other) return{ TinyInt.new(res(_n / other.n).truncate) }
}
 
-(other) {
var res = _n - other.n
if (res < 1 || res > 10) Fiber.abort("Result must be an integer between 1 and 10.")
return TinyInt.new(res)
}
 
*(other) {
var res = _n * other.n
if (res < 1 || res > 10) Fiber.abort("Result must be an integer between 1 and 10.")
return TinyInt.new(res)
}
 
/(other) {
var res = (_n / other.n).truncate
if (res < 1 || res > 10) Fiber.abort("Result must be an integer between 1 and 10.")
return TinyInt.new(res)
}
 
==(other) { _n == other.n }
Line 2,797 ⟶ 3,031:
System.print("%(a) != %(b) -> %(a != b)")
System.print("%(a) + %(a) == %(b) -> %((a + a) == b)")
var g = f + b // out of range error here</langsyntaxhighlight>
 
{{out}}
Line 2,807 ⟶ 3,041:
1 != 2 -> true
1 + 1 == 2 -> true
ResultArgument must be an integer between 1 and 10.
[./primitiveprimitive2 line 114] in +init new(_)
[./primitiveprimitive2 line 487] in (script)
[./primitive2 line 11] in +(_)
[./primitive2 line 34] in (script)
</pre>
 
{{omit from|6502 Assembly}}
{{omit from|68000 Assembly}}
{{omit from|8080 Assembly}}
{{omit from|8086 Assembly}}
{{omit from|ARM Assembly}}
{{omit from|AWK}}
{{omit from|Axe}}
Line 2,831 ⟶ 3,072:
{{omit from|TI-89 BASIC|Does not have user-defined data structures.}}
{{omit from|Vim Script}}
{{omit from|Z80 Assembly}}
2,747

edits