comp.lang.ada
 help / color / mirror / Atom feed
* Curious function signature issue
@ 2013-10-24 21:12 RasikaSrinivasan
  2013-10-24 22:03 ` Jeffrey Carter
  2013-10-24 22:04 ` Adam Beneschan
  0 siblings, 2 replies; 3+ messages in thread
From: RasikaSrinivasan @ 2013-10-24 21:12 UTC (permalink / raw)


all

I have a package P that looks like this:

package P is
   type Person_Type is private ;
   function Create( targetsfile : String := "targets.dat" ;
                    basalfile : String := "basal.dat" ;
                    isffile : String := "isf.dat" ;
                    icrfile : String := "icr.dat" )
                   return Person_Type ;
   function Create return Person_Type ;
   
....
....
end P ;

I am curious how gnat (2013 if it matters) can distinguish between the two overloaded "Create" functions?

The project built successfully though I am yet to exercise the runtime.

thanks for any clues, srini

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

* Re: Curious function signature issue
  2013-10-24 21:12 Curious function signature issue RasikaSrinivasan
@ 2013-10-24 22:03 ` Jeffrey Carter
  2013-10-24 22:04 ` Adam Beneschan
  1 sibling, 0 replies; 3+ messages in thread
From: Jeffrey Carter @ 2013-10-24 22:03 UTC (permalink / raw)


On 10/24/2013 02:12 PM, RasikaSrinivasan@gmail.com wrote:
>
> package P is
>     type Person_Type is private ;
>     function Create( targetsfile : String := "targets.dat" ;
>                      basalfile : String := "basal.dat" ;
>                      isffile : String := "isf.dat" ;
>                      icrfile : String := "icr.dat" )
>                     return Person_Type ;
>     function Create return Person_Type ;
>
> I am curious how gnat (2013 if it matters) can distinguish between the two overloaded "Create" functions?

One has parameters; the other doesn't.

It's at the point of a call to one of these that the compiler has to be able to 
determine which is being called. I can't see how you could successfully call the 
Create without parameters, or the Create with parameters using all the defaults, 
so I suspect you must have only called the version with parameters, and supplied 
an actual parameter.

-- 
Jeff Carter
"My mind is a raging torrent, flooded with rivulets of
thought, cascading into a waterfall of creative alternatives."
Blazing Saddles
89


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

* Re: Curious function signature issue
  2013-10-24 21:12 Curious function signature issue RasikaSrinivasan
  2013-10-24 22:03 ` Jeffrey Carter
@ 2013-10-24 22:04 ` Adam Beneschan
  1 sibling, 0 replies; 3+ messages in thread
From: Adam Beneschan @ 2013-10-24 22:04 UTC (permalink / raw)


On Thursday, October 24, 2013 2:12:28 PM UTC-7, RasikaSr...@gmail.com wrote:
> all
> 
> I have a package P that looks like this:
> 
> package P is
>    type Person_Type is private ;
>    function Create( targetsfile : String := "targets.dat" ;
>                     basalfile : String := "basal.dat" ;
>                     isffile : String := "isf.dat" ;
>                     icrfile : String := "icr.dat" )
>                    return Person_Type ;
>    function Create return Person_Type ;
> ....
> ....
> end P ;
 
> 
> I am curious how gnat (2013 if it matters) can distinguish between the two overloaded "Create" functions?
> 
> The project built successfully though I am yet to exercise the runtime.

> thanks for any clues, srini

You cannot use the Create function with no parameters, because Ada can't tell which one to use.  However, that doesn't prevent the package from compiling.  You won't get an error unless you actually try to use the Create function with no parameters.  (You could still define a function that renames the second Create and use that, however.)

If you're actually using P.Create with no parameters, and you're not getting an error, it's a GNAT bug.  But in that case I'd want to see a small example that demonstrates the problem, to make sure there aren't any other constructs that might be affecting something.

                              -- Adam 


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

end of thread, other threads:[~2013-10-24 22:04 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-10-24 21:12 Curious function signature issue RasikaSrinivasan
2013-10-24 22:03 ` Jeffrey Carter
2013-10-24 22:04 ` Adam Beneschan

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