Path: news.cs.au.dk!news.net.uni-c.dk!howland.erols.net!newsfeed.cwix.com!206.172.150.11!news1.bellglobal.com!news.uunet.ca!not-for-mail From: Karl Waclawek Newsgroups: comp.lang.beta Subject: Re: How to do low level stuff Date: Thu, 28 Jan 1999 21:56:35 -0500 Organization: UUNET Canada News Transport Lines: 81 Message-ID: <36B12363.12951978@idirect.com> References: <368B8A70.CF9934FF@thestar.ca> <36950D20.2FAD4D18@thestar.ca> NNTP-Posting-Host: 207.136.101.92 Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Mailer: Mozilla 4.5 [en] (Win95; I) X-Accept-Language: en Xref: news.cs.au.dk comp.lang.beta:11803 "Kolbjørn Aambø" wrote: > > In article , Morten Grouleff > wrote: > > > Karl Waclawek writes: > > > > [...] > : > > In the next release of the Mjolner System, some new basic types are > > introduced. These include signed and unsigned integers of sizes > > 8,16,32,64 bits. There will also be a 16 bit wchar which is intended to > > hold unicode chars. > : > This is just great.... asked for that some years a go by the way.... > > But there is one additional thing you just have to adress to get BETA to > become a more useful language: Lets give variables an ENDIAN based type! > > bsUInt64 (bigsmallUnsigned64bit int) Big Endian Unsigned 64 bit. > sbUInt64 (smallbigUnsigned64bit int) Little Endian Unsigned 64 bit. > same for all other types.... > > Cant you just rename wchar into Unicode: > bsUnicode > sbUnicode > > If you followed that advice you could make an Internet Communication > package where everything is done big Endian, for instance. Let the > compiler do bs->sb and sb->bs implicit and issue warnings for converting > overhead if neccesary.... I am not sure that that would be in the spirit of BETA, although I agree that the memory layout of data should be something one should be able to control. Once a BETA program has to face the real world, i.e. interfaces to data with arbitrary storage formats and semantics, it becomes necessary to convert between the nice and orderly academic world of BETA and the nasty outside world. ;-) Anyway, instead of special data types, would it not be more generic to provide storage layout conversion functions for the basic data types? Since basically all the world nowadays stores data in terms of 8-bit bytes, once could get away with functions that simply convert any basic data type into a byte array with specified layout. Example for 64bit integers (let's call them Integer64): Int64ToBytes: (# Int64: @Integer64; Layout: ^LayoutSpecifier; Bytes: [8] @Byte; enter (Int64, Layout[]) do ; INNER exit Bytes #) The "do" part would depend on the platform. You could also use inheritance and extend the INNER part instead of using a layout specifier, like Int64ToBytesBE: Int64ToBytes(# do #); So, if you want to place an Integer64 into a byte array at position 17 in big endian format, you would do something like: (MyInt64, BigEndianLayout[]) -> Int64ToBytes -> MyBuffer[17:24]; or MyInt64 -> Int64ToBytesBE -> MyBuffer[17:24]; Currently, however, it seems that you cannot assign to repetition slices, another language feature that would be be useful. Karl ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Karl Waclawek KD Soft Inc. * Phone: (905) 579-3443 * E-Mail: waclawek@idirect.com