poke-devel
[Top][All Lists]
Advanced

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

Re: [PATCH v2] pkl: Fix bit-offset of mapped integral struct


From: Jose E. Marchesi
Subject: Re: [PATCH v2] pkl: Fix bit-offset of mapped integral struct
Date: Thu, 28 Jan 2021 19:43:17 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux)

Hi Mohammad.

> 2021-01-28  Mohammad-Reza Nabipoor  <m.nabipoor@yahoo.com>
>
>       * libpoke/pkl-gen.pks (struct_writer): Fix bit-offset of mapped
>       integral struct to use the real offset, not zero.
>       * testsuite/poke.map/maps-int-structs-21.pk: New test.
>       * testsuite/poke.map/maps-int-structs-22.pk: Likewise.
>       * testsuite/poke.map/maps-int-structs-23.pk: Likewise.
>       * testsuite/poke.map/maps-int-structs-24.pk: Likewise.
>       * testsuite/poke.map/maps-int-structs-25.pk: Likewise.
>       * testsuite/poke.map/maps-int-structs-26.pk: Likewise.
>       * testsuite/poke.map/maps-int-structs-27.pk: Likewise.
>       * testsuite/poke.map/maps-int-structs-28.pk: Likewise.
>       * testsuite/Makefile.am (EXTRA_DIST): Update.
> ---
>
> Hi, Jose.
>
> The fix with tests!

Thanks, this is OK for master.

> ## 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 :)



reply via email to

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