Variable size/Set: Difference between revisions

m (→‎{{header|Mathematica }}: fix header markup)
Line 206:
 
Variables of types 3. and 4. don't hold their data directly but instead contain a fixed length descriptor - 24 bytes for a string and between 64 and 232 bytes for an array depending on the number of dimensions. The descriptor contains, amongst other things, a pointer to where the actual data is stored.
 
=={{header|Free Pascal}}==
''See also: [[#Pascal|Pascal]]''
 
Only enumeration type definitions can have a minimum size:<lang pascal>type
{$packEnum 4}
enum = (x, y, z);</lang>
Only a <tt>{$packEnum}</tt> of <tt>1</tt>, <tt>2</tt>, or <tt>4</tt> Bytes can be specified.
 
=={{header|Go}}==
Line 246 ⟶ 254:
cMin: 8 bytes
</pre>
 
=={{header|Haskell}}==
<lang Haskell>
Line 369 ⟶ 378:
 
=={{header|Pascal}}==
Pascal discourages the programmer to think about specific internal memory structures.
Ordinal and floating point types of FreePascal are listed here: [[http://www.freepascal.org/docs-html/ref/refsu5.html]] and here: [[http://www.freepascal.org/docs-html/ref/refsu6.html]]
Therefore, there is no way to specify the size of any data type.
<lang pascal>var
a: byte; // 1 byte
b: word; // 2 byte
c: cardinal; // 4 byte
d: QWord; // 8 byte
 
The GPC (GNU Pascal compiler), however, allows for ''integer'' types the specification of a minimum precision:
x: real; // 4 byte
<lang pascal>vartype
y: double; // 8 byte</lang>
correctInteger = integer attribute (size = 42);</lang>
''See also: [[#Free Pascal|Free Pascal]]''
 
=={{header|Perl}}==
Line 383 ⟶ 390:
 
In Perl, memory is readily and happily traded for expressiveness and ease of use.
 
=={{header|Perl 6}}==
In Perl 6, normal user-facing types (Int, Rat, Str, Array, Hash) are all auto-sizing, so there is no need to specify a minimum size for them. (Floating point, known as "Num", defaults to a machine double.) For storage declarations, native storage types (starting with a lowercase letter) may also be specified, in which case the required bit size is part of the type name: int16, uint8 (aka "byte"), num32 (a "float"), complex64 (made of two num64's), etc. More generally, such types are created through an API supporting representational polymorphism, in this case, the NativeHOW representation, when provides methods to set the size of a type; the actual allocation calculation happens when such generic types are composed into a class instance representing the semantics of the effective type to the compiler and run-time system. But mostly this is not something users will concern themselves with directly.
149

edits