[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [RFC] Syntax for struct type constructors
From: |
Mohammad-Reza Nabipoor |
Subject: |
Re: [RFC] Syntax for struct type constructors |
Date: |
Tue, 2 Mar 2021 01:04:09 +0330 |
Hi, Jose.
On Mon, Mar 01, 2021 at 10:03:55PM +0100, Jose E. Marchesi wrote:
>
> 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)?
>
2!
It feels more data type :)