Variable size/Set: Difference between revisions

Rename Perl 6 -> Raku, alphabetize, minor clean-up
(Omitted languages: add Processing)
(Rename Perl 6 -> Raku, alphabetize, minor clean-up)
Line 193:
iprec3 3 8 9
iprec4 4 16 18</pre>
 
=={{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|FreeBASIC}}==
Line 206 ⟶ 214:
 
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 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.
 
By spec, arrays may be declared with dimensions of fixed size, but as of this writing, such arrays not yet implemented. An array of fixed size that returns elements of a native type will be stored compactly, and uses exactly the memory you'd think it should, (modulo alignment constraints between elements and any slop at the end due to your memory allocator).
 
=={{header|Phix}}==
Line 416 ⟶ 411:
mpfr_const_pi(pi)
mpfr_printf(1,"PI with 1000 decimals: %.1000RDf\n\n",pi)</lang>
 
=={{header|PicoLisp}}==
In PicoLisp, all variables have the same size (a single cell). But it is
possible to create a data structure of a given minimal size with the
'[http://software-lab.de/doc/refN.html#need need]' function.
 
=={{header|PL/I}}==
Line 436:
z float decimal (33); /* occupies 16 bytes */
</lang>
 
=={{header|PicoLisp}}==
In PicoLisp, all variables have the same size (a single cell). But it is
possible to create a data structure of a given minimal size with the
'[http://software-lab.de/doc/refN.html#need need]' function.
 
=={{header|PureBasic}}==
Line 609 ⟶ 604:
=={{header|Racket}}==
Like many other highlevel languages, Racket doesn't have direct control on object sizes. More than that, objects are almost always references, so holding a vector or a list still starts from some object with pointers to the rest. It is possible, however, to create random ffi structs with some given length, by using something like <tt>(_array _byte N)</tt> and it's possible to add that to some other ffi type by wrapping it with such an array in a struct. But to create and manage chunks of memory, it's much better to just use <tt>malloc</tt> (which is also available via the ffi).
 
=={{header|Perl 6Raku}}==
(formerly 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.
 
By spec, arrays may be declared with dimensions of fixed size, but as of this writing, such arrays not yet implemented. An array of fixed size that returns elements of a native type will be stored compactly, and uses exactly the memory you'd think it should, (modulo alignment constraints between elements and any slop at the end due to your memory allocator).
 
=={{header|REXX}}==
10,333

edits