Syntax Regularlization: Empty Records
Proposal Information
- Who Updates: RyanHinton
- Date Proposed: 2013-10-28
- Date Last Updated: 2013-10-28
- Priority:
- Complexity:
- Focus: General Language
Language Change Specification link
LCS-2016-082
Requirement Summary
Allow record declarations to contain no elements.
Rationale
Record with debug ports. Record has elements when debugging block. Record empty in final design.
The need is similar to that for null arrays. Often I want a port into a component, e.g. for status, and I don't know ahead of time what status I need to include. Assume I write my entity before my architecture and I want to wrap all the status signals in a single OUT-mode record port. Then I have several choices.
- Be omniscient and know from the start exactly what I need on my interface. (This may work for you, but it doesn't for me.)
- Don't define the record type or add the port until I have the first status item to report. This requires changing a the entity declaration, the package for the record type, any component declaraions, and any instantiations. And then later if all my status items go away for some reason, I have to remove the port and type in all of these contexts again.
- Declare the type in the package and the port in the entity declaration. (Currently this can be done with a dummy element.) Then I can add and remove status items simply by adding them to the type declaration in the package, driving them in the architecture (which is where I usually discover what to drive in the first place), and then hook up a receiver somewhere if desired.
Obviously the third option is ideal.
Related Issues: None = General
Competing Issues: None at this time
Current Syntax:
Currently, a "blank" record requires a dummy element or placeholder of some sort.
type confusing_record is record
dummy : boolean;
-- dummy placeholder to avoid compile errors: confuses designers, muddies
-- the interface, wastes processor cycles when ripped out by synthesis,
-- wastes memory in simulation; otherwise it works fine
end record;
Proposed syntax change
Allow records to have zero elements.
type accurate_interface is record
end record; -- not currently legal
Possible Issues
Arguments FOR
- The LRM impact should be light.
- No apparent syntax ambiguities or issues.
- It shouldn't be difficult for tools to implement.
- It's a nice productivity enhancement.
Arguments AGAINST
Even C doesn't allow empty struct declarations. The only reason one needs a record type is to access fields of the type. If there are no fields, there's no need for a record type.
--
ErnstChristen - 2015-01-21
Null ranges of vectors may occur in values, but objects declared with a null range are meaningless. IMO this proposal makes sense only if slices of records and corresponding concatenations are supported in the language.
Many C compilers do tolerate empty structs though (e.g. gcc), and C++ explicitly allows them. Different languages have different needs and this reference does not provide a helpful insight.
General Comments
Supporters
Add your signature here to indicate support for this proposal.
--
RyanHinton - 2013-10-29
--
Brent Hayhoe - 2013-10-30
--
LievenLemiengre - 2015-06-04
--
ThomasPreusser - 2016-09-09
In opposition
Add your signature here to indicate opposition to this proposal.
--main.CliffordWalinsky - 2013-11-13
--
ErnstChristen - 2015-01-21
Topic revision: r10 - 2020-02-17 - 15:34:29 -
JimLewis