Article View: comp.lang.modula2
Article #3202Re: Modula2 for C programmers?
From: Michel De Rosa
Date: Mon, 29 Jan 1996 03:17
Date: Mon, 29 Jan 1996 03:17
60 lines
2795 bytes
2795 bytes
jguthrie@brokersys.com wrote: : Michel De Rosa (aliath@nyongwa.montreal.qc.ca) wrote: : : : [...] : : and/or/xor etc.. it's always been possible to do these, using the set : : operators.. first coerce to a BITSET... : : Please don't talk down to me. Sorry it wasn't my intention to do so.. : I know how to manipulate bitsets, but do WHAT to a BITSET? Well other posts have, i hope, already cleared that up.. : As far as I know, NONE of the M2 compilers I have ever used allow me : to convert between any kind of number and any kind of set. Again it may be only due to the fact that you weren't aware of the type-coercion facility.. I've used a number of different compilers, Logitech v3 (pc/dos), JPI TopSpeed (pc/dos), gpm-pc (again pc/dos), and an old pim2-based compiler for VAX/VMS.. they've all allowed this sort of coercion, with some caveats, mainly some of them would have restrictions, on a size of a set (the same with as a cardinal), and some wouldn't allow coercing from<->to a variable of a different size (say a bitset to a char).. : I know that that isn't mentioned anywhere in PIM3C. I've been at m2 for a long time (i mean real long time).. i honestly can't say how or when i first became aware of the facility.. i know it's in Pim4, because i recently had occasion to look it up.. I do use the term coercion, rather than casting, because there's a difference.. the way pim4 documents the facility, absolutely no interpretation of the bits is made.. we're forcing (coercing) the compiler to treat the expression, as if it was of a different type. My understanding of type-casting, suggests that there's a minimum of interpretation being done, an attempt is made to preserve the value being cast to another type. That is assuming we have a short-integer type, than: si : SHORTINT; i : INTEGER; ... si := -1; (* On intel this maps to FFh *) (* cast si to i *) ... at this point i should be -1 , or FFFFh... With type-coercion, we'd likely get a positive value (always assuming the compiler let's us cast/coerce between different bit-sizes). si := -1; i := INTEGER(si); (* we now have 00FFh *) Michel De Rosa Aliath@Nyongwa.montreal.qc.ca
Technical Details
Message-ID:
<DLxAHC.50q@nyongwa.montreal.qc.ca>Path:
arc1-ca.pugleaf.net!mcrcim.mcgill.edu!nyongwa!aliathReferences:
<erico-1801961940460001@infinitehell.cnmat.berkeley.edu> <4dqusf$d7k@weck.brokersys.com> <DLIGLJ.FDE@nyongwa.montreal.qc.ca> <4du11j$l31@weck.brokersys.com>Show Full Headers
Complete Article Headers
Newsgroups: comp.lang.modula2 Path: arc1-ca.pugleaf.net!mcrcim.mcgill.edu!nyongwa!aliath From: aliath@nyongwa.montreal.qc.ca (Michel De Rosa) Subject: Re: Modula2 for C programmers? Message-ID: <DLxAHC.50q@nyongwa.montreal.qc.ca> Organization: Radio Free Nyongwa, Montreal (Qc), Canada Date: Mon, 29 Jan 1996 03:17:35 GMT References: <erico-1801961940460001@infinitehell.cnmat.berkeley.edu> <4dqusf$d7k@weck.brokersys.com> <DLIGLJ.FDE@nyongwa.montreal.qc.ca> <4du11j$l31@weck.brokersys.com> X-Newsreader: TIN [UNIX 1.3 950824BETA PL0]