🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

2 total messages Started by Marie-Josee Martin Thu, 30 Oct 1986 03:43
TML Pascal ver 2.01 bug
#7801
Author: Marie-Josee Martin
Date: Thu, 30 Oct 1986 03:43
34 lines
1345 bytes
Last night I was working with my newly received TML Pascal ver 2.01.  Well,
I managed to find what I think is a bug compiling some of my old programs.

Using the "Plain Vanilla" mode, TML doesn't pass variable text parameters
correctly, at least for input and output.  The following piece of code
compiles correctly but never runs correctly.  Actually, the program hangs
(and sometimes crashes.)


program main (input, output);

  procedure Sread (var f : text);
    begin
      writeln (SizeOf (f));
      get (f);
      while f^ <> 'q' do
        get (f)
    end;
    
  begin
    Sread (input)
  end.


By defining the procedure as:
  
  procedure Sread (f : text);

the program compiles correctly AND executes properly. (Try to figure
that out.)

Hope this saves someone some trouble.

-Marie-Josee.
Re: TML Pascal ver 2.01 bug
#7818
Author: Brian Bezanson
Date: Sun, 02 Nov 1986 05:44
38 lines
2360 bytes
In article <12125@watnot.UUCP>, mjmartin@watnot.UUCP (Marie-Josee Martin) writes:
> Using the "Plain Vanilla" mode, TML doesn't pass variable text parameters
> correctly, at least for input and output.  The following piece of code
> compiles correctly but never runs correctly.  Actually, the program hangs
> (and sometimes crashes.)
 
>   procedure Sread (var f : text);
>     begin
>       writeln (SizeOf (f));
>       get (f);
>       while f^ <> 'q' do
>         get (f)
>     end;
 
> By defining the procedure as:
>   procedure Sread (f : text);
> the program compiles correctly AND executes properly. (Try to figure
> that out.)

I tried a similiar procedure recently in a program running under Lightspeed
Pascal.  But when it tried to compile a procedure similiar to your second
one, WITHOUT the VARiable parameter, Lightspeed gave me an error.  What you
have to do is change it to a VAR parameter, no mater if you plan on changing
it or not.  The reason why (correct me somebody because this may not be perfect)
is that a file of type TEXT (or a file of char) is a pointer or start of
a buffer in memory for this file.  By passing it as a straight parameter,
the computer would try and pass a copy of the buffer onto the stack.  
By using a VAR parameter you are passing a pointer to this buffer, thus 
giving no memory problems at all.  Lightspeed is set up to watch for this
possible error, either TML misses this, or Leonard lets you try it and
when it gets pushed on the stack, the program either bombs or hangs.

I made the fix in my procedures and used VAR parameters and everything
worked fine, I would assume this should fix your problem with TML.

-- 
Brian Bezanson {seismo,ihnp4,allegra,topaz,harvard}!uwvax!gumby!bezanson
Manta Software Corp.				  bezanson@gumby.wisc.edu 
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads