Type detection: Difference between revisions

Line 1,076:
Pascal has a plethora of dialects, and so I have tried to be as close to ''Algorithms + Data Structures = Programs'' (Wirth) style as I could figure out how, when using the Free Pascal Compiler.
 
<lang pascal>program type_detection_demotypedetectiondemo (input, output);
type
source_tsourcetype = record case kind : (builtintext, filetext) of
builtintext : (i : integer);
filetext : (f : file of char);
end;
 
var
source : source_tsourcetype;
input : file of char;
c : char;
 
procedure print_textprinttext (var source : source_tsourcetype);
begin
case source.kind of
Line 1,110:
kind := builtintext;
i := 1;
print_textprinttext (source);
i := 2;
print_textprinttext (source);
kind := filetext;
f := input;
print_textprinttext (source)
end
end.</lang>
Line 1,123:
<pre>This is text 1.
This is text 2.
program type_detection_demotypedetectiondemo (input, output);
type
source_tsourcetype = record case kind : (builtintext, filetext) of
builtintext : (i : integer);
filetext : (f : file of char);
end;
 
var
source : source_tsourcetype;
input : file of char;
c : char;
 
procedure print_textprinttext (var source : source_tsourcetype);
begin
case source.kind of
Line 1,157:
kind := builtintext;
i := 1;
print_textprinttext (source);
i := 2;
print_textprinttext (source);
kind := filetext;
f := input;
print_textprinttext (source)
end
end.</pre>
1,448

edits