4 ms·
The very first rudimentary standalone example: (define (main) (display "Hello world\n")) Doesn't compile, but instead gives error: Error: main:
by ta8645 2y ago
The very first rudimentary standalone example:
(define (main) (display "Hello world\n"))
Doesn't compile, but instead gives error:
Error: main: global variable `scheme#display' has unknown type
- JonChesterfield 2y agoThe popcount example does compile, if you drop the "assume" form, (import (chicken bitwise) (chicken fixnum)) (define (popcount32 x) ; From "Hacker's Delight" ; (assume (let ((x (fx- x (bitwise-and (arithmetic-shift x -1) #x55555555)))) (let ((x (fx+ (bitwise-and x #x33333333) (bitwise-and (arithmetic-shift x -2) #x33333333)))) (let ((x (bitwise-and (fx+ x (arithmetic-shift x -4)) #x0F0F0F0F))) (let ((x (fx+ x (arithmetic-shift x -8)))) (let ((x (fx+ x (arithmetic-shift x -16)))) (bitwise-and x #x0000003F))))))) Turns into somewhat redundant C, looks much like transliterated bytecode, e.g. long v17 = 0; // ... // popcnt.scm:7 v17 = 0; // ... // popcnt.scm:7 v17 = (t37 & 252645135); // popcount32 // popcnt.scm:8 t40 = crunch_arithmetic_shift(v17, -8); Interesting find in the (small) crunch.h is #ifdef CRUNCH_FREESTANDING #include <inttypes.h> #include <stdarg.h> #include <complex.h> #include "crunch-environment.h" #else // loads of stuff though I haven't found crunch-environment.h in the source yet
- tines 2y agoThe nice thing is that you can emit pretty sloppy C and the C compiler will optimize it pretty well.