Reply: expect procedure name in procedure call(newbie)

ada

    Next

  • 1. Object.Operation and child package
    Hi Ada05 experts, Is it normal to reject compilation of Object.Operation notation when operation is in a child package: package Pack is type Typ is tagged null record; procedure Proc1 (Var : in Typ); end Pack; package Pack.Sub is procedure Proc2 (Var : in Typ); end Pack.Sub; with Pack.Sub; procedure Proc is Obj : Pack.Typ; begin Obj.Proc1; Obj.Proc2; end Proc; The second call does not compile (with gnat): proc.adb:6:04: no selector "Proc2" for type "Typ" defined at pack.ads: 3
  • 2. Size of Vector limited to 1024 MB of Heap Size
    Hi, my machine has 4 GB of RAM and I am wondering, why I can't use at least 2 or 3 GBytes to run an Ada program. It seems, that my Ada Compiler (Gnat 4.4.0) limit the memory to 2 GB per default. Is it possible to allocate more than 2 GB? Here is a simple example of an "evil" vector, that gains more memory in each pass. The program terminates exactly at 1024 MB of used Heap memory. with Ada.Containers.Vectors; procedure Heap is package Generic_Vector is new Ada.Containers.Vectors (Element_Type => Integer, Index_Type => Natural); Evil_Vector : Generic_Vector.Vector; begin -- Heap loop Generic_Vector.Append (Evil_Vector, Integer'Last); end loop; end Heap; heap(6374) malloc: *** mmap(size=2147487744) failed (error code=12) *** error: can't allocate region *** set a breakpoint in malloc_error_break to debug raised STORAGE_ERROR : heap exhausted I could not find a suitable Compiler switch or a parameter, that can be set for the operating system (linux). "ulimit -v" is already set to unlimited. "gnatmem" reports, that my water mark with 1024 MB is reached, but the final water mark is, needless to say, higher. Best regards, Dennis Hoppe

Reply: expect procedure name in procedure call(newbie)

Postby gate02 » Fri, 31 Dec 2004 00:53:32 GMT

You are calling a function as though it were a procedure.  This is
alright in C and C++, where the result is just silently thrown away,
but in Ada you have to do something with the result, such as assign it
or use it in a subsequent expression or routine call.

Similar Threads:

1.expect procedure name in procedure call(newbie)

Hello.

I've got 'expect procedure name in procedure call' warning but
I think my code is good
Inside testclass.adb I have Create function and when I'm trying to call
it from
main.adb unit I receive that error.

Below are full codes of my Ada units.

And by the way - how can I dynamically allocate memory for e.g. 10
elements(array of Floats)?
How can I reallocate them to 20 elements or 4?
How can I free the memory?

thanks in advance
best regards R

Codes:

main.adb:
--------
with testclass;
procedure Main is
object : testclass.rec1_Access;
begin
testclass.Create(object, 10);
end Main;

testclass.ads:
--------------
package testclass is
type rec1 is tagged private;
type rec1_Access is access rec1;
function Create(this: rec1_Access; s: Integer) return Integer;
private
type rec1 is tagged record
field: Integer;
end record;
end testclass;

testclass.adb:
--------------
package body testclass is
function Create(this: rec1_Access; s: Integer) return Integer is
begin
this.field :=s;
		return this.field;
	end Create;
end testclass;

2.calling non-PURE procedures in PURE procedures

In Fortran 95, a PURE procedure cannot call an intrinsic FUNCTION or
SUBOUTINE that is not PURE. The non-PURE instrinsic procedures I know
of are

DATE_AND_TIME
SYSTEM_CLOCK
RANDOM_NUMBER
RANDOM_SEED

Are there others?

Lahey/Fujitsu Fortran 95 does not catch the error of non_PURE
intrinsic functions in PURE procedures, nor did earlier versions of
Compaq Visual Fortran, but CVF 6.6C DOES catch the error. I found some
bugs in my code when upgrading from CVF 6.6 to CVF 6.6C.

The code below, saved in "nonpure.f", compiles without error for LF95
but not CVF 6.6C (which is the correct behavior).

LF95 compilation:
lf95 -c -nfix -f95 -nco nonpure.f
Lahey/Fujitsu Fortran 95 Express Release 5.70c                 
Compiling program unit nonpure_module at line 1:
Encountered 0 errors, 0 warnings in file nonpure.f.
Compiling file nonpure.f.

CVF compilation:
df -c -free -stand:f95 nonpure.f
Compaq Visual Fortran Optimizing Compiler Version 6.6 (Update C)
Copyright 2003 Compaq Computer Corp. All rights reserved.

nonpure.f
nonpure.f(7) : Error: Any procedure referenced in a PURE procedure,
including one referenced via a defined operation or assignmnent, must
be explicitly declared PURE.   [DATE_AND_TIME]
call date_and_time(xdate)
-----^
nonpure.f(12) : Error: Any procedure referenced in a PURE procedure,
including one referenced via a defined operation or assignmnent, must
be explicitly declared PURE.   [RANDOM_NUMBER]
call random_number(x)
-----^
nonpure.f(16) : Error: Any procedure referenced in a PURE procedure,
including one referenced via a defined operation or assignmnent, must
be explicitly declared PURE.   [RANDOM_SEED]
call random_seed()
-----^
nonpure.f(21) : Error: Any procedure referenced in a PURE procedure,
including one referenced via a defined operation or assignmnent, must
be explicitly declared PURE.   [SYSTEM_CLOCK]
call system_clock(ic)
-----^

! begin file nonpure.f
module nonpure_module
implicit none
contains
!
pure subroutine xdate_and_time()
character (len=8) :: xdate
call date_and_time(xdate)
end subroutine xdate_and_time
!
pure subroutine xrandom_number()
real :: x
call random_number(x)
end subroutine xrandom_number
!
pure subroutine xrandom_seed()
call random_seed()
end subroutine xrandom_seed
!
pure subroutine xsystem_clock()
integer :: ic
call system_clock(ic)
end subroutine xsystem_clock
end module nonpure_module

3.How to make a procedure call from another procedure

It is really simple:

proc example {} {puts "hello!"}

proc test {procname} {
   $procname
}
% test example
hello!

4.How to make a procedure call from another procedure

Hi,

I am new to Tcl/Tk and have a little prob. I have to make a procedure
call (within another procedure).The name of the procedure is stored in
a variable and it doesn't take any arguments. To be more clear, I have
a variable "procName" which stores the name of the procedure and I have
to call this procedure from another procedure say, "Proc1". I tried
writing
$procName
within the procedure "Proc1" but this does not make a call to the
specified procedure. How should I go about it?

Regards
-RG

5.Expect - hangs when called from a nested procedure.

Running Active Tcl 8.4.14 on Windows  XP.

Are there any known issues with Expect when called from a 2 level
nested procedure?  I have an FTP Expect script that hangs when the
calling script is moved to a procedure.

E.G  This works - top level script calls dialog procedure(see below
for dialog proc details.


expectFTP,tcl

    .................
    .................
    set variables
    spawn ftp $host

    set prompt     "(Name|login|Login|Username|User).*:.*"
    set sendString "$user1"

    # call diaglog proc
    dialog $spawn_id $prompt $sendString

    #set prompt     "Password:"
    set sendString "$userpassword1"

    #call dialog proc
    dialog $spawn_id $prompt $sendString


E.G  This fails - top level script calls expectFTP_proc procedure
which calls dialog proc details.  The "spawn" creates the FTP
connection, identifies the "User" prompt and submits the "userid" send
string but then the script hangs on "Password".  The debug output
indicates that there is no response from the "userid" send so the FTP
server waits for the userid while Expects looks for the password
prompt.

This only occurs when the code that calls dialog.proc is moved from
the top level script into a procedure.

I can email the complete script is anyone is interested .

Thanks.

Patrick.



expectFTP,tcl

    .................
    .................
    set variables

    # call expectFTP_proc

    expectFTP_proc

        set variables

        spawn ftp $host

        set prompt     "(Name|login|Login|Username|User).*:.*"
        set sendString "$user1"

        # call diaglog proc
        dialog $spawn_id $prompt $sendString

        #set prompt     "Password:"
        set sendString "$userpassword1"

        #call dialog proc
        dialog $spawn_id $prompt $sendString


==================================================

proc dialog { ftpSpawnId prompt sendString } {

    global ftpErrorMatch

    puts \n
    puts "spawnid         is $ftpSpawnId"
    puts "expected prompt is $prompt"
    puts "sendString      is $sendString"

    exp_log_user 1

    expect {

         -i $ftpSpawnId

         -re $prompt {
                puts "matched on prompt"
                exp_send      "$sendString\r"
                exp_send_user "$sendString\n"
         }

         "Unknown host" {
                puts "ERROR: Unknown host"
                expect *
                error "Expected: '$prompt'. Saw: $expect_out(buffer)"
         }


         $ftpErrorMatch {
                    puts "ERROR: FTP Error"
                    expect *
                    error "Expected: '$prompt'. Saw:
$expect_out(buffer)"
             }

         timeout {
                puts "ERROR: timeout exceeded"
                expect *
                error "Expected: '$prompt'. Saw: $expect_out(buffer)"
         }

         eof {
                expect *
                error "Expected: '$prompt'. Saw: $expect_out(buffer)"
         }
    }

    return [ array get expect_out ]

}

6. How to create a procedure that takes another procedure with an argument

7. procedure as argument in procedure

8. Nested procedures and procedure parameters



Return to ada

 

Who is online

Users browsing this forum: No registered users and 42 guest