Bill Richter | 18 Oct 2004 04:07

help with port from DrScheme?

I just downloaded gambc40b9 (haven't even built it; Linux binaries
seem to work), and I have some dumb questions about Gambit.  I have a
fair amount of DrScheme code, which runs very slow, and I'm a bit
tired of PLT right now, although I profited a lot from their teaching
approach.  I thought I'd port to Gambit for a speed increase.  So:

Mostly I'm doing mod 2 linear algebra.  That is, all my numbers are
either 0 or 1.  Isn't there some way to take advantage of that? 

Does Gambit have a case sensitive mode?  I didn't see anything like
this in the info files, but maybe there's an easy way to get it.  

Has anyone worked out ports of various DrScheme things, such as the
local construction?  Here's one dumb example:

(define (merge-1 shortlist longlist less-than?)
  ;; (listof x)^2 (x x -> boolean) -> (listof x) 
  ;; to merge a short list into a longer list, deleting repetitions, using less-than?.
  ;; (merge-1 '(4 8 9) '(1 2 3 5 6 7 9 10 11) <) => (1 2 3 4 5 6 7 8 10)
  (local ((define (phi a B X less-than?)
            ;; x (listof x)^2 (x x -> boolean) -> (listof x) 
            ;; to send a X B to (x_1 ... x_r a (mu B (x_{r+1} ... ))) if x_r < a < x_{r+1}
            (if (empty? X) 
                (cons a B)
                (let ([x_1 (first X)])
                  (if (equal? a x_1) 
                      (merge-1 B (rest X) less-than?)
                      (if (less-than? a x_1) 
                          (cons a (merge-1 B X less-than?))
                          (cons x_1 (phi a B (rest X) less-than?))))))))
(Continue reading)

David Van Horn | 18 Oct 2004 06:26
Picon

Re: help with port from DrScheme?

Bill Richter wrote:
> Has anyone worked out ports of various DrScheme things, such as the
> local construction?

Here is a syntax-rules macro for local:

(define-syntax local
  (syntax-rules (define)
    ((local defs . body)
     (letrec-syntax
         ((rev (syntax-rules ()
                 ((rev accum (x . rest) b) (rev (x . accum) rest b))
                 ((rev accum () b) (f () accum b))))
          (f (syntax-rules ()
               ((f accum ((define (var . spec) . e) . rest) b)
                (f ((var (lambda  spec . e)) . accum) rest b))
               ((f accum ((define var e) . rest) b)
                (f ((var e) . accum) rest b))
               ((f accum () b) (letrec accum . b)))))
       (rev () defs body)))))

David
Eric Merritt | 18 Oct 2004 07:02
Picon
Gravatar

Re: help with port from DrScheme?

Just a note, gsc doesn't seem to support define-syntax and the like. 

On Mon, 18 Oct 2004 00:26:34 -0400, David Van Horn <dvanhorn <at> cs.uvm.edu> wrote:
> Bill Richter wrote:
> > Has anyone worked out ports of various DrScheme things, such as the
> > local construction?
> 
> Here is a syntax-rules macro for local:
> 
> (define-syntax local
david rush | 18 Oct 2004 13:18
Picon
Gravatar

Re: help with port from DrScheme?

Eric Merritt <cyberlync <at> gmail.com> wrote:
> Just a note, gsc doesn't seem to support define-syntax and the 
> like.

But it does still support defmacro-style macros. Actually I thought
that I read in the release notes that define-syntax was in 4.0?

david rush
--

-- 
DIsruptive Technology!
Eric Merritt | 18 Oct 2004 20:11
Picon
Gravatar

Re: help with port from DrScheme?

I agree it does have a macro facility. I wasn't trying to say
otherwise.  Actually from the readme

--
The Gambit-C system conforms to the R4RS and IEEE Scheme standards.
--
and
--
- unhygienic macros
--

These two together suggest that it doesn't. Not that it really needs
it as long as it has defmacro-style macros. I suspect that if you
really really wanted syntax-case and define-syntax you could write
them with a defmacro style macro.

On a side note, I had nearly a million threads running last night, on
a stock pc, before I started running into timeout issues. Gambit 4 is
an awesome system.
Bill Richter | 19 Oct 2004 03:06

Re: help with port from DrScheme?

   > Has anyone worked out ports of various DrScheme things, such as
   > the local construction?

   Here is a syntax-rules macro for local:

Thanks, David!  Problem is, I'd have to learn syntax-rules...  I built
gambc40b9 last night, and another Drscheme question occurred to me:

Can Emacs look like the DrScheme editor?  The Gambit info files say:

   Gambit comes with the Emacs package `gambit.el' which provides a
   nice environment for running Gambit from within the Emacs editor.

and this sticks a number of gambit features into an *.scm file we read
into Emacs.  But I'd like more syntax highlighting, which I suppose
involves font-locking, and mainly I'd like this DrScheme feature:

an expression is highlighted if the point is at either end of it.

I'm sure these are simple enough Emacs questions, but folks here may
already know how to do this.
Marc Feeley | 20 Oct 2004 15:14
Picon

Gambit-C 4.0 beta 10

A new beta of Gambit-C 4.0 is now available in source form at this
address:

    http://www.iro.umontreal.ca/~feeley/gambc4b10.tar.gz

Here are the main changes:

   - all homogeneous vector primitives (u32vector, etc) should now
     work properly

   - fixed a few "configure" problems on Mac OS X and Solaris

   - should build without problems on 64 bit machines (I have only
     checked on a SUN Ultra-sparc, so if you have access to a 64
     bit machine, please report on your success)

   - interpreter handles procedure calls of up to 4 arguments
     faster than the general case (5 and more)

   - implementation of (vector 1 2 3 4) has been improved

   - I now include the portable "syntax-case" implementation that has
     been ported to version 4.0 of the Gambit-C interpreter (it is in
     misc/syntax-case.scm).  To use it start gsi like this:

          gsi misc/syntax-case.scm -

     You can also rename the file to gambcext.scm and move it to the
     Gambit installation directory (and even compile it with "gsc
     -dynamic gambcext.scm" if you wish to speedup macro expansion).
(Continue reading)

Kirill Lisovsky | 21 Oct 2004 06:06
Picon
Favicon

Re: help with port from DrScheme?

Hello!

On Mon, 18 Oct 2004, Bill Richter wrote:

> Can Emacs look like the DrScheme editor?  The Gambit info files say:
>
>    Gambit comes with the Emacs package `gambit.el' which provides a
>    nice environment for running Gambit from within the Emacs editor.
>
> and this sticks a number of gambit features into an *.scm file we read
> into Emacs.  But I'd like more syntax highlighting, which I suppose
> involves font-locking, and mainly I'd like this DrScheme feature:
>
> an expression is highlighted if the point is at either end of it.
>
Drop a look at:

http://www.neilvandyke.org/quack/

Best regards,
         Kirill.
Eric Knauel | 21 Oct 2004 09:14
Picon

Re: Gambit-C 4.0 beta 10


On Wed 20 Oct 2004 15:14, Marc Feeley <feeley <at> IRO.UMontreal.CA> writes:

>    - I now include the portable "syntax-case" implementation that has
>      been ported to version 4.0 of the Gambit-C interpreter (it is in
>      misc/syntax-case.scm).  To use it start gsi like this:
>
>           gsi misc/syntax-case.scm -
>
>      You can also rename the file to gambcext.scm and move it to the
>      Gambit installation directory (and even compile it with "gsc
>      -dynamic gambcext.scm" if you wish to speedup macro expansion).

Is there also a syntax-case implementation for the Gambit-C compiler
somewhere?

-Eric
--

-- 
"Excuse me --- Di Du Du Duuuuh Di Dii --- Huh Weeeheeee" (Albert King)
Marc Feeley | 21 Oct 2004 15:34
Picon

Re: Gambit-C 4.0 beta 10

> On Wed 20 Oct 2004 15:14, Marc Feeley <feeley <at> IRO.UMontreal.CA> writes:
> 
> >    - I now include the portable "syntax-case" implementation that has
> >      been ported to version 4.0 of the Gambit-C interpreter (it is in
> >      misc/syntax-case.scm).  To use it start gsi like this:
> >
> >           gsi misc/syntax-case.scm -
> >
> >      You can also rename the file to gambcext.scm and move it to the
> >      Gambit installation directory (and even compile it with "gsc
> >      -dynamic gambcext.scm" if you wish to speedup macro expansion).
> 
> Is there also a syntax-case implementation for the Gambit-C compiler
> somewhere?

You can add this line to misc/syntax-case.scm:

(define c#wrap-program
  (lambda (src)
    (c#expression->source (expand-syntax (##desourcify src)) src)))

If you want to be able to use this with gsc's batch mode, then you
should rename syntax-case.scm to gambcext.scm and put that file in the
Gambit installation directory.  But be aware that source code location
tracking will not work.  This is why syntax-case.scm is not built into
the system by default (if someone can make a clean port of syntax-case
to Gambit I'll gladly make it a built-in feature!).

Marc
(Continue reading)


Gmane