前書き
かつて、コンピュータフォーラムの1つで、参加者は日常の活動において、いわば言語に欠けているものについての考えを共有しました。一つは、彼が痛んで行方不明になったと言っプットデータ演算子を。これを聞いたことがない人のために、PL / 1言語が変数の値とその名前を出力(または入力)するための演算子を提供したことを説明します。識別子と一緒に。
, 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.")
}
}
}
}
しかし、すべてのインデックスを印刷して非スカラーオブジェクトを表示できるようにライブラリを変更するように求められたとき(そして、PL / 1の機能を実際に繰り返すように)、「宿題」として自分で行うように求められました。私はこの名誉を拒否しました。実際、私はこれをすべて持っており、長い間使用しているという口実でした。どうやら、ライブラリの作成者は、これを行う方法をすぐには理解していませんでした。そして、なぜか映画「愛のフォーミュラ」のシーンを思い出しました。カグリオストロは、フォークを食べてみんなを驚かせたのに、プレートを同時に食べることを拒否しました。