poke-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: assert() inside type x = struct { ...


From: Mohammad-Reza Nabipoor
Subject: Re: assert() inside type x = struct { ...
Date: Sat, 9 Apr 2022 16:25:19 +0430

Hi.

On Fri, Apr 08, 2022 at 05:12:24PM +0200, Jose E. Marchesi wrote:
> 
> > Is it intentional that assert() does not work inside type definitions like 
> > this?
> >
> > type foo = struct { string yo; };
> > type x = struct {
> >   uint<8> len;
> >   union {
> >     foo myfoo;
> >     byte[len] unknown;
> >   } payload;
> >   assert(payload'size'magnitude/8 == len);
> > };
> 
> Statements inside struct types are not supported, no.
> Only declarations.
> 

What do you think about chaning the `format` to be an expression of type
`int`?
That way users can do something like this:

```poke
struct
{
  int field1;
  int field2;
  
  var a_descriptive_variable_name = assert (some_condition, "...");
};

```

If you agree with this, I can send the patch.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]