# BLISS

The following BLISS code has never been compiled or executed, and probably does not work. Nevertheless, it should be close to correct, so you at least can see what the language looked like. I don't believe that there is a running BLISS compiler anywhere. I ran across some source code for one, but it was written in BLISS ...

At one time BLISS was a serious alternative to C for systems programming. The main peculiarity of the language is it's handling of variables on the right hand side of an assignment. The backwards arrow, <-, is used for assignment. The expression

x <- x + 1

takes the address of x, adds one to it, and assigns the resultant address to x. To increment the current value of x you must use the . (period) operator to extract the value of x like this.

x <- .x + 1

Variables are untyped, so you can assign anything to anything.

!////////////////////////////////////////////////////////// !// Name: Peter M. Maurer !// Program: Sieve of Eratosthenes !// Due: Never !// Language: BLISS !////////////////////////////////////////////////////////// begin ! define the sieve data structure own Candidates[1000],i,j; ! everything is potentially prime until proven otherwise incr i from 0 to 999 do Candidates[.i] <- 1; ! Neither 1 nor 0 is prime, so flag them off Candidates[0] <- 0; Candidates[1] <- 0; ! start the sieve with the integer 0 i <- 0; while .i<1000 do begin ! advance to the next un-crossed out number. ! this number must be a prime while .i<1000 AND Candidates[.i] = 0 do i <- .i + 1; ! insure against running off the end of the data structure if .i<1000 then begin ! cross out all multiples of the prime, starting with 2*p. j <- 2; while .j*.i < 1000 do begin Candidates[.j*.i] <- 0; j <- j + 1; end ! advance to the next candidate i <- .i + 1; end end; ! all uncrossed-out numbers are prime (and only those numbers) ! print all primes incr i from 0 to 999 do if Candidates[i] NEQ 0 then ! The following function is fake. BLISS has no built-in I/O ! I guess you just used something from another language. Output(i," is prime\n"); end