Newsgroups: comp.lang.scheme
Path: cantaloupe.srv.cs.cmu.edu!bb3.andrew.cmu.edu!newsfeed.pitt.edu!gatech!newsfeed.internetmci.com!in2.uu.net!fi.gs.com!netnews.fi.gs.com!mcmanr
From: mcmanr@nytrdc19.eq.gs.com (Russ McManus)
Subject: Re: STOP ME before I CODE in C again!!!
In-Reply-To: hjstein@blinky.cpaf.com's message of 28 Mar 1996 10:55:04 GMT
Message-ID: <MCMANR.96Mar29104918@nytrdc19.eq.gs.com>
Sender: news@fi.gs.com (Netnews Administrator)
Nntp-Posting-Host: nytrdc19.eq.gs.com
Organization: International Equities - Goldman, Sachs & Co
References: <HJSTEIN.96Mar28125504@blinky.cpaf.com>
Date: Fri, 29 Mar 1996 15:49:17 GMT
Lines: 54

HJS is generally correct about the problems associated with
using scheme for real-world programs.  R4RS defines the core
of the language, but leaves too much of the OS interface out.
SLIB doesn't help much here, either.  

A scheme standard library is the way to go; people could quit 
worrying about the incompatibilities between different implementations.
The best starting point here is probably scsh.

As for the FFI issue, I agree with HJS that simplicity of
embedding is important.  I have tried the Guile, SIOD, libscheme,
Elk, and STk FFIs.  I was discouraged from trying to extend Scsh 
by the documentation.

In my experience, the libscheme interface is the simplest, and is
the only one that equals the simplicity of tcl.  Maybe it could 
serve as the starting point for a standard.  There are only 
two prototypes for extensions;  one for primitives and one for 
syntax.

A nearly complete libscheme extension:

#include "scheme.h"

static Scheme_Object *
my_nifty_proc(int argc, Scheme_Object *argv[]) {
    int i = some_c_stuff();
    return(scheme_make_integer(i));
}

void init_my_ext(Scheme_Env *env) {
    scheme_add_global("my-nifty-proc",  
	              scheme_make_prim(my_nifty_proc),  
                      env);
}


There are some limitations to libscheme that would discourage one from
using it as a stand-alone interpreter.  The problems include 
rudimentary error handling, no dynamic loading, no code compilation.
Memory management is clean thanks to the Boehm convervative gc (fewer
headaches than Guile or Elk, for instance).

    H> With Tcl, there's no need to ever write a complicated main()
    H> again - one can just develop afew specialized C routines, link
    H> it into the Tcl interpreter, and start using them.  Write some
    H> circuit analysis and layout routines, and use them immediately.

I use libscheme as you describe above, with even better results
(I get to use scheme).

-russ

p.s. kudos to brad benson for libscheme.
