From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII X-Google-Thread: 103376,2ea6ccd50b440aa7 X-Google-Attributes: gid103376,public From: "Samuel T. Harris" Subject: Re: Problem when overloading a procedure Date: 1999/08/17 Message-ID: <37B97883.5CE21955@hso.link.com>#1/1 X-Deja-AN: 513814726 Content-Transfer-Encoding: quoted-printable References: X-Accept-Language: en Content-Type: text/plain; charset=iso-8859-1 Organization: Raytheon Training Inc. Mime-Version: 1.0 Newsgroups: comp.lang.ada Date: 1999-08-17T00:00:00+00:00 List-Id: "JIMHER@yanoesladirecci=F3n.com" wrote: > = > I'm writing a program, and I have found a problem when I try to overloa= d > a procedure. The program is: > = > procedure program is > = > type MyType is array(1..10) of character; > = > procedure proc(s:in string) is > begin > put_line("Original string"); > end proc; > = > procedure proc(s:in MyType) is > begin > put_line("My type"); > end proc; > = > begin > proc("hello"); > end program; > = > The problem is that, when I compile the program, the compiler says that= > is unable to select between the two forms of 'proc'. I suppose that it = is > because the compiler can't decide if the literal "hello" is of type > string or MyType, so I tried > = > ... > begin > proc(string("hello")); > end program; > = As others have already pointed out, you need a "qualified expression." What you have is a "type conversion". The difference is significant eventhough the syntax is very similar. string("hello") is a type conversion. It looks like a function call but the function name is a type name. It also acts like a function call (at least semantically since many occurances need no code implementating them). As such, it suffers from the original problem, namely, what type to convert from? Just as proc can tell what type the string literal is suppose to be, the type converter string also can't tell what type the literal is suppose to be. string'("hello") is a type qualification. It means what it says. The little tick "'" after the type name makes all the difference. This says the expression inside the parenthesis is suppose to be of type string. Nothing happens. It is a way for the source to resolve ambiguities, especially when several derived scalar types are visible and literals are needed. > but the compiler didn't accept it. > = > I think that it will be some language way to tell the compiler if the > literal sent to 'proc' is of type string or of type MyType, so I would > thank a lot if any one could tell me how. Also, if it can be done by > another way, it could help me too. > = > Thanks in advance and sorry about my english > = > -- > Jes=FAs Jim=E9nez Herranz > vtis0102@CACANOps.uib.es > (Remove CACANO from the address) -- = Samuel T. Harris, Principal Engineer Raytheon, Scientific and Technical Systems "If you can make it, We can fake it!"