Giter Site home page Giter Site logo

algol60's Issues

Consecutive comments are not accepted

This bug report ist for Racktet 8.13 [cs] from May 2024.
The experimental Algol 60 system does not accept a program text with two consecutive comments.
The following example demonstrates this:

#lang algol60
begin
  comment
      Example of two consecutive comments
    ;
  comment
      Racket Algol 60 does not allow two consecutive comments
    ;
  printsln(`Hello!')
end

The error message is

program.rkt:7:6: parse error near <identifier>
  context...:
   /usr/share/racket/collects/syntax/readerr.rkt:15:2: -raise-read-error
   .../syntax/module-reader.rkt:82:28: read
   /usr/share/racket/collects/syntax/module-reader.rkt:211:2: wrap-internal
   .../syntax/module-reader.rkt:76:9: wrap-internal/wrapper

A parameterless function used as an expression is not called

This bug report demonstrates a problem with parameterless functions.

The following piece of code

#lang algol60
begin
  integer procedure getvalue;
     getvalue := 4;

  integer i;
  i := getvalue;
  printnln(i)
end

fails with this message:
bad value: expected a number, got #<procedure:getvalue>
In my understanding, the problem is that in

i := getvalue;

the function getvalue is not called. Instead, the generated code attempts to assign a function to an integer, which of course fails.
The following modified example works:

#lang algol60
begin
  integer procedure getvalue(arg);
     Boolean arg;
     getvalue := 4;
  integer i;
  i := getvalue(true);
  printnln(i)
end

This works because the call of a function with parameters is unambiguous.

To further clarify the more tricky aspects of parameterless functions, consider the following example:

#lang algol60

begin
  real procedure r;
  begin
    r := 5.0;
  end;

  real procedure p1(rv, rp);
    real rv;
    real procedure rp;
  begin
    p1 := rv + rp
  end;
  printnln(p1(r, r))
end

In Racket Algol 60 this does not work. Note that in the expression
p1(r, r)
the first occurance of r is a function call, while the second isn't. For some reason, Racket Algol 60 does not see the difference because r is parameterless.

Again, the introduction of a dummy parameter (to function r) disambiguates a function call from a reference to a function:

#lang algol60
begin
  real procedure r(x);
    Boolean x;
  begin
    r := 5.0;
  end;

  real procedure p1(rv, rp);
    real rv;
    real procedure rp;
  begin
    p1 := rv + rp(true)
  end;

  printnln(p1(r(true), r))
end

Now a function call requires a syntax that is different from a function reference and everything is fine.

Internal error compiling the "man or boy" test

This program (by Donald Knuth):

begin real procedure A(k, x1, x2, x3, x4, x5);
  value k; integer k;
  real x1, x2, x3, x4, x5;
  begin real procedure B;
    begin k := k - 1;
          B := A := A(k, B, x1, x2, x3, x4)
    end;
    if k <= 0 then A := x4 + x5 else B
  end;
  printnln(A(10, 1, -1, -1, 1, 0))
end

fails to compile, producing the following error:

val: unbound identifier;
 also, no #%top syntax transformer is bound
  context...:
   #(43855 intdef) [common scopes]
  other binding...:
   local
   #(-6132 module base) #(-6129 module) [common scopes]
  common scopes...:
   #(43766 module top-level) #(43776 local) #(43777 intdef)
   #(43781 local) #(43783 intdef) #(43786 local) #(43787 intdef)
   #(43788 local) #(43793 intdef) #(43795 local) #(43796 intdef)
   #(43815 local) #(43816 intdef) #(43818 local) #(43819 intdef)
   #(43822 local) #(43823 intdef) #(43824 local) #(43829 intdef)
   #(43831 local) #(43832 intdef) #(43846 local) #(43847 intdef)
   #(43854 local) in: val

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.