Re: SDL-News: type cast in SDL

Subject: Re: SDL-News: type cast in SDL
From: Rick Reed TSE (
Date: Wed Jun 04 2003 - 06:13:43 GMT

Become an SDL Forum Society member <>
The originator of this message is responsible for its content.
-----From Rick Reed TSE <> to sdlnews -----

Yang LIU at wrote on 03/06/2003 09:01:

> I defined my new type like this:
> newtype Frame inherits Octetstring operators all;
> .....
> dcl myframe Frame;
> dcl myOS Octetstring;
> We know when generates C code from SDL, Frame is the same as
> SDL_Octet_String, but in SDL we can't assign like: myframe:=myOS,
> cause different type.
> I wanna know how can I do a cast between myframe and myOS in SDL?

myframe := octetstring(bitstring(myOS))

should work. If not then try

myframe := <<TYPE Frame>>octetstring(<<TYPE Octetstring>>bitstring(myOS))

what this does is to convert myOS to a bitstring then convert this bitstring
to a Frame. The second version tells the SDL tool which of the overloaded
operators to use, though in principle this should be derivable from context.

Of course, this is not really a "cast" which would need to be built into the
language. Unfortunately most of the language expert group thought that such
casts were unnecessary.

For this to work efficiently the SDL tool needs to recognise these
bitstring/octectstring conversions do not actually need any runtime

Rick Reed -
Tel:+44 15394 88462 Mob.:+44 7970 50 96 50

--End text from Rick Reed TSE <> to sdlnews --- For extra SDL Forum Society benefits join at <>

This archive was generated by hypermail 2a23 : Thu May 09 2013 - 16:05:49 GMT