comp.lang.ada
 help / color / mirror / Atom feed
From: Jere <jhb.chat@gmail.com>
Subject: Re: Iterable container as generic parameter
Date: Sat, 27 Jan 2018 06:31:49 -0800 (PST)
Date: 2018-01-27T06:31:49-08:00	[thread overview]
Message-ID: <cda33a6e-bfad-4a4d-b38b-5eecff77633a@googlegroups.com> (raw)
In-Reply-To: <8a75d56c-29d0-464a-9f2a-9126d8f17ba1@googlegroups.com>

On Saturday, January 27, 2018 at 6:38:43 AM UTC-5, Lionel Draghi wrote:
> Le samedi 27 janvier 2018 08:03:49 UTC+1, Randy Brukardt a écrit :
> > ...
> > >By the way, I have another question. There is no way to provide a default
> > > instantiation to a formal package parameter?
> > 
> > Not in Ada 2012 or before. There is an open issue (it is one of those that 
> > Emmanuel referenced in his message) to allow that. It hasn't progressed any 
> > significant amount at this time.
> 
> Very interesting indeed, to have lawyers and implementers view on a language change proposal.
> 
> From my user point of view, the "or use" proposal looks very good.
> It's simple (to write!), easy to read (much more in my opinion than "with Default_Type => ..." syntax).

I agree.  I like the "or use" syntax best so far.

> 
> I would just add that, when reading the comment on the ":=" proposal, that ":=" may seems to imply copying a type, I realized that I was already reading :
> > procedure New_Line (Spacing : Positive_Count := 1);
> as "give your own spacing, _or use_ 1 if none given", and not as 
> "_copy_ 1 in Spacing if none given". 
> 
> So, IMHO, I wouldn't give a high weight to this argument.
>  
> And, actually, 
> > procedure New_Line (Spacing : Positive_Count or use 1);
> looks good too :-)
>  
While I don't like := as much as "or use", I will just add that
in today's Ada, := doesn't always imply copying.  It also can imply
build in place (somewhat similar to move semantics) in some cases.
So I agree that it isn't as much of a stretch.

I would still think "or use" is better though.

Another option that is less useful than default package types is
(making up a term here) package delegation/forwarding:

-- not legal Ada
with Specific_Package; use Specific_Package;

generic
   type Some_Type is limited private;
package Default_Package is new Base_Package
   (First_Param  => Specific_Thing,
    Second_Param => Some_Type);

I think you can do that or something similar in a generic formal,
but I don't think you can define a new generic like this.  It would
only be an alternative to default package formals (I would prefer
those), but would allow for defining a default package specification
for another.  It wouldn't be very useful if you wanted to default
a lot of things in different combinations though.


  reply	other threads:[~2018-01-27 14:31 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-01-25  0:22 Iterable container as generic parameter Lionel Draghi
2018-01-25  3:36 ` Randy Brukardt
2018-01-25 14:58   ` Lionel Draghi
2018-01-25 18:26     ` briot.emmanuel
2018-01-26  4:50     ` Randy Brukardt
2018-01-26  9:09       ` briot.emmanuel
2018-01-26 22:32         ` Lionel Draghi
2018-01-27  7:03           ` Randy Brukardt
2018-01-27 11:38             ` Lionel Draghi
2018-01-27 14:31               ` Jere [this message]
2018-01-28 18:08         ` Lionel Draghi
2018-01-29 13:34           ` briot.emmanuel
2018-01-29 22:26             ` Lionel Draghi
2018-01-29 23:00               ` Randy Brukardt
2018-01-30 22:35                 ` Lionel Draghi
2018-01-30 23:32                   ` Lionel Draghi
2018-01-31  0:15                   ` Lionel Draghi
2018-01-30 15:13               ` Shark8
2018-01-26 23:07 ` Lionel Draghi
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox