comp.lang.ada
 help / color / mirror / Atom feed
* Problem with generic package
@ 2014-04-15 18:26 Laurent
  2014-04-15 19:36 ` Adam Beneschan
                   ` (2 more replies)
  0 siblings, 3 replies; 20+ messages in thread
From: Laurent @ 2014-04-15 18:26 UTC (permalink / raw)


Hi

As an exercise I have created a generic search function. Because my library folder begins to get messy I tried to put some related parts together in a package.

https://github.com/Chutulu/Library.git

The generic swap and sort are working as standalone but in my package I get this error:

expect generic subprogram in instantiation

No idea what the compiler tries to explain.

Thanks

Laurent


package body Array_Generics is

   procedure Swap_Generic (Value1, Value2 : in out Element_Type) is

      Temp_Value : Element_Type;

   begin -- Swap_Generic

      Temp_Value := Value1;
      Value1 := Value2;
      Value2 := Temp_Value;

   end Swap_Generic;

   procedure Sort_Generic (List : in out List_Type) is

      -- We need to make an instance of Swap_Generic for this case

      error ==>procedure Exchange is new Swap_Generic (Value_Type => Element_Type); <== error

      Index_Of_Min : Index_Type;

      .
      .
      .


^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: Problem with generic package
  2014-04-15 18:26 Problem with generic package Laurent
@ 2014-04-15 19:36 ` Adam Beneschan
  2014-04-15 19:44 ` Adam Beneschan
  2014-04-15 20:41 ` Simon Wright
  2 siblings, 0 replies; 20+ messages in thread
From: Adam Beneschan @ 2014-04-15 19:36 UTC (permalink / raw)


On Tuesday, April 15, 2014 11:26:49 AM UTC-7, Laurent wrote:
> Hi
> 
> As an exercise I have created a generic search function. Because my library folder begins to get messy I tried to put some related parts together in a package.
> 
> https://github.com/Chutulu/Library.git
> 
> The generic swap and sort are working as standalone but in my package I get this error:
> 
> expect generic subprogram in instantiation
> 
> No idea what the compiler tries to explain.

> package body Array_Generics is
> 
>    procedure Swap_Generic (Value1, Value2 : in out Element_Type) is

This is not a generic.  Generics begin with the word "generic".  Therefore, you can't instantiate it.

It looks like you want to make this a generic and you want the generic type parameter to be called Value_Type.  Try this:

   generic
      type Value_Type is private;
   procedure Swap_Generic (Value1, Value2 : in out Value_Type) is 
      Temp_Value : Value_Type; 
   begin -- Swap_Generic 
      Temp_Value := Value1; 
      Value1 := Value2; 
      Value2 := Temp_Value; 
   end Swap_Generic; 

                               -- Adam


^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: Problem with generic package
  2014-04-15 18:26 Problem with generic package Laurent
  2014-04-15 19:36 ` Adam Beneschan
@ 2014-04-15 19:44 ` Adam Beneschan
  2014-04-15 20:12   ` Laurent
  2014-04-15 20:41 ` Simon Wright
  2 siblings, 1 reply; 20+ messages in thread
From: Adam Beneschan @ 2014-04-15 19:44 UTC (permalink / raw)


Sorry, I was a bit hasty with my previous response.  I was looking just at the code you posted here, which wasn't complete information.  On looking at the code at your github site, I think I see what's going on.

The problem is that in this line:

    procedure Exchange is new Swap_Generic (Value_Type => Element_Type);

since you have a Swap_Generic in the same package body, the compiler thinks that's what the name Swap_Generic refers to.  But it looks like you also have a top-level generic procedure Swap_Generic.  I assume that's what the above line was trying to instantiate.

First of all, you need to put "with Swap_Generic;" at the top of Array_Generics.adb; otherwise the top-level generic procedure can never be used. 

Then, since the name of the other non-generic Swap_Generic hides the one you've WITH'ed, you need to say this in order to instantiate the generic Swap_Generic:

    procedure Exchange is new 
        Standard.Swap_Generic (Value_Type => Element_Type);

since all top-level units are children of Standard.  The compiler cannot use "overload resolution" to find the correct Swap_Generic because generics cannot be overloaded with anything.

                                -- Adam

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: Problem with generic package
  2014-04-15 19:44 ` Adam Beneschan
@ 2014-04-15 20:12   ` Laurent
  2014-04-15 20:37     ` Adam Beneschan
                       ` (2 more replies)
  0 siblings, 3 replies; 20+ messages in thread
From: Laurent @ 2014-04-15 20:12 UTC (permalink / raw)


Hi

Hm yes and no. I am trying to get rid of Swap_Generic and Sort_Generic. Trying to combine those together with my generic search function in one generic package: array_generics (stupid name have to find something else). Have just posted them for completeness but forgotten to write it (if its clear for me doesn't mean it is for someone else).

Sorry for the confusion.

If I leave the swap_generic.ads and with'ing it, comment the swap in the array_generic.adb out then the instantiation works without changing anything else.

If I remove the swap_generic.adb from the library folder, remove the with'ing, reload project...
and try to instantiate the swap_generic from the package I get this error:

expect generic subprogram in instantiation.

No idea why the compiler complains. Should be the same thing as before. 

Thanks

Laurent




^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: Problem with generic package
  2014-04-15 20:12   ` Laurent
@ 2014-04-15 20:37     ` Adam Beneschan
  2014-04-15 20:43     ` Eryndlia Mavourneen
  2014-04-15 21:28     ` Georg Bauhaus
  2 siblings, 0 replies; 20+ messages in thread
From: Adam Beneschan @ 2014-04-15 20:37 UTC (permalink / raw)


On Tuesday, April 15, 2014 1:12:33 PM UTC-7, Laurent wrote:
> Hi
> 
> 
> 
> Hm yes and no. I am trying to get rid of Swap_Generic and Sort_Generic. Trying to combine those together with my generic search function in one generic package: array_generics (stupid name have to find something else). Have just posted them for completeness but forgotten to write it (if its clear for me doesn't mean it is for someone else).
> 
> Sorry for the confusion.
> 
> If I leave the swap_generic.ads and with'ing it, comment the swap in the array_generic.adb out then the instantiation works without changing anything else.
> 
> If I remove the swap_generic.adb from the library folder, remove the with'ing, reload project...
> 
> and try to instantiate the swap_generic from the package I get this error:
> 
> expect generic subprogram in instantiation.
> 
> No idea why the compiler complains. Should be the same thing as before. 

No--it definitely is not the same.  In the version with top-level Sort_Generic and Swap_Generic, both of those are generics, and you would instantiate them.  But if you have a generic package Array_Generics with two *non-generic* procedures Sort_Generic and Swap_Generic, you would only instantiate Array_Generics--never Sort_Generic or Swap_Generic.  You can only instantiate generics, and generics are things declared with the word "generic".  

In this case, if you were *outside* of Array_Generics, you would instantiate Array_Generics:

    package My_Record_Arrays is new Array_Generics
      (Element_Type => My_Record, Index_Type => [something], 
       List_Type => [something], Compare => [something]);

and then you could use Swap_Generic like this:

    My_Record_Arrays.Swap_Generic (v1, v2);

(Of course, it wouldn't be a generic any more, so the name is not appropriate.  Also, if you don't want programs to have to provide Index_Type, List_Type, and Compare, just to use Swap, then you need to move Swap *out* of Array_Generics.  It's not an array routine, so maybe it doesn't belong there anyway.)

In the example you posted, you're already inside Array_Generics, so you can't have Array_Generics instantiate itself.  In this case, you don't want to instantiate Swap_Generic, you just call it.

It looks like you don't quite understand how generics work.  When you instantiate Array_Generics, like this:

    package My_Record_Arrays is new Array_Generics
      (Element_Type => My_Record, Index_Type => Natural, 
       List_Type => My_Record_Array, Compare => My_Compare_Function);
  
it's almost as if you had the specification and body of Array_Generics right there in your code, with the name Array_Generics replaced by My_Record_Arrays, Element_Type replaced by My_Record, Index_Type replace by Natural, and so on.  (The effect isn't exactly the same as replacing names; there are some subtleties that make it different.  But for the purpose of understanding how they work, it's close enough.)  So now you have an instantiated package spec that looks something like this:

    package My_Record_Arrays is
        procedure Swap_Generic (Value_1, Value_2 : in out MY_RECORD_TYPE); 
        procedure Sort_Generic (List : in out MY_RECORD_ARRAY);
        ...

and an instantiated package body that looks something like:

    package body My_Record_Arrays is

        procedure Swap_Generic (Value_1, Value_2 : in out MY_RECORD_TYPE) is 
            ...
        end Swap_Generic;

        procedure Sort_Generic (List : in out MY_RECORD_ARRAY) is 
            ...
        end Sort_Generic;

And within this (pretend) instantiated package body, you wouldn't need to instantiate Swap_Generic, would you?  You'd just call it, because all the generic parameters have been replaced already.  And in the rest of your program, if you had an package spec that looked like the above, you'd use the swap procedure by calling My_Record_Arrays.Swap_Generic(X,Y), right?  Well, that's how you'd call it when you do it with a generic.

Anyway, that's roughly how you need to think about generics.  Hope this helps clear things up.

                            -- Adam


^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: Problem with generic package
  2014-04-15 18:26 Problem with generic package Laurent
  2014-04-15 19:36 ` Adam Beneschan
  2014-04-15 19:44 ` Adam Beneschan
@ 2014-04-15 20:41 ` Simon Wright
  2014-04-15 21:12   ` Laurent
  2 siblings, 1 reply; 20+ messages in thread
From: Simon Wright @ 2014-04-15 20:41 UTC (permalink / raw)


Laurent <daemon2@internet.lu> writes:

>    procedure Sort_Generic (List : in out List_Type) is
>
>       -- We need to make an instance of Swap_Generic for this case
>
>       error ==>procedure Exchange is new Swap_Generic (Value_Type => Element_Type); <== error

You do *not* need to make an instance of Swap_Generic; within the body
of Array_Generic you can refer to Swap_Generic as it is. And, as Adam
says, Swap_Generic isn't actually a generic subprogram in its own right,
it's "just" a subprogram in a generic package.

The compiler messages I got were

   array_generics.adb:18:33: expect generic subprogram in instantiation
   array_generics.adb:36:13: "Exchange" is undefined

so delete the first line and replace Exchange by Swap_Generic in the
second.


By the way, GNAT works much better if you stick with lower-case file
names (I think your code wouldn't compile on Linux, which has
case-sensitive file names; when compiling Array_Generics.adb GNAT
expects to find array_generics.ads, not Array_Generics.ads).

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: Problem with generic package
  2014-04-15 20:12   ` Laurent
  2014-04-15 20:37     ` Adam Beneschan
@ 2014-04-15 20:43     ` Eryndlia Mavourneen
  2014-04-15 20:47       ` Eryndlia Mavourneen
  2014-04-15 21:28     ` Georg Bauhaus
  2 siblings, 1 reply; 20+ messages in thread
From: Eryndlia Mavourneen @ 2014-04-15 20:43 UTC (permalink / raw)


On Tuesday, April 15, 2014 3:12:33 PM UTC-5, Laurent wrote:
> Hi
> 
> Hm yes and no. I am trying to get rid of Swap_Generic and Sort_Generic. Trying to combine those together with my generic search function in one generic package: array_generics (stupid name have to find something else). Have just posted them for completeness but forgotten to write it (if its clear for me doesn't mean it is for someone else).
> 
> Sorry for the confusion.
> 
> If I leave the swap_generic.ads and with'ing it, comment the swap in the array_generic.adb out then the instantiation works without changing anything else.
> 
> If I remove the swap_generic.adb from the library folder, remove the with'ing, reload project...and try to instantiate the swap_generic from the package I get this error:
> 
>     expect generic subprogram in instantiation.
> 
> No idea why the compiler complains. Should be the same thing as before. 
> 
> Thanks
> Laurent

I believe the problem is that you did not define a Compare function in your instantiation.  Try

        with function Compare (Left, Right : Element_Type) return Boolean is <>;

Eryndlia Mavourneen
(KK1T)


^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: Problem with generic package
  2014-04-15 20:43     ` Eryndlia Mavourneen
@ 2014-04-15 20:47       ` Eryndlia Mavourneen
  0 siblings, 0 replies; 20+ messages in thread
From: Eryndlia Mavourneen @ 2014-04-15 20:47 UTC (permalink / raw)


The box tells the compiler to look for a function named Compare, if one is not specified in the instantiation.

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: Problem with generic package
  2014-04-15 20:41 ` Simon Wright
@ 2014-04-15 21:12   ` Laurent
  2014-04-15 21:27     ` Adam Beneschan
  2014-04-15 22:14     ` Simon Wright
  0 siblings, 2 replies; 20+ messages in thread
From: Laurent @ 2014-04-15 21:12 UTC (permalink / raw)



> so delete the first line and replace Exchange by Swap_Generic in the...

I got that by myself so at least some progress :)

The whole problem comes from the fact that swap_generic and sort_generic where given in the book, the search_generic was left as exercise which I was able to solve.

Just trying to get those 3 things in one package disturbed me. At least I probably won't forget it. 

MacOS doesn't care about case even if it is unix based.

Tried to use my array_generics in some test program. 
error: invalid prefix in selected component "Array_Generics"

the with'ing and prefix'ing is also proposed by gps. perhaps again the same problem as before? not understanding what I am doing? 

Thanks


with Ada.Text_IO;
with Ada.Integer_Text_IO;
with Ada.Float_Text_IO;
with Array_Generics;

procedure Test_Search_Array_Generic is

   subtype Index is Integer range 1 .. 10;

   type Float_Vector is array (Index range <>) of Float;

   V1 : Float_Vector (1 .. 10);

 ==>  function Search_Float is new Array_Generics.Search_Generic
     (List_Type => Float_Vector, Index_Type => Index, Element_Type => Float); <== error

   procedure Display_Float_Vector (V : Float_Vector) is

      Target: Float;

   begin -- Display_Float_Vector

      Ada.Text_IO.Put (Item => "Please enter the value to search for: ");
      Ada.Float_Text_IO.Get (Item => Target);
      Ada.Integer_Text_IO.Put (Item => Search_Float (List => V, Target => Target),Width => 1);
      Ada.Text_IO.New_Line;

   exception
      when Array_Generics.Item_Not_Found =>
         Ada.Text_IO.Put (Item => "Target not found!");

   end Display_Float_Vector;

begin

   V1 := (0.7, 1.5, 6.9, -3.2, 0.0, 5.1, 2.0, 7.3, 2.2, -5.9);

   Display_Float_Vector (V => V1);

end Test_Search_Array_Generic;



^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: Problem with generic package
  2014-04-15 21:12   ` Laurent
@ 2014-04-15 21:27     ` Adam Beneschan
  2014-04-15 21:58       ` Laurent
  2014-04-15 22:14     ` Simon Wright
  1 sibling, 1 reply; 20+ messages in thread
From: Adam Beneschan @ 2014-04-15 21:27 UTC (permalink / raw)


On Tuesday, April 15, 2014 2:12:07 PM UTC-7, Laurent wrote:

> Tried to use my array_generics in some test program. 
> 
> error: invalid prefix in selected component "Array_Generics"

>  ==>  function Search_Float is new Array_Generics.Search_Generic
>      (List_Type => Float_Vector, Index_Type => Index, Element_Type => Float); 

You can only instantiate Array_Generics.  Search_Generic is not a generic.

                            -- Adam

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: Problem with generic package
  2014-04-15 20:12   ` Laurent
  2014-04-15 20:37     ` Adam Beneschan
  2014-04-15 20:43     ` Eryndlia Mavourneen
@ 2014-04-15 21:28     ` Georg Bauhaus
  2 siblings, 0 replies; 20+ messages in thread
From: Georg Bauhaus @ 2014-04-15 21:28 UTC (permalink / raw)


On 15/04/14 22:12, Laurent wrote:
> Hi
>
> Hm yes and no. I am trying to get rid of Swap_Generic and Sort_Generic. Trying to combine those together with my generic search function in one generic package: array_generics (stupid name have to find something else). Have just posted them for completeness but forgotten to write it (if its clear for me doesn't mean it is for someone else).
>
> Sorry for the confusion.
>
> If I leave the swap_generic.ads and with'ing it, comment the swap in the array_generic.adb out then the instantiation works without changing anything else.
>
> If I remove the swap_generic.adb from the library folder, remove the with'ing, reload project...
> and try to instantiate the swap_generic from the package I get this error:
>
> expect generic subprogram in instantiation.

I think the confusion is elsewhere.
   The package Array_Generics, declared in Array_Generics.ads, and the
declarations in Swap_Generic.ads are not related at all, since Array_Generics
does not "with" Swap_Generic. It does, however, declare a procedure
of the same name, Swap_Generic, which is a plain procedure.  A plain procedure
cannot be instantiated, as others have noted.

Briefly, using one-letter names, you have

a.ads  declaring  generic procedure a,                  (1)
p.ads  declaring  generic package p with some a in it   (2)

Now, a from (1) and a from (2) are unrelated, they just happen
to be both named a. Maybe you had a from (1) in mind when you
effectively tried to instantiate a from (2).

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: Problem with generic package
  2014-04-15 21:27     ` Adam Beneschan
@ 2014-04-15 21:58       ` Laurent
  2014-04-15 22:03         ` Adam Beneschan
  2014-04-16  6:03         ` Georg Bauhaus
  0 siblings, 2 replies; 20+ messages in thread
From: Laurent @ 2014-04-15 21:58 UTC (permalink / raw)



> You can only instantiate Array_Generics.  Search_Generic is not a generic.

Hm now that one I don't understand. search_generic was generic before I transformed it into array_generics. It worked and could be instantiated. Now that it is inside this package it doesn't work anymore? 

I have the feeling that OOP is just about generating millions of small pieces just to puzzle them again together. Bah don't like that. Probably a reason why I hate java. Had just the choice between VB and Java, hm pest or cholera? Unfortunately no Ada course :(

Concerning (1) and (2): No I have some (1)'s and I try to put them into (2) to get rid of the (1)'s. Where I want (2) to be a package which contains a generic swap, sort and search function/procedure. 

Thanks

Laurent

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: Problem with generic package
  2014-04-15 21:58       ` Laurent
@ 2014-04-15 22:03         ` Adam Beneschan
  2014-04-16  6:03         ` Georg Bauhaus
  1 sibling, 0 replies; 20+ messages in thread
From: Adam Beneschan @ 2014-04-15 22:03 UTC (permalink / raw)


On Tuesday, April 15, 2014 2:58:23 PM UTC-7, Laurent wrote:
> > You can only instantiate Array_Generics.  Search_Generic is not a generic.
> 
> 
> 
> Hm now that one I don't understand. search_generic was generic before I transformed it into array_generics.  It worked and could be instantiated. Now that it is inside this package it doesn't work anymore? 

Because it's not a generic any more.  I've said this at least twice already, but a generic is something that is declared with the word "generic", and Search_Generic is no longer declared with the word "generic".  Now that Array_Generics is a generic and the procedures are not generic, you can instantiate Array_Generics but you cannot instantiate the procedures.

                               -- Adam


^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: Problem with generic package
  2014-04-15 21:12   ` Laurent
  2014-04-15 21:27     ` Adam Beneschan
@ 2014-04-15 22:14     ` Simon Wright
  2014-04-16 18:49       ` Laurent
  1 sibling, 1 reply; 20+ messages in thread
From: Simon Wright @ 2014-04-15 22:14 UTC (permalink / raw)


Laurent <daemon2@internet.lu> writes:

> MacOS doesn't care about case even if it is unix based.

But I've seen GNAT running on Mac OS X get *very* confused about
unexpected file name casing. Best to get yourself out of the habit
before it bites you. Or, worse, someone who's trying to use your work in
a different environment.

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: Problem with generic package
  2014-04-15 21:58       ` Laurent
  2014-04-15 22:03         ` Adam Beneschan
@ 2014-04-16  6:03         ` Georg Bauhaus
  2014-04-16 20:37           ` Laurent
  1 sibling, 1 reply; 20+ messages in thread
From: Georg Bauhaus @ 2014-04-16  6:03 UTC (permalink / raw)


On 15/04/14 23:58, Laurent wrote:
>
>> You can only instantiate Array_Generics.  Search_Generic is not a generic.

> Concerning (1) and (2): No I have some (1)'s and I try to put them into (2) to get rid of the (1)'s. Where I want (2) to be a package which contains a generic swap, sort and search function/procedure.

Right. As Adam explains, you need to declare them so.

generic
    the package's parameters
package p is ...

     generic -- ?
       further, the procedure's parameters -- ?
     procedure a (...) is
     
end p;

If procedure `a' should operate in terms of the package's parameters,
and no further, special, generic formal parameters of its own,
then it need not be generic on its own, since each instance of the
package also makes one procedure `a' that sees the actuals "around"
it, i.e., the types etc. passed to the package's formal parameters
on instantiation of package p.

If, on the other hand, procedure `a' needs generic parameters in
addition to those of the package in which it is declared, then it
needs to be declared as a generic as shown, preceded by its own
"generic" part.

Example:

generic
    type T is private;
package Stack is

     procedure push (Item : T);

     generic
        with function Compare (X, Y : T) return Boolean;
     procedure Sort;

end Stack;



^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: Problem with generic package
  2014-04-15 22:14     ` Simon Wright
@ 2014-04-16 18:49       ` Laurent
  0 siblings, 0 replies; 20+ messages in thread
From: Laurent @ 2014-04-16 18:49 UTC (permalink / raw)


> But I've seen GNAT running on Mac OS X get *very* confused about 
> unexpected file name casing. Best to get yourself out of the habit
> before it bites you. Or, worse, someone who's trying to use your work in
> a different environment.

Thought that it was GPS taking care of the naming case but it is configured to use lowercase. Tried gnat make from terminal with first letter uppercase filename and it didn't complain.

Doesn't take a lot of effort to adapt to lowercase naming so for the next file I will use it.

Laurent

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: Problem with generic package
  2014-04-16  6:03         ` Georg Bauhaus
@ 2014-04-16 20:37           ` Laurent
  2014-04-16 21:13             ` Mike H
  0 siblings, 1 reply; 20+ messages in thread
From: Laurent @ 2014-04-16 20:37 UTC (permalink / raw)



> Example:

> generic
>     type T is private;
> package Stack is
>      procedure push (Item : T);
>      generic
>         with function Compare (X, Y : T) return Boolean;
>      procedure Sort; 
> end Stack;

Yes thanks that is clear and got my test to work.

@Adam: Sry there are moments where I am blocking on a problem
and I don't see anything around.

If I have a big generic package but I need only one function from it
but for different types. I have to instantiate the package once for every type.
Which means that there will be a lot of memory allocated for
unused things? Or is the compiler smart enough to cut the unused
parts off?

Thanks

Laurent


^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: Problem with generic package
  2014-04-16 20:37           ` Laurent
@ 2014-04-16 21:13             ` Mike H
  2014-04-16 22:31               ` Randy Brukardt
  2014-04-16 23:06               ` Jeffrey Carter
  0 siblings, 2 replies; 20+ messages in thread
From: Mike H @ 2014-04-16 21:13 UTC (permalink / raw)


 Laurent  writes
>If I have a big generic package but I need only one function from it
>but for different types. I have to instantiate the package once for every type.
>Which means that there will be a lot of memory allocated for
>unused things? Or is the compiler smart enough to cut the unused
>parts off?
>
Ada has been around since the 1980s. Always assume that the compiler
writers are smaller than you are until contrary evidence suggests
otherwise

-- 
Knowledge is knowing a tomato is a fruit
Wisdom in knowing not to put it in the fruit salad.
Mike ;-)

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: Problem with generic package
  2014-04-16 21:13             ` Mike H
@ 2014-04-16 22:31               ` Randy Brukardt
  2014-04-16 23:06               ` Jeffrey Carter
  1 sibling, 0 replies; 20+ messages in thread
From: Randy Brukardt @ 2014-04-16 22:31 UTC (permalink / raw)


"Mike H" <postmaster@ada-augusta.demon.co.uk> wrote in message 
news:dJJMtxAMKvTTFwdN@ada-augusta.demon.co.uk...
> Laurent  writes
>>If I have a big generic package but I need only one function from it
>>but for different types. I have to instantiate the package once for every 
>>type.
>>Which means that there will be a lot of memory allocated for
>>unused things? Or is the compiler smart enough to cut the unused
>>parts off?
>>
> Ada has been around since the 1980s. Always assume that the compiler
> writers are smaller than you are until contrary evidence suggests
> otherwise

I think you probably meant "smarter" rather than "smaller" in the above. 
Otherwise, I think you are making an unsupportable statement (although it 
might have been true in my specific case when Janus/Ada was created, not so 
much anymore ;-).

                       Randy.




^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: Problem with generic package
  2014-04-16 21:13             ` Mike H
  2014-04-16 22:31               ` Randy Brukardt
@ 2014-04-16 23:06               ` Jeffrey Carter
  1 sibling, 0 replies; 20+ messages in thread
From: Jeffrey Carter @ 2014-04-16 23:06 UTC (permalink / raw)


On 04/16/2014 02:13 PM, Mike H wrote:
>>
> Ada has been around since the 1980s. Always assume that the compiler
> writers are smaller than you are until contrary evidence suggests
> otherwise

Some compiler writers are pretty big guys.

-- 
Jeff Carter
"You couldn't catch clap in a brothel, silly English K...niggets."
Monty Python & the Holy Grail
19

^ permalink raw reply	[flat|nested] 20+ messages in thread

end of thread, other threads:[~2014-04-16 23:06 UTC | newest]

Thread overview: 20+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-04-15 18:26 Problem with generic package Laurent
2014-04-15 19:36 ` Adam Beneschan
2014-04-15 19:44 ` Adam Beneschan
2014-04-15 20:12   ` Laurent
2014-04-15 20:37     ` Adam Beneschan
2014-04-15 20:43     ` Eryndlia Mavourneen
2014-04-15 20:47       ` Eryndlia Mavourneen
2014-04-15 21:28     ` Georg Bauhaus
2014-04-15 20:41 ` Simon Wright
2014-04-15 21:12   ` Laurent
2014-04-15 21:27     ` Adam Beneschan
2014-04-15 21:58       ` Laurent
2014-04-15 22:03         ` Adam Beneschan
2014-04-16  6:03         ` Georg Bauhaus
2014-04-16 20:37           ` Laurent
2014-04-16 21:13             ` Mike H
2014-04-16 22:31               ` Randy Brukardt
2014-04-16 23:06               ` Jeffrey Carter
2014-04-15 22:14     ` Simon Wright
2014-04-16 18:49       ` Laurent

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