[Top][All Lists]

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

[RFC] Syntax for struct type constructors

From: Jose E. Marchesi
Subject: [RFC] Syntax for struct type constructors
Date: Mon, 01 Mar 2021 22:03:55 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux)

Hi people!

Next feature I will implement in poke is support for having arguments in
struct types.  Like this:

type Packet =
  struct (int control, int datasize = 256)
    byte ctrl = control;
    byte[datasize] payload;

I feel good with the above syntax: it in intuitive and clear.

However, at the type construction side, I contemplate two options:

1) To use parenthesis, like in:

   Packet (2, 1024)
   Packet (2) /* datasize is optional */

2) To use angle brackets, like in:

   Packet<2, 1024>
   Packet<2> /* datasize is optional */

My intention is to implement 2).  This is mainly because most other type
constructors like int<N>, uint<N> and offset<...,...> also use angle
brackets to be parametrized.

But if someone thinks 1) is better for some reason, I am all ears :)
What you people think?  1) or 2)?

reply via email to

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