Acerca de la implementación de E / S con nombre

Introducción

Una vez, en uno de los foros informáticos, los participantes compartieron sus pensamientos sobre lo que les falta en los idiomas, por así decirlo, en sus actividades diarias. Uno dijo que le faltaba mucho un operador como poner datos . Para aquellos que no han oído hablar de esto, les explicaré que el lenguaje PL / 1 proporcionó un operador para generar (o ingresar) los valores de las variables junto con sus nombres, es decir, junto con identificadores.





, 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.")
      }
    }
  }
}

      
      



Sin embargo, cuando se me pidió que modificara la biblioteca para que permitiera mostrar objetos no escalares con la impresión de todos los índices (y luego realmente repetiría las capacidades de PL / 1), se me pidió que lo hiciera yo mismo como "tarea". Rechacé este honor, con el pretexto de que, de hecho, tengo todo esto y lo uso desde hace mucho tiempo. Aparentemente, el autor de la biblioteca simplemente no descubrió de inmediato cómo hacer esto. Y por alguna razón me acordé de una escena de la película "Fórmula del amor", donde Cagliostro, habiendo sorprendido a todos comiéndose un tenedor, seguía negándose a comer un plato al mismo tiempo.








All Articles