GNU Pascal Homepage - gpc - gpc-announce - gpc-de - gpc-doc
This page in English

Mail #10736

Zurück zur Archiv-Hauptseite

Vorige Mail   Nächste Mail   Unformatiert/Volle Header
Übersicht  10 Tage   Betreff   Datum   Thread   Autor  

Von: Tom Schneider
Betreff: Upper/lower case in identifiers
Datum: 10.9.2004, 18:42:00

program capbug(output);

(* capbug: capitalization bug in gpc compiler

  Dr. Thomas D. Schneider
  National Cancer Institute
  Laboratory of Experimental and Computational Biology
  Molecular Information Theory Group
  Frederick, Maryland  21702-1201
  toms@ncifcrf.gov
  permanent email: toms@alum.mit.edu (use only if first address fails)
  http://www.lecb.ncifcrf.gov/~toms/

 *)

const
(* begin module version *)
   version = 1.00; (* of capbug.p 2004 Sep 10
2004 Sep 10, 1.00: origin
*)
(* end module version *)

(* begin module describe.capbug *)
(*
name
   capbug: capitalization bug in gpc compiler

synopsis
   capbug(output: out)

files

   output: messages to the user

description

   Demonstrate capitals bug in GPC.  The name of a local procedure is
   objected to by GPC if there is a global by the same name but
   different capitalization.

   In theory the compiler should keep track of what is local and what
   is global anyway, so it should be able to avoid this.

   It is a problem because if one imports procedures from another
   program, they are not being treated as pure 'black boxes'.
   Instead, local variable names are being compared to the global
   variable names.

   In otherwords, the scope rule of Pascal is being violated
   when these warnings are generated.

   This problem is not fixed by adding the flag:

   -Widentifier-case-local
      Warn about an identifier written with varying case within one
      program/module/unit.

examples

gpc 20040516, based on gcc-3.3.3

for this program itself gives:

capbug.p:113: warning: capitalisation of `x' doesn't match
capbug.p:111: warning:  previous capitalisation `X'
capbug.p:113: warning: capitalisation of `y' doesn't match
capbug.p:111: warning:  previous capitalisation `Y'
capbug.p: In procedure `themain':
capbug.p:138: warning: capitalisation of `X' doesn't match
capbug.p:113: warning:  previous capitalisation `x'
capbug.p:139: warning: capitalisation of `Y' doesn't match
capbug.p:113: warning:  previous capitalisation `y'

The result is:

capbug 1.00
outside: x = 1
outside: y = 2
inside:  x = 3
inside:  y = 4
themain: X = 5
themain: Y = 6

which demonstrates that the scope rules are being followed when the
progrm runs, because X and Y are set before the calls to routines
outside and inside, but they are not affected by those calls.  That
is, the outside and inside routines have local variables.

documentation

see also

   {Manual on GPC that gives the -Widentifier-case-local flag:}
   http://www.gnu-pascal.de/gpc/GPC-Command-Line-Options.html

   {Discussion on the topic, "Upper/lower case in identifiers":}
   http://www.gnu-pascal.de/crystal/gpc/en/raw-mail7665.html

author

   Thomas Dana Schneider

bugs

technical notes

*)
(* end module describe.capbug *)

var
   X, Y: integer; (* global X and Y *)

procedure outside(x, y: integer);
(* an outside procedure *)
begin
   x := 1;
   y := 2;
   writeln(output,'outside: x = ',x:1);
   writeln(output,'outside: y = ',y:1);
end;

(* begin module capbug.themain *)
procedure themain;
(* the main procedure of the program *)

procedure inside(x, y: integer);
(* an inside procedure *)
begin
   x := 3;
   y := 4;
   writeln(output,'inside:  x = ',x:1);
   writeln(output,'inside:  y = ',y:1);
end;

begin
   writeln(output,'capbug ',version:4:2);

   X := 5;
   Y := 6;
   outside(X, Y);
   inside(X, Y);
   writeln(output,'themain: X = ',X:1);
   writeln(output,'themain: Y = ',Y:1);

end;
(* end module capbug.themain *)

begin
   themain;
end.

Vorige Mail   Nächste Mail   Unformatiert/Volle Header
Übersicht  10 Tage   Betreff   Datum   Thread   Autor  


Antworten auf diese Mail

Autor Betreff Datum
Waldek Hebisch Upper/lower case in identifiers 11.9.2004, 02:51:31

Zurück zur Archiv-Hauptseite


Hinweis: Diese Seite enthält Informationen, die nicht vom Betreiber dieser Website, sondern von den Autoren der archivierten Mails stammen. Der Betreiber dieser Website ist nicht für den Inhalt dieser Informationen verantwortlich. Die weitere Verwendung dieser Informationen bedarf des Einverständnisses des jeweiligen Autors.

Sofern WWW-Adressen (URLs) in den archivierten Mails als Hyperlinks hervorgehoben werden, so geschieht dies ausschließlich zur Annehmlichkeit für den Leser. Der Inhalt der auf diese Weise angelinkten Webseiten spiegelt nicht notwendigerweise die Meinung des Betreibers dieser Webseite oder der Autoren der archivierten Mails wider. Der Betreiber dieser Webseite ist nicht für den Inhalt solcher Webseiten verantwortlich. Diese Seiten sind ausdrücklich nicht als Teil des Inhalts dieser Seite zu betrachten, sondern lediglich als Referenzen.


Diese Seite wurde erzeugt von Crystal 0.999 (Linux 2.4.27/i686).