poke-devel
[Top][All Lists]
Advanced

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

Re: [RFC] A new mechanism to access the active field of unions


From: Jose E. Marchesi
Subject: Re: [RFC] A new mechanism to access the active field of unions
Date: Fri, 05 Mar 2021 10:29:37 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux)

Proposals extracted from the discussion, so far:

a) Overload `isa' to get both IDENTIFIER and STR

   To the exising:

   a1) VAL isa TYPE

       Checks whether VAL is of type TYPE.

   We add:

   a2) VAL isa IDENTIFIER

       Checks whether VAL is an union value _and_ has a field named
       IDENTIFIER.

   a3) VAL isa STR

       Checks whether VAL is an union value _and_ has a field named STR.

   PRO: no additional keywoards are introduced.
   CON: the overloading of `isa' may be confusing.

b) Like a), but we only add a3) since it is more general.

   PRO: VAL isa IDENTIFIER remains available for something else :P
   CON: in most cases the field name will be constant and it is
         easier to just write an identifier.

c) Like a Use a different keyword instead of `isa' in a2) and a3).
   Maybe `holds'.

   PRO: no potential confusion due to the overloading of `isa'.
   CON: introduces a new keyword in the language.

d) Use an attribute syntax instead of a binary operator syntax.

   VAL'holds("foo")

   PRO: no need to introduce new keyword.
   PRO: can also be applied to structs (more orthogonal)
   CON: in most cases the field name will be constant and it is
         easier to just write an identifier.



reply via email to

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