Variable size/Get: Difference between revisions

Content added Content deleted
(Added Kotlin)
Line 873: Line 873:


Native types such as int64 or num32 are of fixed size; Perl 6 supports representational polymorphism of such types (and compositions of such types) through a pluggable meta-object protocol providing "knowhow" objects for the various representations. Currently the NativeHOW knowhow may be interrogated for the bit sizes of native types, but this is officially outside the purview of the language itself (so far).
Native types such as int64 or num32 are of fixed size; Perl 6 supports representational polymorphism of such types (and compositions of such types) through a pluggable meta-object protocol providing "knowhow" objects for the various representations. Currently the NativeHOW knowhow may be interrogated for the bit sizes of native types, but this is officially outside the purview of the language itself (so far).

=={{header|Phix}}==
<lang Phix>printf(1,"An integer contains %d bytes.\n", machine_word())</lang>
See builtins\VM\pHeap.e for the complete low-level details. Because of shared references,
it is often not practical to obtain a meaningful size, and you can often store a "sparse"
structure in far less memory than expected. Plus (as per Icon) sequences and strings have
some room (up to 50%) for expansion. The builtin length() function gives no indication of
the latter or the size of individual elements, unless used in a recursive routine, and as
said even then may grossly overstate actual memory use due to shared references.
You may also wish to examine builtins\VM\pMemChk.e for some ideas about how to perform a
detailed heap analysis - in that specific case for post-run memory leak checking, done from
the safety of a secondary heap, so that the one it is examining does not suddenly change.


=={{header|PicoLisp}}==
=={{header|PicoLisp}}==