Newsgroups: comp.sys.transputer
From: rbs@wb.utwente.nl (Herman Roebbers [BSC/RT])
Subject: Re: An occam query
Organization: Twente University, Dept. of Mech. Eng., Netherlands
Date: Wed, 15 Jun 1994 10:07:47 GMT
Message-ID: <CrFo4z.6x4@Utwente.NL>

According to wgd@ukc.ac.uk (Warren Day):
>
>Hi,
>
>Does anyone have any light to throw on this problem of automated type
>measurement in occam?
>
>I'm trying to write something like,
>
>[]BYTE packet
>  ...
>  INT value RETYPES [packet FROM 0 FOR bytes.in.an(INT) ]:
>  value := expr
>
>I've tried,
>
>  INT value RETYPES [packet FROM 0 FOR (SIZE INT) ]:
>  value := expr
>
>but the compiler complains,
>
>Error 2017:13 Monadic operator INT and operand not in parentheses
>
>and from playing around it is complaining about the second INT on the line
>not the first (weird!).
>
>Has anyone got a much cleaner way to do this, and a way that get through the
>compiler.  I would prefer to have something automatic that the compiler can
>look at and work out,
>
>  INT value RETYPES [packet FROM 0 FOR relative.size(INT, BYTE) ]:
>  value := expr
>

How about:

  INT bytes:
  []BYTE word RETYPES bytes:
  INT value RETYPES [packet FROM 0 FOR SIZE word ]:
  value := expr

That would do it perfectly.

>and not just an anonymous constant such as,
>
>  VAL bytes.in.an.int IS 4:
>  INT value RETYPES [packet FROM 0 FOR bytes.in.an.int ]:
>  value := expr
>
>Thanks for any thoughts.
>
>Smiles,
>--
>Warren
>		Pause for a moment,
>			and consider mans humanity towards his fellow man.

Have fun,

Herman


