Hello, Is it possible for the main procedure to be inside a package? The compiler is GNAT.
Hello, Is it possible for the main procedure to be inside a package? The compiler is GNAT.
XXXX@XXXXX.COM a rit : No, the main procedure must be a library level procedure. I think that there is another restriction: this procedure should not have parameters (I have no easy way to check that right now). Pascal. -- --|------------------------------------------------------ --| Pascal Obry Team-Ada Member --| 45, rue Gabriel Peri - 78114 Magny Les Hameaux FRANCE --|------------------------------------------------------ --| http://www.**--****.com/ --| "The best way to travel is by means of imagination" --| --| gpg --keyserver wwwkeys.pgp.net --recv-key C1082595
That would make your program potentially non-portable. The only form of main procedure" that is required to be supported is "However, an implementation is required to support all main subprograms that are public parameterless library procedures." (RM 10.2.27) Cheers -- Martin
Pascal Obry a rit : Anything can be a main subprogram (the restriction was for 83), however only parameterless library procedures are guaranteed to be portable: LRM 10.2(29): An implementation may restrict the kinds of subprograms it supports as main subprograms. However, an implementation is required to support all main subprograms that are public parameterless library procedures. How to define the main subprogram (including the case where it is not a library procedure) is implementation defined, i.e. RTFM! -- --------------------------------------------------------- J-P. Rosen ( XXXX@XXXXX.COM ) Visit Adalog's web site at http://www.**--****.com/
No. The compiler would not know which procedure should be main because the main procedure can be called anything you like. However It can be a child procedure to a package. I use this feature quite often when I have packages just for one program. Works like this: package My_Package is end My_Package; procedure My_Package.My_Main is begin .... end My_Package.My_Main; Martin -- mailto:// XXXX@XXXXX.COM Ada programming at: http://www.**--****.com/
Even for Ada 83, a main program was not required to be a parameterless library procedure. I recall seeing at least one validated Ada 83 compiler that also allowed the main program to be a library level parameterless function returning an integer. The result of such a function sets the return code of the resulting process. For both Ada 83 and Ada 95, however, the only portable form for a main program is a library parameterless library procedure.
> Is it possible for the main procedure to be inside a package? The with My_Package; procedure Main is begin My_Package.Main; end;
Jean-Pierre Rosen < XXXX@XXXXX.COM > writes: True, but most Ada implementations support only the minimum required, here -- no main functions, no parameters on main procedures, and no main procedures nested in packages. - Bob
First u have to know that package cannot be executed directly. more than that if u create a main procedure inside the package then the compiler is unable to identify that main procedure and that main procedure will be treated as a normal procedure inside that particular package.
1.procedure inside package body and modelsim error
hi, int main(void) { main(); return 0; } wat does the standard says about the above code snippet?
3.module procedure in main program
The following program is bad f95 because it has a MODULE PROCEDURE declaration in a main program instead of in a module, where one is declaring a generic name for which the specific procedures are internal. But did the standard have to disallow that? Some compilers allow it,presumably as a language extension, printing complex case sqr((0,2)) = (-4.000000,0.0000000E+00) real case sqr( 2.0) = 4.000000 as I had expected. PROGRAM squaring INTERFACE sqr MODULE PROCEDURE rsqr,csqr END INTERFACE REAL x COMPLEX z PRINT*,'complex case sqr((0,2)) =',sqr((0,2)) PRINT*,'real case sqr( 2.0) =',sqr( 2.0 ) CONTAINS REAL FUNCTION rsqr(x) REAL,INTENT(IN)::x rsqr = x**2 END FUNCTION rsqr COMPLEX FUNCTION csqr(z) COMPLEX,INTENT(IN)::z csqr = z**2 END FUNCTION csqr END PROGRAM squaring Unless that could cause some ambiguity which I have failed to see, I suggest that f2008 either allow it, or introduce a new keyword INTERNAL PROCEDURE that one could use in an interface block in a main program or an external subprogram when, as above, the specific procedures it refers to are internal. The same issue could not arise in an internal subprogram unless f2008 allows them to contain internal subprograms. John Harper, School of Mathematics, Statistics and Computer Science, Victoria University, PO Box 600, Wellington, New Zealand e-mail XXXX@XXXXX.COM phone (+64)(4)463 5341 fax (+64)(4)463 5045
4.Importing variables from Main Expect Body to Procedures
After much Google searching and wasting time, I am still stuck on a fairly simple problem. I have written an expect script in which the lindex function is used to receive a password from the outside but then I got fancy and am trying to import it in to a procedure. The manual says that all variables are local unless you use the global designation which I did with no effect at all. Here is a stripped-down example of the script. The complaint from expect -d is that the variable pw can't be read. #!/usr/local/bin/expect -f #Pick up first argument as password. set pw [lindex $argv 0] #This has the proper value anywhere in the main body. #Feed it to proc login. proc login { } { send "$pw\r" expect { -exact "ord" { send -- "" expect -exact "\$" send -- "exit\r" expect eof exit 1 } -exact "\$" { return } } } I did try global pw and occupied a few more bytes of disk space, but nothing seems to import that variable into proc login. The other lines in the script do work if I hard-code the variable in to the procedure so this little problem is all that separates me from victory.:-). Any constructive ideas are much appreciated. -- Martin McCormick WB5AGZ Stillwater, OK Information Technology Division Network Operations Group
Hi there, When I .compile a procedure, it says, You compiled a main program while inside a procedure. Returning. And all the information before the compilation was lost. How to fix it? Thanks, sukye
Users browsing this forum: No registered users and 13 guest