Hi Tucker,

My thoughts:

You said yourself that this is "quite similar to the situation of calling an 
iterating procedure that has a single access-to-procedure parameter, plus zero 
or more other parameters."

If the following procedure was defined, you could already use a procedural 
iterator, according to what is already written in 5.5.3 of Ada 202X Draft 23:

  procedure Iterate_Some_Structure (Obj : Structure_Type; Action : not null 
access procedure (Key : Key_Type; Value : Value_Type));


So... the idea, then, is that the language would effectively recognize the 
generic signature as being equivalent to the access-to-procedure parameter.
(at least in this context)

This would be to make it easier to use existing libraries that chose to use the 
generic approach rather than offering a procedure with a single 
access-to-procedure parameter.

As it is, we could already wrap the generic if we want to use the procedural 
iterator;
The following code wraps such a generic and works for what it is in GNAT, for 
example:

procedure Wrap_Iterate_Some_Structure (Obj : Structure_Type; Action : not null 
access procedure (Key : Key_Type; Value : Value_Type)) is
  procedure Call_It is new Iterate_Some_Structure (Action => Action.all);
begin
  Call_It (Obj => Obj);
end Wrap_Iterate_Some_Structure;

But your solution avoids having to explicitly instantiate the generic or add 
any additional named procedures;
it would be like generating and calling the above procedure without the 
developer having to write it.

It is definitely a neat idea, but I don't see how it would generalize.


If this becomes part of the language, users might expect it to generalize, or 
it just becomes an odd one-off special case;
I'd want to know how else I could use this seemingly powerful capability:
It's basically a light-weight way of using an anonymous ephemeral generic 
instantiation... but it only works when there's a only single formal procedure 
parameter.
I think it is too much of a special case if it's limited to this, but I'd be 
interested in other people weighing in.

If we could build on this to allow it to be more general, it could be really 
interesting; possibly a part of how to bring generics into the 21st century.
... but right now this is only addressing a case that doesn't even need a 
generic.

- message sent in plain text -

Joshua Fletcher
613-721-4405

From: Tucker Taft @ adacore <[email protected]>
Sent: Tuesday, December 10, 2019 8:39 AM
To: Ada-Comment List <[email protected]>
Subject: Re: [Ada-Comment] Possible generalization of Procedural Iterator


On Dec 9, 2019, at 1:50 PM, Fletcher, Joshua <mailto:[email protected]> 
wrote:

I'm following up on my previous response, as I hadn't fully grasped the power 
of the procedural iterators.
To me, they appear similar to lambda expressions and closures in other 
languages.

I really like the power offered by the procedural iterators.
...

They have turned out to be useful in a number of contexts.

Unfortunately, I was unable to determine from your responses what you thought 
of generalizing this "syntactic sugar" to cover the case of a generic with a 
single formal parameter that is a formal procedure.

Take care,
-Tuck
“This message and/or attachments may include information subject to GD 
Corporate Policies 07-103 and 07-105 and is intended to be accessed only by 
authorized recipients. Use, storage and transmission are governed by General 
Dynamics and its policies. Contractual restrictions apply to third parties. 
Recipients should refer to the policies or contract to determine proper 
handling. Unauthorized review, use, disclosure or distribution is prohibited. 
If you are not an intended recipient, please contact the sender and destroy all 
copies of the original message.”
b��j�yǢ��m�+&z����q��{*.���r��y�h��u���g��f��)�+-N�^j��h*&���+-���jw�j)p��ey��ւ�i��ا���ܭ�X��ǫ��Zj�a����^��'����r��jwlj��zǧv��Z
��z{m��^���i�kz����zkzwfj)m���֝i�����N��+-��)z��y���u�^���q�,��"jب���<�h�μ�װb��5�t�^��

Reply via email to