Subject: Re: SDL-News: type cast in SDL
From: Rick Reed TSE (rickreed#tseng.co.uk)
Date: Wed Jun 04 2003 - 06:13:43 GMT
Become an SDL Forum Society member <http://www.sdl-forum.org/Society/members.htm>
The originator of this message is responsible for its content.
-----From Rick Reed TSE <rickreed#tseng.co.uk> to sdlnews -----
Yang LIU at lyly97#mails.tsinghua.edu.cn 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 - rickreed#tseng.co.uk Tel:+44 15394 88462 Mob.:+44 7970 50 96 50
--End text from Rick Reed TSE <rickreed#tseng.co.uk> to sdlnews --- For extra SDL Forum Society benefits join at <http://www.sdl-forum.org/Society/members.htm>
This archive was generated by hypermail 2a23 : Thu May 09 2013 - 16:05:49 GMT