jahboater wrote: ↑Wed Jul 03, 2019 3:49 pm

I suspect these people claiming that xxx language can do everything C can do, have not kept up with recent C standards.

And I suspect C++ with its five types of pointer is way ahead of all of them!

How would you write something like following in C supporting recent standards?

Code: Select all

```
dcl (i, k) fixed bin(31);
do i = 1 to 10, 9 to 1 by -1, 2 repeat 2*i while (i <= 1024);
put skip list(i);
end;
```

and output should be:

Code: Select all

```
1
2
3
4
5
6
7
8
9
10
9
8
7
6
5
4
3
2
1
2
4
8
16
32
64
128
256
512
1024
```

How about presenting Sudoku board in C. In PL/I, I can do:

Code: Select all

```
/* Sudoku board presentation from the book: The New PL/I. */
define alias bits bit(9) aligned;
dcl total(81) type bits;
dcl matrix(9, 9) type bits based(addr(total));
dcl box(9, 3, 3) type bits defined (total(trunc((1sub-1) /3) * 27 + mod(1sub-1, 3) * 3 + (2sub-1) * 9 + 3sub));
dcl posbit(0:9) type bits init('000000000'b, '100000000'b, '010000000'b, '001000000'b,
'000100000'b, '000010000'b, '000001000'b, '000000100'b,
'000000010'b, '000000001'b);
```

To test possible values for free cell:

Code: Select all

```
result = ^(any(matrix(i, *)) | any(matrix(*, j)) | any(box(numbox(i, j), *, *)));
/********************************************/
/* Returns box number for the sudoku coords */
/********************************************/
numbox: proc(i, j) returns(fixed bin(31));
dcl (i, j) fixed bin(31);
dcl lookup(9, 9) fixed bin(31) static nonasgn init( (3)1, (3)2, (3)3,
(3)1, (3)2, (3)3,
(3)1, (3)2, (3)3,
(3)4, (3)5, (3)6,
(3)4, (3)5, (3)6,
(3)4, (3)5, (3)6,
(3)7, (3)8, (3)9,
(3)7, (3)8, (3)9,
(3)7, (3)8, (3)9 );
return(lookup(i, j));
end numbox;
```

You mean smart pointers? To me they seem like a library or preprocessor ugly hacks, not true integrated parts of the core language.

jahboater wrote: ↑Wed Jul 03, 2019 3:49 pm

C and C++ do have a '->' operator by the way, used in the same manner as PL/1 by the looks of it.

Yeah, syntax was borrowed from PL/I . Just like they borrowed preprocessor and crippled it's syntax.

Here is how to calculate some fibonacci numbers into array using PL/I preprocessor:

Code: Select all

```
%fibonacci: proc (n, table) statement;
dcl n fixed;
dcl table char;
dcl (i, f1, f2, f3) fixed;
dcl nums char;
f1 = 1; f2 = 0;
nums = '0';
do i = 1 to n;
f3 = f1 + f2;
f1 = f2;
f2 = f3;
nums = nums || ',' || f3;
end;
ans('dcl ' || table || ' (0:' || n || ') fixed bin init (' || nums || ');') skip;
%end fibonacci;
%act fibonacci;
```

Here is an example on how to use it in program: