[gambit-list] Fatal crash
    Marc Feeley 
    feeley at iro.umontreal.ca
       
    Mon Apr 14 23:14:26 EDT 2008
    
    
  
On 14-Apr-08, at 10:53 PM, Marc Feeley wrote:
> It obviously can't be implemented as:
>
> (define (car x)
>   (car x))
>
> Since this is an infinite recursion.  Gambit's implementation of the
> car procedure corresponds roughly to this:
>
> (define (car x)
>
>   (declare (extended-bindings))
>
>   (if (pair? x)
>       (##car x)
>       (error "car expects a pair!")))
>
> The ##car procedure which is called by car is a version of car which
> assumes that the parameter is a pair.  In other words ##car is simply
> an indirection (with offset).
And if you are wondering how the ##car procedure is implemented, then  
it goes roughly like this:
(define (##car x)
   (declare (extended-bindings))
   (##car x))
Note that this is *not* an infinite recursion because the call to  
##car is inlined by the compiler.  This approach is used to define all  
the simple primitive procedures.
Marc
    
    
More information about the Gambit-list
mailing list