Ada-Rapporteur-Group / User-Community-Input

Ada User Community Input Working Group - Github Mirror Prototype
27 stars 1 forks source link

Named parameters in reduction expression #13

Closed sttaft closed 11 months ago

sttaft commented 2 years ago

!reference Ada 202x RM4.5.10(23/5) !from Chrisoph Grein 2021-07-17 !keywords named parameter notation !discussion

I've always liked the named parameter notation and use it always when it adds information like e.g. in Put (I, Width => 42), I hate to see calls like Put (X, 2, 3). I however use it never in cases where the actual and formal parameter have the same name - that's just noise - with one important exception: in cases like Arctan where calls with positional notation lose important information (here the coordinates, especially so as parameters are called y, x in this sequence).

To come to the point. Reduction expression are missing this feature and are less readable: My_Rates'Reduce (Float'Min, Float'Last) and I can easily dream up more cryptic expressions.

I'm very well aware of the problems: There is no way in Ada to use subprograms as parameters (only as access). What is more: Operators used in such expressions may be intrinsic, so they have not access.

So in the syntax proposed, there is a lot of magic involved. ... Perhaps ARG ingenuity can come up with a solution.

Christoph

CKWG commented 1 year ago

Hm, I just found a problem with this proposal: In an attribute_definition_clause, no named parameter associations seem to be allowed. For example the stream attributes have parameters given in italics. procedure S'Write(Stream : not null access Ada.Streams.Root_Stream_Type'Class; Item : in T); This seems to say that the actual parameters cannot be given in named association. However, I cannot find a statement in the RM stating this fact. Only in 1.1.4(14), I can find that _xxx_name is equivalent to name alone. But there is no name here! (Sh, in compound words, xxx is not displayed in italics!) So where is it stated in the RM that i cannot write X'Write (Stream => Ada.Text_IO.Text_Streams.Stream (Ada.Text_IO.Standard_Output), Item => Object);

ARG-Editor commented 11 months ago

This topic is included in AI22-0081-1.

ARG-Editor commented 11 months ago

AI22-0081-1 was Approved by the ARG at meeting #63A, so this issue has been closed.