Language Change Specification for Empty records syntax regularization


LCS Number: LCS-2016-082
Version: 2
Date: 22-Dec-2016 (ver.1), 10-Feb-2017 (ver.2)
Status:  
Author: Ryan Hinton
Email:  
Source Doc: Syntax regularization: empty records
Summary: Allow record type definitions to have zero elements

Voting Results: Cast your votes here

Yes:

  1. Ryan Hinton - 2016-12-22 - Version 2
  2. Thomas Preusser - 2016-12-22 - Version 2
  3. Farrell Ostler - 2016-12-22 - Version 1
  4. Brent Hayhoe - 2016-12-23 - Version 1
  5. Jakko Verhallen - 2016-12-29 - Version 1
  6. Martin Zabel - 2017-02-17 - Version 2
  7. Rob Gaddi - 2017-01-26 - Version 1
  8. Jim Lewis- 2017-02-06 - Version 1
  9. Patrick Lehmann - 2017-02-16 - Version 2

No:

Abstain:

  1. Kevin Jennings - 2016-12-23 - Version 1...don't think I'll make use of this, but not really opposed if it helps someone else
  2. Lieven Lemiengre - 2017-01-27
  3. Brent Hayhoe - 2017-02-16 Version 2 - Abstain due to lack of personal time for review.
  4. Martin Thompson- 2017-02-17 Version 2 - what KevinJ said

Details of Language Change

Changes are shown in red font. Deleted text is crossed out. Editing comments are in green.

LRM 5.3.3 Record types

Modify BNF after first full paragraph, middle of page 51 (pdf 65).


record_type_definition ::=
    record
        element_declaration
        { element_declaration }
    end record [ record_type_simple_name ]

(The identical change should be made in the syntax summary in Annex C.)

LRM 9.3.5 Qualified expressions

A qualified expression is a basic operation (see 5.1) that is used to explicitly state the type, and possibly the subtype, of an operand that is an expression or an aggregate.

qualified_expression ::=
     type_mark ' ( expression )
   | type_mark ' aggregate
   | type_mark ' ( )

For qualified expressions with an operand, Tthe operand shall have the same type as the base type of the type mark. The value of such a qualified expression is the value of the operand. The evaluation of such a qualified expression evaluates the operand and converts it to the subtype denoted by the type mark.

A qualified expression without an operand is used to express a literal for a composite type or subtype with no elements. The value of such a qualified expression is an empty value of the type or subtype denoted by the type mark.

-- Ryan Hinton - 2016-12-22

Comments

Suave uses "type foo is null record" to define empty records. How does a map to an empty record look like? Are empty record compatible?

-- Patrick Lehmann - 2016-12-31

PL: Suave uses type foo is null record to define empty records.

MZ: Requiring null record does not work well with conditional compilation. The record might get empty based on conditions.

-- Martin Zabel - 2017-01-09

An alternative for null record is:

type MyRecord is record
  null;
end record;

I changed my vote to NO, because I think an empty initialization should be addressed by this proposal too.

type MyRecord is record
`if DEBUG = "TRUE" then
  debug1 : std_logic;
`end if
end record;

entity E1 is
  port (P : MyRecord);
end entity;

entity E2 is
end entity;

architecture A2 of E2 is
begin
  inst : entity work.E1
    port map (P => (
`if DEBUG = "TRUE" then
        debug1 => '1'
`end if
      )
    );
end architecture;

If DEBUG is FALSE, then the port map collapses to port map (P => () ). Empty aggregation lists are not supported.

-- Patrick Lehmann - 2017-01-09

Could we force a record aggregate that may be empty to use a qualified expression? In Patrick's example:

architecture A2 of E2 is
begin
  inst : entity work.E1
    port map (P => MyRecord'(
`if DEBUG = "TRUE" then
        debug1 => '1'
`end if
      )
    );
end architecture;

-- Rob Gaddi - 2017-01-27

Version 2 created to use Rob's great idea.

-- Ryan Hinton - 2017-02-10

What happens for string'('A') is then the ('A') understood as a element of an aggregate? string'() = ""

I am not saying that there are any issues, but there may be some rough edges

-- Jim Lewis - 2017-03-21

Topic revision: r22 - 2017-04-02 - 15:42:45 - PatrickLehmann
 
Copyright © 2008-2024 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback