EinfĂĽhrung
Einmal teilten die Teilnehmer in einem der Computerforen ihre Gedanken darüber mit, was ihnen bei ihren täglichen Aktivitäten sozusagen an Sprachen fehlt. Einer sagte, dass ihm ein Operator wie Put-Daten schmerzlich fehlte . Für diejenigen, die noch nichts davon gehört haben, werde ich erklären, dass die PL / 1-Sprache einen Operator zum Ausgeben (oder Eingeben) der Werte von Variablen zusammen mit ihren Namen bereitstellte, d. H. zusammen mit Bezeichnern.
, put list(X,Y); - :
1280 1024
put data(X,Y); :
X= 1280 Y= 1024
:
put list(’X=’,X,’Y=’,Y);
, . , put data, «» get data .
, «» ( ) put data .
, , () . put data . « », (.. ) . , exe- . «» . , , , put data, , . , «» . , .
-
, , put data . . , , . :
1. , -. , , . (.. ) , , , , .., .
2. , . , , . , , .
, . - .
put data , ( ) , « ».
. - «», . «» , .. , , -.
, , :
put data(x(i+1,j-1));
:
put list(’x(i+1,j-1)=’,x(i+1,j-1));
, -, . . , , .
-
« » . put data, – - . - , .
, put data , :
put data(x);
« » - :
do i=lbound(x) to hbound(x); put data(x(i)); end;
. , x – (, 33), put data(x); , - :
X(1,1)= 1 X(1,2)= 2 X(1,3)= 3 X(2,1)= 4 X(2,2)= 5 X(2,3)= 6 X(3,1)= 7 X(3,2)= 8 X(3,3)= 9
put data(x(2)); :
X(2,1)= 4 X(2,2)= 5 X(2,3)= 6
x – ( PL/1 ), , :
declare
1 a,
2 a1 fixed,
2 a2 fixed,
2 b,
3 b1 fixed,
3 b2 float;
put data(a);
A.A1= 0 A.A2= 0 A.B.B1= 0 A.B.B2= 0.000000E+00
, , (.. ), :
declare
1 a(1:2),
2 a1 fixed,
2 a2 fixed,
2 b,
3 b1 (-5:3) fixed,
3 b2 float;
put data(b);
B(1).B1(-5)= 0 B(1).B1(-4)= 0 B(1).B1(-3)= 0 B(1).B1(-2)= 0 B(1).B1(-1)= 0 B(1).B1(0)= 0 B(1).B1(1)= 0 B(1).B1(2)= 0 B(1).B1(3)= 0 B(1).B2= 0.000000E+00 B(2).B1(-5)= 0 B(2).B1(-4)= 0 B(2).B1(-3)= 0 B(2).B1(-2)= 0 B(2).B1(-1)= 0 B(2).B1(0)= 0 B(2).B1(1)= 0 B(2).B1(2)= 0 B(2).B1(3)= 0 B(2).B2= 0.000000E+00
PL/1 -. . - :
put list((x(i) do i=lbound(x) to hbound(x)));
:
do i=lbound(x) to hbound(x); put list(x(i)); end;
- . , PL/1 , , , . , :
put list(1e0*(x1+x2)/2e0));
, , - , . – , . .
, (put data) – . , . , , . . . – , , , -.
, -, « », . .
, put data, , . .. , , . - , , , , , , - .
, , . , , x(1:10,1:10,1:10) :
put list(x); 1000
put list(x(5)); 100
put list(x(5,6)); 10 .
put list(x(5,6,8)); - .
, put data , . ?A, ?B, ?,…?O ( 15 15) :
X(?A,?B)= 1 X(?A,?B)= 2 X(?A,?B)= 3 X(?A,?B)= 4 X(?A,?B)= 5 X(?A,?B)= 6 X(?A,?B)= 7 X(?A,?B)= 8 X(?A,?B)= 9
. put data – ?A, ?B, ?,…?O, 07FH.
, , , , , . . , , .
, put data - get data, , . , , PL/1 . , . , , put data(x);, :
X(1,2)= 2 X(1,1)= 1 X(2,3)= 6 X(2,1)= 4 X(2,2)= 5 X(3,1)= 7 X(1,3)= 3 X(3,2)= 8 X(3,3)= 9
get data(x); , . , , , , - . , , exe-, get data. , . – put data get data «» put get .
, - . , , - , . - , , , .
, , , , . , , , , -.
, , :
1. .
2. .
« » , , , « ».
, , . , , , , .. , put data.
, , , PL/1:
using System.Console;
using PL1.Macro;
module Program
{
Main() : void
{
def x = 1280;
def y = 1024;
put data(x, y);
put data(x, y, x + y, x.ToString() + "asd");
_ = ReadLine();
}
}
using Nemerle;
using Nemerle.Compiler;
using Nemerle.Compiler.Parsetree;
using System.Collections.Generic;
using System.Linq;
namespace PL1.Macro
{
public macro PutData(args)
syntax ("put", "data", args)
{
PutDataImpl.Impl(args)
}
module PutDataImpl
{
public Impl(args : PExpr) : PExpr
{
match (args)
{
| PExpr.Tuple as args =>
def code = List();
foreach (arg in args.args)
{
code.Add(<[ $(arg.ToString()) ]>);
code.Add(<[ "=" ]>);
code.Add(arg);
code.Add(<[ " " ]>);
}
code.RemoveAt(code.Count - 1);
def code = code.Aggregate((a1, a2) => <[ $a1 + $a2 ]>);
<[ System.Console.WriteLine($(code)) ]>
| _ => PExpr.Error(args.Location, "Tuple expected.")
}
}
}
}
Als ich jedoch gebeten wurde, die Bibliothek so zu ändern, dass nicht skalare Objekte mit Druck aller Indizes angezeigt werden können (und dann die Funktionen von PL / 1 wirklich wiederholt werden), wurde ich gebeten, dies selbst als "Hausaufgabe" zu tun. Ich lehnte diese Ehre unter dem Vorwand ab, dass ich das alles tatsächlich habe und es schon lange benutze. Anscheinend hat der Autor der Bibliothek einfach nicht sofort herausgefunden, wie das geht. Und aus irgendeinem Grund erinnerte ich mich an eine Szene aus dem Film "Formula of Love", in der Cagliostro, der alle mit einer Gabel überrascht hatte, sich immer noch weigerte, gleichzeitig einen Teller zu essen.