[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH v2] pkl: Fix bit-offset of mapped integral struct
From: |
Mohammad-Reza Nabipoor |
Subject: |
Re: [PATCH v2] pkl: Fix bit-offset of mapped integral struct |
Date: |
Thu, 28 Jan 2021 22:25:04 +0330 |
On Thu, Jan 28, 2021 at 07:43:41PM +0100, Jose E. Marchesi wrote:
>
> >
> > The fix with tests!
>
> Thanks, this is OK for master.
>
Pushed.
Thanks.
> > ## Off-topic proposal
> >
> > When I was writing the function `t` in `maps-int-structs-2[5-8].pk` tests.
> > I thought it'd be nice to have the following syntax to access struct field
> > dynamically:
> >
> > ```
> > type S = struct { int a; long b; };
> > var s = S{};
> > var a = "a",
> > b = "b";
> >
> > s.("a") = 10;
> > s.("b") = 20;
> >
> > s.(a) = 1;
> > s.(b) = 2;
> > ```
> >
> > This syntax is inspired by MATLAB programming language.
> >
> > WDYT?
> > (Of course this is not for Poke 1.0!)
>
> I thought of that. Having good introspection to structs would be a very
> good thing.
>
> However, that will have to wait until we implement gradual typing in the
> language and compiler to support that (the type of something like
> s.("a") should be `any').
>
> It is in the pipeline :)
Awesome!