Memory layout of a data structure: Difference between revisions
Rename Perl 6 -> Raku, alphabetize, minor clean-up
(Merge omitted languages at bottom and add Processing) |
Thundergnat (talk | contribs) (Rename Perl 6 -> Raku, alphabetize, minor clean-up) |
||
Line 294:
In a similar way, text content may employ only a limited character set so perhaps five bits per symbol would suffice, or some other packing scheme might suggest itself. There is also a whole world of compression algorithms. The end result is that a data structure manifesting as records in a disc file may be difficult to unpack into a convenient internal form even given a careful description of the layout.
=={{header|FreeBASIC}}==▼
<lang freebasic>' FB 1.05.0 Win64▼
' using bit fields▼
Type RS232_Pin9▼
carrierDetect : 1 As UByte ▼
receivedData : 1 As UByte ▼
transmittedData : 1 As UByte▼
dataTerminalReady : 1 As UByte▼
signalGround : 1 As UByte▼
dataSetReady : 1 As UByte▼
requestToSend : 1 As UByte▼
clearToSend : 1 As UByte▼
ringIndicator : 1 As UByte▼
End Type▼
Print SizeOf(RS232_Pin9) '' 2 bytes▼
Sleep</lang>▼
=={{header|Free Pascal}}==
Line 341 ⟶ 322:
{{Out}}
<pre>0000000000010000</pre>
▲=={{header|FreeBASIC}}==
▲<lang freebasic>' FB 1.05.0 Win64
▲' using bit fields
▲Type RS232_Pin9
▲ carrierDetect : 1 As UByte
▲ receivedData : 1 As UByte
▲ transmittedData : 1 As UByte
▲ dataTerminalReady : 1 As UByte
▲ signalGround : 1 As UByte
▲ dataSetReady : 1 As UByte
▲ requestToSend : 1 As UByte
▲ clearToSend : 1 As UByte
▲ ringIndicator : 1 As UByte
▲End Type
▲Print SizeOf(RS232_Pin9) '' 2 bytes
▲Sleep</lang>
=={{header|Go}}==
Line 746:
$vec->set($rs232{'RD Received data'}, 1);
$vec->get($rs232{'TC Transmit clock'});</lang>
=={{header|Perl 6}}==▼
The following is specced to work, but implementation of shaped arrays is not quite complete.▼
<lang perl6>enum T_RS232 <▼
carrier_detect▼
received_data▼
transmitted_data▼
data_terminal_ready▼
signal_ground▼
data_set_ready▼
request_to_send▼
clear_to_send▼
ring_indicator▼
>;▼
my bit @signal[T_RS232];▼
@signal[signal_ground] = 1;</lang>▼
In the absence of shaped arrays, you can do the usual bit-twiddling tricks on a native integer of sufficient size. (Such an integer could presumably be mapped directly to a device register.)▼
<lang perl6>$signal +|= 1 +< signal_ground;</lang>▼
Using a native int is likelier to work on a big-endian machine in any case. Another almost-there solution is the mapping of C representational types into Perl 6 for native interfaces, but it does not yet support bit fields.▼
=={{header|Phix}}==
Line 844 ⟶ 823:
((ctype-c->scheme _rs232) 276) ; -> '(TD SG RI)
</lang>
(formerly Perl 6)
▲The following is specced to work, but implementation of shaped arrays is not quite complete.
▲<lang perl6>enum T_RS232 <
▲ carrier_detect
▲ received_data
▲ transmitted_data
▲ data_terminal_ready
▲ signal_ground
▲ data_set_ready
▲ request_to_send
▲ clear_to_send
▲ ring_indicator
▲>;
▲my bit @signal[T_RS232];
▲@signal[signal_ground] = 1;</lang>
▲In the absence of shaped arrays, you can do the usual bit-twiddling tricks on a native integer of sufficient size. (Such an integer could presumably be mapped directly to a device register.)
▲<lang perl6>$signal +|= 1 +< signal_ground;</lang>
▲Using a native int is likelier to work on a big-endian machine in any case. Another almost-there solution is the mapping of C representational types into Perl 6 for native interfaces, but it does not yet support bit fields.
=={{header|REXX}}==
|