[plt-scheme] small question about mzscheme's source

From: Matthew Flatt (mflatt at cs.utah.edu)
Date: Mon May 3 22:27:45 EDT 2004

At Tue, 4 May 2004 03:14:40 +0200, "ifconfig" wrote:
> I was just taking a brief look in mzscheme's src, and I noticed in
> scheme_bitwise_shift (in /plt/src/mzschme/src/number.c) that you shift using
> bignum calculations if shift is more than MAX_SHIFT_TRY or less than
> -MAX_SHIFT_EVER. Under 32 bits, MAX_SHIFT_EVER is defined as 32, which makes
> sense. But why is MAX_SHIT_TRY 29? You could shift 30 bits, and ever 31
> without bignum calculations, couldn't you?

A MzScheme fixnum is represented using 31-bit two's complement. If you
shift a 1 left by 30 bits, you get the representation of -2^30 instead
of 2^31.

> Also, in /plt/src/mzscheme/src/schpriv.h, how do the following two lines
> help the compiler?
> /* Compiler helper: */
> #define ESCAPED_BEFORE_HERE  return NULL

Uses of ESCAPED_BEFORE_HERE help the compiler. This macro is used after
calls to scheme_wrong_type() or other functions that never return
(because they longjmp). The compiler can't know that those function
never return, so the "return NULL" forces a function abort after the
call. It's not quite as good as the compiler knowing about the error
functions, but it's better than nothing.

The code contains many "return NULL"s that would be better written

> And last but not least, are the basics of the compiler put in a
> specific file?

The top of eval.c is as much as there is.

> I'm trying to learn how to make a simple scheme->asm compiler for only
> basic data types, etc.

Perhaps this is clear already, but MzScheme doesn't have a Scheme->asm
compiler --- just a Scheme->bytecode compiler and a bytecode


Posted on the users mailing list.